public static void LoadConfiguration() { var octoSec = ConfigurationManager.GetSection("spock/octopus") as OctopusSection; if (octoSec != null && octoSec.ServiceBlocks != null) { ServiceBlocks = new Dictionary <string, ServiceBlock>(octoSec.ServiceBlocks.Count); ServiceTypes = new Dictionary <string, Assembly>(); ServiceTypesCrossDomain = new Dictionary <string, Assembly>(); foreach (ServiceBlockConf svcBlockConf in octoSec.ServiceBlocks) { var serviceBlock = new ServiceBlock(svcBlockConf.Name); var asmDir = svcBlockConf.AssemblyLocation; foreach (DependenceConf dependConf in svcBlockConf.Dependencies) { string fileDll = string.Format("{0}/{1}", asmDir, dependConf.Assembly); Assembly assembly = null; if (dependConf.IsCrossDomain) { AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; assembly = AppDomain.CurrentDomain.Load("@#" + fileDll); ServiceTypesCrossDomain[assembly.FullName] = assembly; } else { assembly = Assembly.LoadFrom(Path.GetFullPath(fileDll)); ServiceTypes[assembly.FullName] = assembly; } serviceBlock.Assemblies.Add(assembly); //Cargamos el tipo que se injectará en el servicio if (svcBlockConf.GenericParameter != null && dependConf.Assembly.ToLower().Equals(svcBlockConf.GenericParameter.Assembly.ToLower())) { serviceBlock.InjectionType = assembly.GetType(svcBlockConf.GenericParameter.Class); serviceBlock.IsGeneric = serviceBlock.InjectionType.IsGenericType; } ServiceBlocks[serviceBlock.Name] = serviceBlock; } } } }
public static void LoadConfiguration() { var octoSec = ConfigurationManager.GetSection("spock/octopus") as OctopusSection; if (octoSec != null && octoSec.ServiceBlocks != null) { ServiceBlocks = new Dictionary<string, ServiceBlock>(octoSec.ServiceBlocks.Count); ServiceTypes = new Dictionary<string, Assembly>(); ServiceTypesCrossDomain = new Dictionary<string, Assembly>(); foreach (ServiceBlockConf svcBlockConf in octoSec.ServiceBlocks) { var serviceBlock = new ServiceBlock(svcBlockConf.Name); var asmDir = svcBlockConf.AssemblyLocation; foreach (DependenceConf dependConf in svcBlockConf.Dependencies) { string fileDll = string.Format("{0}/{1}", asmDir, dependConf.Assembly); Assembly assembly = null; if (dependConf.IsCrossDomain) { AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; assembly = AppDomain.CurrentDomain.Load("@#" + fileDll); ServiceTypesCrossDomain[assembly.FullName] = assembly; } else { assembly = Assembly.LoadFrom(Path.GetFullPath(fileDll)); ServiceTypes[assembly.FullName] = assembly; } serviceBlock.Assemblies.Add(assembly); //Cargamos el tipo que se injectará en el servicio if (svcBlockConf.GenericParameter != null && dependConf.Assembly.ToLower().Equals(svcBlockConf.GenericParameter.Assembly.ToLower())) { serviceBlock.InjectionType = assembly.GetType(svcBlockConf.GenericParameter.Class); serviceBlock.IsGeneric = serviceBlock.InjectionType.IsGenericType; } ServiceBlocks[serviceBlock.Name] = serviceBlock; } } } }