public override bool Execute()
        {
            using var fileStream = File.Create(RootDescriptorFilePath.ItemSpec);
            var assemblyNames = AssemblyNames.Select(a => a.ItemSpec);

            WriteRootDescriptor(fileStream, assemblyNames);
            return(true);
        }
Пример #2
0
 /// <summary>
 /// Adds specificly configured assemblies.
 /// </summary>
 /// <param name="addedAssemblyNames">The added assembly names.</param>
 /// <param name="assemblies">The assemblies.</param>
 protected virtual void AddConfiguredAssemblies(List <string> addedAssemblyNames, List <Assembly> assemblies)
 {
     foreach (Assembly assembly in AssemblyNames.Select(Assembly.Load).Where(assembly => !addedAssemblyNames.Contains(assembly.FullName)))
     {
         assemblies.Add(assembly);
         addedAssemblyNames.Add(assembly.FullName);
     }
 }
Пример #3
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);
     }
 }
Пример #4
0
        public static Assembly[] GetAllAssemblies()
        {
            var assemblies = AppDomain.CurrentDomain.GetAssemblies();

            var assembliesList = assemblies.ToList().Where(a => AssemblyNames.Any(an => a.FullName.Contains(an))).OrderBy(x => x.FullName.Contains("ApiCore")).ToList();

            var assembliesArray = assembliesList.OrderBy(a => a.FullName.Contains("ApiCore")).ToArray();

            return(assembliesArray);
        }
        private void SanitizeInput()
        {
            AssemblyPaths = AssemblyPaths.Select(p => p
                                                 .Replace('\\', Path.DirectorySeparatorChar)
                                                 .Replace('/', Path.DirectorySeparatorChar))
                            .Distinct()
                            .ToArray();

            AssemblyNames = AssemblyNames
                            .Where(n => !string.IsNullOrWhiteSpace(n))
                            .Distinct()
                            .ToArray();
        }
Пример #6
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);
     }
 }
Пример #7
0
    public static Assembly GetAssembly(string name)
    {
        if (assemblies == null)
        {
            FillAssemnblyArrays();
        }
        int i = AssemblyNames.ToList().IndexOf(name);

        if (i < 0)
        {
            return(null);
        }
        else
        {
            return(GetAssembly(i));
        }
    }
Пример #8
0
 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);
     }
 }