Exemplo n.º 1
0
        private static WcfSetting GetWcfSetting(Type type)
        {
            WcfSetting setting = null;

            try
            {
                if (type.IsInterface)
                {
                    using (var client = WcfServiceClientFactory.CreateServiceClient <IWcfConfigService>())
                    {
                        setting = client.Channel.GetClientSetting(type.FullName, CommonConfiguration.MachineIP);
                    }
                }
                else
                {
                    using (var client = WcfServiceClientFactory.CreateServiceClient <IWcfConfigService>())
                    {
                        setting = client.Channel.GetServerSetting(type.FullName, CommonConfiguration.MachineIP);
                    }
                }
            }
            catch (Exception ex)
            {
                ex.Handle(WcfLogProvider.ModuleName, "WcfSettingManager", "GetWcfSetting");
            }
            return(setting);
        }
Exemplo n.º 2
0
        private static WcfSetting Current(Type type)
        {
            WcfSetting setting = null;

            if (!wcfSettings.ContainsKey(type))
            {
                AppInfoCenterService.LoggingService.Warning(WcfLogProvider.ModuleName, "WcfSettingManager", "Current",
                                                            string.Format("WcfSettingManager.Current 没有获取到 {0} 的配置", type.FullName));
                Init(type);

                if (type.IsInterface)
                {
                    setting = new WcfClientSetting
                    {
                        WcfCoreSetting = new WcfClientCoreSetting
                        {
                        },
                        WcfPerformanceServiceSetting = new WcfPerformanceServiceSetting
                        {
                            Enabled = true,
                            ReportStateIntervalMilliSeconds = 10000,
                            AllowMethods = new List <string> {
                                "*"
                            },
                            DenyMethods = new List <string>(),
                        },
                        WcfLogSetting = new WcfLogSetting
                        {
                            Enabled = true,
                            ExceptionInfoSetting = new ExceptionInfoSetting
                            {
                                Enabled = false,
                            },
                            InvokeInfoSetting = new InvokeInfoSetting
                            {
                                Enabled = false,
                            },
                            StartInfoSetting = new StartInfoSetting
                            {
                                Enabled = true,
                            },
                            MessageInfoSetting = new MessageInfoSetting
                            {
                                Enabled = false,
                            }
                        },
                        WcfSecuritySetting = new WcfSecuritySetting
                        {
                            PasswordCheck = new PasswordCheck
                            {
                                Enable = false,
                            }
                        }
                    };
                }
                else
                {
                    setting = new WcfServerSetting
                    {
                        WcfCoreSetting = new WcfServerCoreSetting
                        {
                            EnableUnity = true,
                        },
                        WcfPerformanceServiceSetting = new WcfPerformanceServiceSetting
                        {
                            Enabled = true,
                            ReportStateIntervalMilliSeconds = 10000,
                            AllowMethods = new List <string> {
                                "*"
                            },
                            DenyMethods = new List <string>(),
                        },
                        WcfLogSetting = new WcfLogSetting
                        {
                            Enabled = true,
                            ExceptionInfoSetting = new ExceptionInfoSetting
                            {
                                Enabled = true,
                            },
                            InvokeInfoSetting = new InvokeInfoSetting
                            {
                                Enabled = false,
                            },
                            StartInfoSetting = new StartInfoSetting
                            {
                                Enabled = true,
                            },
                            MessageInfoSetting = new MessageInfoSetting
                            {
                                Enabled = false,
                            }
                        },
                        WcfSecuritySetting = new WcfSecuritySetting
                        {
                            PasswordCheck = new PasswordCheck
                            {
                                Enable = false,
                            }
                        }
                    };
                }
            }
            else
            {
                setting = wcfSettings[type] as WcfSetting;
            }
            return(setting);
        }