コード例 #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
ファイル: WCFSelfHostFactory.cs プロジェクト: kriznaraj/Code
        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);
                }
            }
        }