예제 #1
0
 IServiceHost IServiceHostFactory.Create(IConfigService configService, IUtilityProvider utility)
 {
     var hostConfig = configService.Get<WCFSelfHostConfig>(ConfigGroup, ServiceName);
     int length = hostConfig.BaseAddresses.Length;
     Uri[] uris = new Uri[length];
     for (int init = 0; init < length; init++)
     {
         uris[init] = new Uri(hostConfig.BaseAddresses[init]);
     }
     return new WCFSelfHost(Type.GetType(hostConfig.Type), uris);
 }
예제 #2
0
        IServiceHost IServiceHostFactory.Create(IConfigService configService, IUtilityProvider utility)
        {
            var hostConfig = configService.Get <WCFSelfHostConfig>(ConfigGroup, ServiceName);
            int length     = hostConfig.BaseAddresses.Length;

            Uri[] uris = new Uri[length];
            for (int init = 0; init < length; init++)
            {
                uris[init] = new Uri(hostConfig.BaseAddresses[init]);
            }
            return(new WCFSelfHost(Type.GetType(hostConfig.Type), uris));
        }
예제 #3
0
        public static IResourceProvider Create(IUtilityProvider utilityProvider)
        {
            IResourceProvider resourceProvider = null;
            /*TODO - Need to find out the way to copy the config file on Post Build Process*/
            var map = new ExeConfigurationFileMap();
            map.ExeConfigFilename = AppDomain.CurrentDomain.BaseDirectory + @"bin\Controls.ResourceManager.dll.config";
            var config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);

            /*Provides what type of provider to be used to for Error Messages and Literals Persistance*/
            Type providerType = Type.GetType(config.AppSettings.Settings["DataProvider"].Value);           
            

            /*Provides what type of Resource provider to be used to keep the Error Messages and Literals*/
            Type resourceProviderType = Type.GetType(config.AppSettings.Settings["ResourceProvider"].Value);   

            if(resourceProviderType == typeof(FileResourceProvider))
            {
                string baseName = config.AppSettings.Settings["BaseResource"].Value;
                if (String.IsNullOrEmpty(baseName))
                {

                    utilityProvider.GetLogger().LogFatal("ResourceServiceFactory.Resource File", 9005);
                    throw new Exception("FileResourceProvider configuration missing");
                }

                Type assemblyType = Type.GetType(baseName);
                Assembly assembly = Assembly.GetAssembly(assemblyType);
                resourceProvider = (IResourceProvider)Activator.CreateInstance(resourceProviderType, assemblyType.FullName, assembly);
                if (resourceProvider == null)
                {
                    utilityProvider.GetLogger().LogFatal("ResourceServiceFactory.Resource Provider", 9002);
                }
            }
            else if (resourceProviderType == typeof(DBResourceProvider))
            {
                /*Reads the Connection String for the provider mentioned above.*/
                IDataProvider dataProvider = (IDataProvider)Activator.CreateInstance(providerType, String.Format(config.AppSettings.Settings["ConnectionString"].Value, AppDomain.CurrentDomain.BaseDirectory));
                if (dataProvider == null)
                {
                    utilityProvider.GetLogger().LogFatal("ResourceServiceFactory.Data Provider", 9003);
                }

                resourceProvider = (IResourceProvider)Activator.CreateInstance(resourceProviderType, dataProvider);
                if (resourceProvider == null)
                {
                    utilityProvider.GetLogger().LogFatal("ResourceServiceFactory.Resource Provider", 9004);
                }
            }
            return resourceProvider;
        }
