Split VAR.WebForms.Common to a class library.
This commit is contained in:
29
VAR.WebForms.Common/Code/GlobalConfig.cs
Normal file
29
VAR.WebForms.Common/Code/GlobalConfig.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace VAR.WebForms.Common.Code
|
||||
{
|
||||
public static class GlobalConfig
|
||||
{
|
||||
private static IGlobalConfig _globalConfig = null;
|
||||
|
||||
public static IGlobalConfig Get()
|
||||
{
|
||||
if (_globalConfig == null)
|
||||
{
|
||||
Type iGlobalConfig = typeof(IGlobalConfig);
|
||||
Type foundGlobalConfig = AppDomain.CurrentDomain
|
||||
.GetAssemblies()
|
||||
.SelectMany(x => x.GetTypes())
|
||||
.Where(x =>
|
||||
x.IsAbstract == false &&
|
||||
x.IsInterface == false &&
|
||||
iGlobalConfig.IsAssignableFrom(x) &&
|
||||
true)
|
||||
.FirstOrDefault();
|
||||
_globalConfig = ObjectActivator.CreateInstance(foundGlobalConfig) as IGlobalConfig;
|
||||
}
|
||||
return _globalConfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user