private void OnModuleInitialized <TModuleType>(TModuleType module) where TModuleType : ModuleCore <TModuleType>
        {
            var controllerTypes = AppCore.GetBindedTypes <IModuleController <TModuleType> >();

            if (controllerTypes != null)
            {
                if (AppCore.AppDebugLevel >= DebugLevel.Detailed)
                {
                    Debug.WriteLine($"{nameof(ModuleControllerTypesManager)}.{nameof(OnModuleInitialized)}: найдены следующие типы контроллеров - '{string.Join("', '", controllerTypes)}'.");
                }

                var controllerTypesSplitIntoTypes = controllerTypes.
                                                    Select(x => new { Type = x, Attribute = x.GetCustomAttribute <ModuleControllerAttribute>() }).
                                                    Where(x => x.Attribute != null).
                                                    GroupBy(x => x.Attribute.ControllerTypeID, x => x.Type).
                                                    Select(x => new { ControllerTypeID = x.Key, ControllerType = x.Last() }).
                                                    ToList();

                _moduleControllerTypesList[module.QueryType] = controllerTypesSplitIntoTypes.ToDictionary(x => x.ControllerTypeID, x => x.ControllerType);
            }
            else
            {
                if (AppCore.AppDebugLevel >= DebugLevel.Detailed)
                {
                    Debug.WriteLine($"{nameof(ModuleControllerTypesManager)}.{nameof(OnModuleInitialized)}: не найдено ни одного типа контроллеров.");
                }

                _moduleControllerTypesList[module.QueryType] = new Dictionary <int, Type>();
            }
        }
Beispiel #2
0
        private void OnModuleInitialized <TModuleType>(TModuleType module) where TModuleType : ModuleCore <TModuleType>
        {
            var controllerTypes = AppCore.GetBindedTypes <IModuleController <TModuleType> >();

            if (controllerTypes != null)
            {
                var controllerTypesSplitIntoTypes = controllerTypes.
                                                    Select(x => new { Type = x, Attribute = x.GetCustomAttribute <ModuleControllerAttribute>() }).
                                                    Where(x => x.Attribute != null).
                                                    GroupBy(x => x.Attribute.ControllerTypeID, x => x.Type).
                                                    Select(x => new { ControllerTypeID = x.Key, ControllerType = x.Last() }).
                                                    ToList();

                _moduleControllerTypesList[module.QueryType] = controllerTypesSplitIntoTypes.ToDictionary(x => x.ControllerTypeID, x => x.ControllerType);
            }
            else
            {
                _moduleControllerTypesList[module.QueryType] = new Dictionary <int, Type>();
            }
        }