예제 #4
0
        public static IResourceProvider Create(IUtilityProvider utilityProvider)
        {
            IResourceProvider resourceProvider = null;
            /*TODO - Need to find out the way to copy the config file on Post Build Process*/
            var map = new ExeConfigurationFileMap();

            map.ExeConfigFilename = AppDomain.CurrentDomain.BaseDirectory + @"bin\Controls.ResourceManager.dll.config";
            var config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);

            /*Provides what type of provider to be used to for Error Messages and Literals Persistance*/
            Type providerType = Type.GetType(config.AppSettings.Settings["DataProvider"].Value);


            /*Provides what type of Resource provider to be used to keep the Error Messages and Literals*/
            Type resourceProviderType = Type.GetType(config.AppSettings.Settings["ResourceProvider"].Value);

            if (resourceProviderType == typeof(FileResourceProvider))
            {
                string baseName = config.AppSettings.Settings["BaseResource"].Value;
                if (String.IsNullOrEmpty(baseName))
                {
                    utilityProvider.GetLogger().LogFatal("ResourceServiceFactory.Resource File", 9005);
                    throw new Exception("FileResourceProvider configuration missing");
                }

                Type     assemblyType = Type.GetType(baseName);
                Assembly assembly     = Assembly.GetAssembly(assemblyType);
                resourceProvider = (IResourceProvider)Activator.CreateInstance(resourceProviderType, assemblyType.FullName, assembly);
                if (resourceProvider == null)
                {
                    utilityProvider.GetLogger().LogFatal("ResourceServiceFactory.Resource Provider", 9002);
                }
            }
            else if (resourceProviderType == typeof(DBResourceProvider))
            {
                /*Reads the Connection String for the provider mentioned above.*/
                IDataProvider dataProvider = (IDataProvider)Activator.CreateInstance(providerType, String.Format(config.AppSettings.Settings["ConnectionString"].Value, AppDomain.CurrentDomain.BaseDirectory));
                if (dataProvider == null)
                {
                    utilityProvider.GetLogger().LogFatal("ResourceServiceFactory.Data Provider", 9003);
                }

                resourceProvider = (IResourceProvider)Activator.CreateInstance(resourceProviderType, dataProvider);
                if (resourceProvider == null)
                {
                    utilityProvider.GetLogger().LogFatal("ResourceServiceFactory.Resource Provider", 9004);
                }
            }
            return(resourceProvider);
        }
예제 #5
0
        public static void Register(IConfigService configService, IResourceService resourceService, IEncryptionService encryptionService, IAccessPolicyProvider accessPolicyProvider, IUtilityProvider utilityProvider, ISiteConfigProvider siteConfigProvider)
        {
            if (configService == null)
            {
                throw new Exception("Please provide a config service");
            }

            if (resourceService == null)
            {
                throw new Exception("Please provide a resource service");
            }

            if (encryptionService == null)
            {
                throw new Exception("Please provide a Encryption service");
            }

            if (accessPolicyProvider == null)
            {
                throw new Exception("Please provide a Access Policy Service Provider");
            }

            if (utilityProvider == null)
            {
                throw new Exception("Please provide a Utility Provider");
            }

            if (siteConfigProvider == null)
            {
                throw new Exception("Please provide a Site Specific Config Service");
            }

            ConfigService        = configService;
            ResourceService      = resourceService;
            EncryptionService    = encryptionService;
            AccessPolicyProvider = accessPolicyProvider;
            UtilityProvider      = utilityProvider;
            SiteConfigProvider   = siteConfigProvider;
            ControlConfigReader  = ConfigurationReader.Instance;
            PropertyConfigurator.Configure();
        }
예제 #6
0
        public static void Register(IConfigService configService, IResourceService resourceService, IEncryptionService encryptionService, IAccessPolicyProvider accessPolicyProvider, IUtilityProvider utilityProvider, ISiteConfigProvider siteConfigProvider)
        {
            if (configService == null)
            {
                throw new Exception("Please provide a config service");
            }

            if (resourceService == null)
            {
                throw new Exception("Please provide a resource service");
            }

            if (encryptionService == null)
            {
                throw new Exception("Please provide a Encryption service");
            }

            if (accessPolicyProvider == null)
            {
                throw new Exception("Please provide a Access Policy Service Provider");
            }

            if(utilityProvider == null)
            {
                throw new Exception("Please provide a Utility Provider");
            }

            if (siteConfigProvider == null)
            {
                throw new Exception("Please provide a Site Specific Config Service");
            }

            ConfigService = configService;
            ResourceService = resourceService;
            EncryptionService = encryptionService;
            AccessPolicyProvider = accessPolicyProvider;
            UtilityProvider = utilityProvider;
            SiteConfigProvider = siteConfigProvider;
            ControlConfigReader = ConfigurationReader.Instance;
            PropertyConfigurator.Configure();
        }
