예제 #1
0
        public CommandInfo(CommandInfo?parent, ConfiguredCommand prototype)
        {
            Parent = parent;

            Name             = prototype.Name;
            Aliases          = new HashSet <string>(prototype.Aliases);
            Description      = prototype.Description;
            Data             = prototype.Data;
            CommandType      = prototype.CommandType;
            SettingsType     = prototype.SettingsType;
            Delegate         = prototype.Delegate;
            IsDefaultCommand = prototype.IsDefaultCommand;
            IsHidden         = prototype.IsHidden;

            Children   = new List <CommandInfo>();
            Parameters = new List <CommandParameter>();
            Examples   = prototype.Examples ?? new List <string[]>();

            if (CommandType != null && string.IsNullOrWhiteSpace(Description))
            {
                var description = CommandType.GetCustomAttribute <DescriptionAttribute>();
                if (description != null)
                {
                    Description = description.Description;
                }
            }
        }
예제 #2
0
        public static void Setup()
        {
            Logger = BetterEditor.Logger;

            StoredCommands.Clear();
            IEnumerable <Type> CommandTypes = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.GetCustomAttribute <CommandInfo>() != null);

            foreach (Type CommandType in CommandTypes)
            {
                string CommandId = CommandType.GetCustomAttribute <CommandInfo>().Id;

                StoredCommands.Add(CommandId, (BECommand)CommandType.GetConstructors().First().Invoke(null, null));
            }
        }
예제 #3
0
        public CommandInfo(CommandInfo parent, ConfiguredCommand prototype)
        {
            Parent = parent;

            Name             = prototype.Name;
            Description      = prototype.Description;
            CommandType      = prototype.CommandType;
            SettingsType     = prototype.SettingsType;
            IsDefaultCommand = prototype.IsDefaultCommand;

            Children   = new List <CommandInfo>();
            Parameters = new List <CommandParameter>();
            Examples   = prototype.Examples ?? new List <string[]>();

            if (!IsBranch)
            {
                var description = CommandType.GetCustomAttribute <DescriptionAttribute>();
                if (description != null)
                {
                    Description = description.Description;
                }
            }
        }