|
using System;
using System.Reflection;
public static class BusinessFactory
{
public static IBusiness Create(string businessName)
{
Assembly a = Assembly.GetExecutingAssembly();
Type[] types = a.GetTypes();
foreach (Type t in types)
{
if (t.Namespace == "Business")
{
if (t.FullName.EndsWith(businessName))
{
return Activator.CreateInstance(t) as IBusiness;
}
}
}
throw new ApplicationException(string.Format("Business object [{0}] not known", businessName));
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Hi my name is Dries de Groot. I have a Masters degree in applied physics and am graduated in solid-state matter. Besides that I am a .NET Professional with scrum certificates