예제 #1
0
        private static Collection <CswNbtDataContractModule> _getModules(CswNbtResources NbtResources)
        {
            HashSet <string> seenModules = new HashSet <string>();
            Collection <CswNbtDataContractModule> ret = new Collection <CswNbtDataContractModule>();

            //This is the "root" module - this exists solely for rendering the tree
            CswNbtDataContractModule RootModule = new CswNbtDataContractModule
            {
                Name    = "Modules",
                Enabled = false     //this doesn't really matter because we don't show the root
            };

            ret.Add(RootModule);

            foreach (CswEnumNbtModuleName ModuleName in CswEnumNbtModuleName.All)
            {
                if (CswEnumNbtModuleName.Unknown != ModuleName && false == seenModules.Contains(ModuleName.ToString()) && false == NbtResources.Modules.ModuleHasPrereq(ModuleName))
                {
                    seenModules.Add(ModuleName.ToString());
                    CswNbtDataContractModule module = _getModuleData(NbtResources, ModuleName);
                    _recurse(NbtResources, module, seenModules);
                    if (false == NbtResources.Modules.ModuleIsHidden(ModuleName))
                    {
                        RootModule.ChildModules.Add(module);
                    }
                }
            }
            return(ret);
        }
예제 #2
0
        private static CswNbtDataContractModule _getModuleData(CswNbtResources NbtResources, CswEnumNbtModuleName Module)
        {
            bool isEnabled = NbtResources.Modules.IsModuleEnabled(Module);
            CswNbtDataContractModule module = new CswNbtDataContractModule()
            {
                Name    = Module.Value,
                Enabled = isEnabled
            };

            return(module);
        }
예제 #3
0
 private static void _recurse(CswNbtResources NbtResources, CswNbtDataContractModule Module, HashSet <string> seenModules)
 {
     foreach (CswEnumNbtModuleName childModule in NbtResources.Modules.GetChildModules(Module.Name))
     {
         CswNbtDataContractModule childModuleData = _getModuleData(NbtResources, childModule);
         seenModules.Add(childModule.Value);
         _recurse(NbtResources, childModuleData, seenModules);
         if (false == NbtResources.Modules.ModuleIsHidden(childModule))
         {
             Module.ChildModules.Add(childModuleData);
         }
     }
 }
예제 #4
0
        public static void HandleModule(ICswResources CswResources, CswNbtModulesPageReturn Return, CswNbtDataContractModule Module)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;

            CswEnumNbtModuleName ThisModule = Module.Name;

            if (Module.Enabled)
            {
                NbtResources.Modules.EnableModule(ThisModule);
            }
            else
            {
                NbtResources.Modules.DisableModule(ThisModule);
            }

            Return.Data.Modules = _getModules(NbtResources);
        }