Пример #1
0
        public static void RegisterArgZeroProviderTypes(Type type, string[] args, Assembly assembly)
        {
            foreach (Type extender in assembly.GetTypes().Where(t => t.ExtendsType(type)))
            {
                ((IRegisterArguments)extender.Construct()).RegisterArguments(args);
                string name = extender.Name;
                if (!extender.Name.EndsWith("Provider"))
                {
                    Message.PrintLine("For clarity and convention, the name of type {0} should end with 'Provider'", ConsoleColor.Yellow);
                }
                else
                {
                    name = name.Truncate("Provider".Length);
                }

                ProviderTypes.AddMissing(name, extender);
            }
        }
Пример #2
0
        /// <summary>
        /// Register extenders of the specified type from the specified assembly as shell providers ensuring that their required arguments
        /// are also properly registered.
        /// </summary>
        /// <param name="args"></param>
        /// <param name="assembly"></param>
        /// <typeparam name="T"></typeparam>
        public static void RegisterArgZeroProviderTypeArguments <T>(string[] args, Assembly assembly) where T : IRegisterArguments
        {
            foreach (Type type in assembly.GetTypes().Where(type => type.ExtendsType <T>()))
            {
                type.Construct <T>().RegisterArguments(args);
                string name = type.Name;
                if (!type.Name.EndsWith("Provider"))
                {
                    Message.PrintLine("For clarity and convention, the name of type {0} should end with 'Provider'", ConsoleColor.Yellow);
                }
                else
                {
                    name = name.Truncate("Provider".Length);
                }

                ProviderTypes.AddMissing(name, type);
            }
        }