예제 #7
0
        public static void Configure(IConfigService configService, IUtilityProvider _utilityProvider, IResourceService _iResourceSerive)
        {
            utilityProvider  = _utilityProvider;
            iResourceService = _iResourceSerive;
            /*Call LoadCommandConfig Method to Load all the Command Configuration through ConfigService.*/
            IEnumerable <CommandConfig>       commands         = configService.Get <CommandConfig>("CommandTypeConfig");
            IEnumerable <CommandActionConfig> actionConfigList = configService.Get <CommandActionConfig>("CommandActionTypeConfig");

            foreach (CommandActionConfig actionConfig in actionConfigList)
            {
                ControllerCreateParams controllerConfig = new ControllerCreateParams();
                controllerConfig.Name            = actionConfig.ActionKey;
                controllerConfig.AllowAnonymous  = actionConfig.AllowAnonymous;
                controllerConfig.ExceptionPolicy = actionConfig.ExceptionPolicy;
                controllerConfig.TaskId          = actionConfig.TaskId;
                CommandConfig cmd = commands.Where <CommandConfig>(o => o.CommandKey == actionConfig.CommandConfig).FirstOrDefault();
                if (cmd != null)
                {
                    Type commandType = Type.GetType(cmd.CommandUri);
                    controllerConfig.CommandType = commandType;


                    if (commandType != null)
                    {
                        while (commandType.Name != typeof(ProcessCommand <,>).Name && commandType.Name != typeof(ParameterizedActionCommand <>).Name && commandType.Name != typeof(RequestCommand <>).Name && commandType.Name != typeof(ExecutorCommand).Name)
                        {
                            commandType = commandType.BaseType;
                        }

                        Type[] param = commandType.GetGenericArguments();

                        if (commandType.Name == typeof(ProcessCommand <,>).Name)
                        {
                            controllerConfig.RequestViewModel = param[0];
                            controllerConfig.ReponseViewModel = param[1];
                            controllerConfig.ControllerType   = typeof(Processor <, ,>).MakeGenericType(
                                new Type[] { controllerConfig.CommandType, controllerConfig.RequestViewModel, controllerConfig.ReponseViewModel });
                        }
                        else if (commandType.Name == typeof(ParameterizedActionCommand <>).Name)
                        {
                            controllerConfig.RequestViewModel = param[0];
                            controllerConfig.ControllerType   = typeof(ParamterizedExecutor <,>).MakeGenericType(
                                new Type[] { controllerConfig.CommandType, controllerConfig.RequestViewModel });
                        }
                        else if (commandType.Name == typeof(RequestCommand <>).Name)
                        {
                            controllerConfig.ReponseViewModel = param[0];
                            controllerConfig.ControllerType   = typeof(Requestor <,>).MakeGenericType(
                                new Type[] { controllerConfig.CommandType, controllerConfig.ReponseViewModel });
                        }
                        else if (commandType.Name == typeof(ExecutorCommand).Name)
                        {
                            controllerConfig.ControllerType = typeof(Executor <>).MakeGenericType(
                                new Type[] { controllerConfig.CommandType });
                        }


                        controllerConfig.DivId    = actionConfig.RefreshDiv;
                        controllerConfig.ViewName = actionConfig.ViewName;
                        ResultType result;
                        Enum.TryParse(actionConfig.ResultType, out result);
                        controllerConfig.ResultBuilder = result;
                        ControllerBag.Add(controllerConfig.Name, controllerConfig);
                    }
                    else
                    {
                        utilityProvider.GetLogger().LogFatal("Controller Configurator", 9000);
                    }
                }
                else
                {
                    utilityProvider.GetLogger().LogFatal("Controller Configurator", 9001);
                }
            }
        }
