Esempio n. 1
0
        private Module LoadInternal(object moduleInstance, ModuleAttribute moduleAttr, TypeInfo typeInfo, IDependencyMap dependencyMap)
        {
            if (_modules.ContainsKey(moduleInstance.GetType()))
            {
                return(_modules[moduleInstance.GetType()]);
            }

            var loadedModule = new Module(typeInfo, this, moduleInstance, moduleAttr, dependencyMap);

            _modules[moduleInstance.GetType()] = loadedModule;

            foreach (var cmd in loadedModule.Commands)
            {
                _map.AddCommand(cmd);
            }

            return(loadedModule);
        }
Esempio n. 2
0
        internal Module(TypeInfo source, CommandService service, object instance, ModuleAttribute moduleAttr, IDependencyMap dependencyMap)
        {
            Source   = source;
            Service  = service;
            Name     = source.Name;
            Prefix   = moduleAttr.Prefix ?? "";
            Instance = instance;

            var nameAttr = source.GetCustomAttribute <NameAttribute>();

            if (nameAttr != null)
            {
                Name = nameAttr.Text;
            }

            var summaryAttr = source.GetCustomAttribute <SummaryAttribute>();

            if (summaryAttr != null)
            {
                Summary = summaryAttr.Text;
            }

            var remarksAttr = source.GetCustomAttribute <RemarksAttribute>();

            if (remarksAttr != null)
            {
                Remarks = remarksAttr.Text;
            }

            List <Command> commands = new List <Command>();

            SearchClass(source, instance, commands, Prefix, dependencyMap, moduleAttr.AppendSpace);
            Commands = commands;

            Preconditions = BuildPreconditions();
        }