/// <summary>
        /// Creates and adds a <see cref="ModuleInfoGroup"/> to the catalog.
        /// </summary>
        /// <param name="catalog">The catalog to add the module to.</param>
        /// <param name="initializationMode">Stage on which the module group to be added will be initialized.</param>
        /// <param name="refValue">Reference to the location of the module group to be added.</param>
        /// <param name="moduleInfos">Collection of <see cref="ModuleInfo"/> included in the group.</param>
        /// <returns>The same <see cref="IModuleCatalog"/> with the added module group.</returns>
        public static IModuleCatalog AddGroup(this IModuleCatalog catalog, InitializationMode initializationMode, string refValue, params ModuleInfo[] moduleInfos)
        {
            if (!(catalog is IModuleGroupsCatalog groupSupport))
            {
                throw new NotSupportedException(Resources.MustBeModuleGroupCatalog);
            }

            if (moduleInfos == null)
            {
                throw new ArgumentNullException(nameof(moduleInfos));
            }

            ModuleInfoGroup newGroup = new ModuleInfoGroup
            {
                InitializationMode = initializationMode,
                Ref = refValue
            };

            foreach (var info in moduleInfos)
            {
                newGroup.Add(info);
            }

            groupSupport.Items.Add(newGroup);

            return(catalog);
        }
 /// <summary>
 /// Adds a new module that is statically referenced to the specified module info group.
 /// </summary>
 /// <param name="moduleInfoGroup">The group where to add the module info in.</param>
 /// <param name="moduleType">The type for the module. This type should be a descendant of <see cref="IModule"/>.</param>
 /// <param name="dependsOn">The names for the modules that this module depends on.</param>
 /// <returns>Returns the instance of the passed in module info group, to provide a fluid interface.</returns>
 /// <remarks>The name of the module will be the type name.</remarks>
 public static ModuleInfoGroup AddModule(
     this ModuleInfoGroup moduleInfoGroup,
     Type moduleType,
     params string[] dependsOn)
 {
     if (moduleType == null)
     {
         throw new ArgumentNullException("moduleType");
     }
     return(AddModule(moduleInfoGroup, moduleType.Name, moduleType, dependsOn));
 }
        public virtual ModuleCatalog AddGroup(InitializationMode initializationMode, string refValue, params ModuleInfo[] moduleInfos)
        {
            if (moduleInfos == null) throw new System.ArgumentNullException("moduleInfos");

            ModuleInfoGroup newGroup = new ModuleInfoGroup();
            newGroup.InitializationMode = initializationMode;
            newGroup.Ref = refValue;

            foreach (ModuleInfo info in moduleInfos)
            {
                newGroup.Add(info);
            }

            this.items.Add(newGroup);

            return this;
        }
        /// <summary>
        /// Adds a new module that is statically referenced to the specified module info group.
        /// </summary>
        /// <param name="moduleInfoGroup">The group where to add the module info in.</param>
        /// <param name="moduleName">The name for the module.</param>
        /// <param name="moduleType">The type for the module. This type should be a descendant of <see cref="IModule"/>.</param>
        /// <param name="dependsOn">The names for the modules that this module depends on.</param>
        /// <returns>Returns the instance of the passed in module info group, to provide a fluid interface.</returns>
        public static ModuleInfoGroup AddModule(
            this ModuleInfoGroup moduleInfoGroup,
            string moduleName,
            Type moduleType,
            params string[] dependsOn)
        {
            if (moduleType == null)
            {
                throw new ArgumentNullException("moduleType");
            }
            if (moduleInfoGroup == null)
            {
                throw new ArgumentNullException("moduleInfoGroup");
            }

            ModuleInfo moduleInfo = new ModuleInfo(moduleName, moduleType.AssemblyQualifiedName);

            moduleInfo.DependsOn.AddRange(dependsOn);
            moduleInfoGroup.Add(moduleInfo);
            return(moduleInfoGroup);
        }