예제 #8
0
 public BaseController(IUtilityProvider utilityProvider)
 {
     _utilityProvider = utilityProvider;
 }
예제 #9
0
 public ContentsController(IUtilityProvider utilityProvider, ILogger <ContentsController> logger, IContentSectionProvider contentSectionProvider) : base(utilityProvider)
 {
     _contentSectionProvider = contentSectionProvider;
     _logger = logger;
 }
예제 #10
0
        public static void Configure(IConfigService configService, IUtilityProvider _utilityProvider, IResourceService _iResourceSerive)
        {
            utilityProvider = _utilityProvider;
            iResourceService = _iResourceSerive;
            /*Call LoadCommandConfig Method to Load all the Command Configuration through ConfigService.*/
            IEnumerable<CommandConfig> commands = configService.Get<CommandConfig>("CommandTypeConfig");
            IEnumerable<CommandActionConfig> actionConfigList = configService.Get<CommandActionConfig>("CommandActionTypeConfig");

            foreach (CommandActionConfig actionConfig in actionConfigList)
            {
                ControllerCreateParams controllerConfig = new ControllerCreateParams();
                controllerConfig.Name = actionConfig.ActionKey;
                controllerConfig.AllowAnonymous = actionConfig.AllowAnonymous;
                controllerConfig.ExceptionPolicy = actionConfig.ExceptionPolicy;
                controllerConfig.TaskId = actionConfig.TaskId;
                CommandConfig cmd = commands.Where<CommandConfig>(o => o.CommandKey == actionConfig.CommandConfig).FirstOrDefault();
                if (cmd != null)
                {
                    Type commandType = Type.GetType(cmd.CommandUri);
                    controllerConfig.CommandType = commandType;


                    if (commandType != null)
                    {
                        while (commandType.Name != typeof(ProcessCommand<,>).Name && commandType.Name != typeof(ParameterizedActionCommand<>).Name && commandType.Name != typeof(RequestCommand<>).Name && commandType.Name != typeof(ExecutorCommand).Name)
                        {
                            commandType = commandType.BaseType;
                        }

                        Type[] param = commandType.GetGenericArguments();

                        if (commandType.Name == typeof(ProcessCommand<,>).Name)
                        {
                            controllerConfig.RequestViewModel = param[0];
                            controllerConfig.ReponseViewModel = param[1];
                            controllerConfig.ControllerType = typeof(Processor<,,>).MakeGenericType(
                                new Type[] { controllerConfig.CommandType, controllerConfig.RequestViewModel, controllerConfig.ReponseViewModel });
                        }
                        else if (commandType.Name == typeof(ParameterizedActionCommand<>).Name)
                        {
                            controllerConfig.RequestViewModel = param[0];
                            controllerConfig.ControllerType = typeof(ParamterizedExecutor<,>).MakeGenericType(
                                new Type[] { controllerConfig.CommandType, controllerConfig.RequestViewModel });
                        }
                        else if (commandType.Name == typeof(RequestCommand<>).Name)
                        {
                            controllerConfig.ReponseViewModel = param[0];
                            controllerConfig.ControllerType = typeof(Requestor<,>).MakeGenericType(
                                new Type[] { controllerConfig.CommandType, controllerConfig.ReponseViewModel });
                        }
                        else if (commandType.Name == typeof(ExecutorCommand).Name)
                        {
                            controllerConfig.ControllerType = typeof(Executor<>).MakeGenericType(
                                new Type[] { controllerConfig.CommandType });
                        }


                        controllerConfig.DivId = actionConfig.RefreshDiv;
                        controllerConfig.ViewName = actionConfig.ViewName;
                        ResultType result;
                        Enum.TryParse(actionConfig.ResultType, out result);
                        controllerConfig.ResultBuilder = result;
                        ControllerBag.Add(controllerConfig.Name, controllerConfig);
                    }
                    else
                    {
                        utilityProvider.GetLogger().LogFatal("Controller Configurator", 9000);
                    }
                }
                else
                {
                    utilityProvider.GetLogger().LogFatal("Controller Configurator", 9001);
                }
            }
        }