G
Guest
We have a project that we are developing in C# and one of our biggest requirements is that this be a single application but that many of the functions be customized depending on which cost center the user belongs to. In reality, what this typically means is that the user interfaces are the same everywhere but there are some business logic that is different from cost center to cost center. As much as possible we are building switches into the code from logic that we can anticipate, but we realize from experience (this is v3 of this product) that it just isn't possible to handle all business logic through switches and some custom code will be required. So, my question is what techniques have others found work in C# for accomplishing this goal? The "core" components cannot be modified, but it is acceptable to add new custom components to the application that might override some of the functionality of those "core" components.
I'm relatively new to C# (former VB6 programmer) and from what I've found so far, it appears that using delegates may be a promising technique. The one gotcha that I've run into so far is that I can't figure out how to get a reference to a component and function at runtime to use as the delegate. What I mean is that I would like my "core" function to lookup (in a database or session variable) the file name of an assembly which holds the delegate function and then call it in place of the compiled function code. So, pseudo-code might look like:
void CoreFunc()
{
// See if there is a cost center specific delegate
if( _costCenterAssemblyName != "" )
{
call GetDelegateFunc( _costCenterAssemblyName + ".CoreFunc()" );
return;
}
// Otherwise, do what you would normally do...
...
}
Any help with how to accomplish this or suggestions of a better method would be greatly appreciated.
Thanks!!!
Ian
I'm relatively new to C# (former VB6 programmer) and from what I've found so far, it appears that using delegates may be a promising technique. The one gotcha that I've run into so far is that I can't figure out how to get a reference to a component and function at runtime to use as the delegate. What I mean is that I would like my "core" function to lookup (in a database or session variable) the file name of an assembly which holds the delegate function and then call it in place of the compiled function code. So, pseudo-code might look like:
void CoreFunc()
{
// See if there is a cost center specific delegate
if( _costCenterAssemblyName != "" )
{
call GetDelegateFunc( _costCenterAssemblyName + ".CoreFunc()" );
return;
}
// Otherwise, do what you would normally do...
...
}
Any help with how to accomplish this or suggestions of a better method would be greatly appreciated.
Thanks!!!
Ian