/// <summary>
        /// Returns an array with the modules found by using reflection.
        /// </summary>
        /// <returns>An array of <see cref="IModuleInfo"/>. An empty array is returned if no module is located.</returns>
        public IModuleInfo[] EnumerateModules()
        {
            List<ModuleInfo> modules = new List<ModuleInfo>();
            List<string> directories = new List<string>();

            directories.Add(BasePath);
            while (directories.Count > 0)
            {
                string directory = directories[0];
                directories.Remove(directory);
                foreach (string filename in Directory.GetFiles(directory, "*.dll"))
                {
                    Assembly assm = Assembly.LoadFile(filename);
                    if (AssemblyHasModuleAttribute(assm))
                    {
                        ModuleInfo mi = new ModuleInfo();
                        mi.SetAssemblyFile(filename);
                        modules.Add(mi);
                    }
                }
                directories.AddRange(Directory.GetDirectories(directory));
            }

            return modules.ToArray();
        }
        public IModuleInfo[] Parse(string xml)
        {
            SolutionProfileElement solution = XmlValidationHelper.DeserializeXml<SolutionProfileV1.SolutionProfileElement>(xml,
                "SolutionProfileV1.xsd", Namespace);

            List<ModuleInfo> mis = new List<ModuleInfo>();

            if (solution.Modules != null) {
                foreach (ModuleInfoElement moduleInfo in solution.Modules) {
                    ModuleInfo mi = new ModuleInfo(moduleInfo.AssemblyFile);
                    SetModuleRoles(moduleInfo, mi);
                    mis.Add(mi);
                }
            }

            return mis.ToArray();
        }
Example #3
0
 private static void SetModuleRoles(ModuleInfoElement moduleInfo, ModuleInfo mi)
 {
     if (moduleInfo.Roles != null && moduleInfo.Roles.Length > 0)
         foreach (RoleElement role in moduleInfo.Roles)
             mi.AddRoles(role.Allow);
 }
 private static IModuleInfo[] CreateModuleInfos(SolutionProfileElement solutionProfile)
 {
     ModuleInfo[] mInfos = new ModuleInfo[solutionProfile.Modules.Length];
     for (int i = 0; i < solutionProfile.Modules.Length; i++)
     {
         ModuleInfoElement xsdModule = solutionProfile.Modules[i];
         ModuleInfo mInfo = new ModuleInfo(xsdModule.AssemblyFile);
         mInfo.SetUpdateLocation(xsdModule.UpdateLocation);
         if (xsdModule.Roles != null && xsdModule.Roles.Length > 0)
         {
             foreach (RoleElement role in xsdModule.Roles)
             {
                 mInfo.AddRoles(role.Allow);
             }
         }
         mInfos[i] = mInfo;
     }
     return mInfos;
 }