コード例 #1
0
        /// <summary>
        /// Configure the builder by default from attributes.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static ICommandLineModuleManifestBuilder WithDefaultsFromModuleType(this ICommandLineModuleManifestBuilder builder, Type type)
        {
            if (type.IsDefined(typeof(CommandsFromAssemblyAttribute)))
            {
                builder.WithCommandsFromModuleAssembly(type);
            }

            var cmdAttrs = type.GetCustomAttributes <CommandFromAttribute>(true);

            foreach (var attr in cmdAttrs)
            {
                builder.AddCommand(attr.Type);
            }

            return(builder);
        }
コード例 #2
0
 /// <summary>
 /// Add a command type to manifest.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="builder"></param>
 /// <returns></returns>
 public static ICommandLineModuleManifestBuilder AddCommand <T>(this ICommandLineModuleManifestBuilder builder) where T : ICommand => builder.AddCommand(typeof(T));