TC1
-- CodeModuleA
TC2
-- CodeModuleA
I'd like to place a C# conditional statement in CodeModuleA, that is based on which TC the module is being run from. Something along the lines of:
if (TC1)
{
...
}
else if (TC2)
{
...
}
Basically I want to do one thing if the code module is being run as part of TC1 and do something else if the code module is being run as part of TC2.
How can I write that condition?
Thanks!
C# Conditional Question
Re: C# Conditional Question
If you are doing different things, you should split your current module into different modules. Each module should do one thing.
If there is a portion of the module that you want to use in both places, take it out and make it its own module.
For example, say you want to do actions A and B in TC1, and A and C in TC2. Right now you have module A that does it all. Instead, make a module for A, a module for B, and a module for C. Then just put them where you need them.
This is why it is recommended to make the modules as small as possible. It is much easier to manage and manipulate them if they are only doing one thing.
To answer your actual question, I think it is possible, but I believe it uses an internal, non-public API that could change in the future without warning, and it is not recommended to use those.
If there is a portion of the module that you want to use in both places, take it out and make it its own module.
For example, say you want to do actions A and B in TC1, and A and C in TC2. Right now you have module A that does it all. Instead, make a module for A, a module for B, and a module for C. Then just put them where you need them.
This is why it is recommended to make the modules as small as possible. It is much easier to manage and manipulate them if they are only doing one thing.
To answer your actual question, I think it is possible, but I believe it uses an internal, non-public API that could change in the future without warning, and it is not recommended to use those.
Shortcuts usually aren't...
-
- Certified Professional
- Posts: 455
- Joined: Tue Feb 18, 2014 2:14 pm
- Location: Co Louth, Ireland
- Contact:
Re: C# Conditional Question
Thanks for your helpful reply krstcs, I am currently considering your suggestions and the best option for doing this.