Exemplo n.º 1
0
        private KeyValuePair <string, IModule> ExpandNamedModule(IModule module)
        {
            NamedModule namedModule = module as NamedModule;

            return(namedModule != null
                ? new KeyValuePair <string, IModule>(namedModule.Name, namedModule.Module)
                : new KeyValuePair <string, IModule>(null, module));
        }
Exemplo n.º 2
0
        public static void Replace(this IModuleList moduleList, int index, IModule module, string name = "")
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                NamedModule namedModule = moduleList[index] as NamedModule;
                if (namedModule != null)
                {
                    name = namedModule.Name;
                }
            }

            moduleList.RemoveAt(index);
            moduleList.Insert(index, name, module);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Replaces a module at the specified index.
        /// </summary>
        /// <param name="moduleList">The <see cref="ModuleList"/>.</param>
        /// <param name="index">The index of the module to replace.</param>
        /// <param name="module">The replacement module.</param>
        /// <param name="name">An optional name of the replacement module.</param>
        /// <typeparam name="TModuleList">The type of the module list.</typeparam>
        /// <returns>The current instance.</returns>
        public static TModuleList Replace <TModuleList>(this TModuleList moduleList, int index, IModule module, string name = null)
            where TModuleList : IModuleList
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                NamedModule namedModule = moduleList[index] as NamedModule;
                if (namedModule != null)
                {
                    name = namedModule.Name;
                }
            }

            moduleList.RemoveAt(index);
            moduleList.Insert(index, name, module);
            return(moduleList);
        }