コード例 #1
0
 public WebAppTypeFinder(Web.IWebContext webContext, EngineSection engineConfiguration)
 {
     this.webContext = webContext;
     this.ensureBinFolderAssembliesLoaded = engineConfiguration.DynamicDiscovery;
     foreach (var assembly in engineConfiguration.Assemblies.AllElements)
     {
         AssemblyNames.Add(assembly.Assembly);
     }
 }
コード例 #2
0
 public static Type GetTypeByQualifiedName(string name)
 {
     try
     {
         Type type;
         TypeCache.TryGetValue(name, out type);
         if (ReferenceEquals(type, null))
         {
             if (Assemblies == null || Assemblies.Any())
             {
                 Assemblies = GetAllAssemblies();
             }
             foreach (var asm in Assemblies.Where(assembly => !AssemblyNames.Contains(assembly.FullName)))
             {
                 AssemblyNames.Add(asm.FullName);
             }
             foreach (var assemblyName in AssemblyNames)
             {
                 type = Type.GetType(name + "," + assemblyName);
                 if (!ReferenceEquals(type, null))
                 {
                     break;
                 }
             }
             if (ReferenceEquals(type, null))
             {
                 foreach (var assemblyName in AssemblyNames)
                 {
                     string temp = assemblyName.Substring(0, assemblyName.IndexOf(",", StringComparison.Ordinal));
                     type = Type.GetType(temp + "." + name + "," + assemblyName);
                     if (!ReferenceEquals(type, null))
                     {
                         break;
                     }
                 }
             }
             if (ReferenceEquals(type, null))
             {
                 return(null);
             }
             TypeCache.Add(name, type);
         }
         return(type);
     }
     catch (Exception e)
     {
         Debug.LogError(string.Format("QReflection - Get Type by Qualified Name : Can't find the type - {0} - with the exception." + e, name));
         return(null);
     }
 }
コード例 #3
0
ファイル: WebAppTypeFinder.cs プロジェクト: nikita239/Aspect
 public WebAppTypeFinder(TypeCache assemblyCache, EngineSection engineConfiguration)
 {
     this.assemblyCache    = assemblyCache;
     this.dynamicDiscovery = engineConfiguration.DynamicDiscovery;
     this.enableTypeCache  = engineConfiguration.Assemblies.EnableTypeCache;
     if (!string.IsNullOrEmpty(engineConfiguration.Assemblies.SkipLoadingPattern))
     {
         this.AssemblySkipLoadingPattern = new Regex(engineConfiguration.Assemblies.SkipLoadingPattern);
     }
     if (!string.IsNullOrEmpty(engineConfiguration.Assemblies.RestrictToLoadingPattern))
     {
         this.AssemblyRestrictToLoadingPattern = new Regex(engineConfiguration.Assemblies.RestrictToLoadingPattern);
     }
     logger.DebugFormat("EnableTypeCache: {0}, DynamicDiscovery: {1}, AssemblySkipLoadingPattern:{2}, AssemblyRestrictToLoadingPattern: {3}", enableTypeCache, dynamicDiscovery, AssemblySkipLoadingPattern, AssemblyRestrictToLoadingPattern);
     foreach (var assembly in engineConfiguration.Assemblies.AllElements)
     {
         logger.DebugFormat("Adding configured assembly {0}", assembly.Assembly);
         AssemblyNames.Add(assembly.Assembly);
     }
 }