コード例 #1
0
        public static ESBConfig ReadConfig()
        {
            if (_esbConfig != null)
            {
                return(_esbConfig);
            }
            if (!File.Exists(configfile))
            {
                string configfile2 = AppDomain.CurrentDomain.BaseDirectory + "ESBConfig.xml";
                if (!File.Exists(configfile2))
                {
                    throw new Exception(string.Format("未找到ESBConfig配置文件,路径:{0} 和路径 {1}", configfile, configfile2));
                }
                else
                {
                    configfile = configfile2;
                }
            }


            _esbConfig = SerializerHelper.DeSerializerFile <ESBConfig>(configfile, true);
            if (_esbConfig.ESBServer.IndexOf('.') == -1 &&
                _esbConfig.ESBServer.IndexOf(':') == -1)
            {
                var ipaddress = System.Net.Dns.GetHostAddresses(_esbConfig.ESBServer);
                if (ipaddress == null)
                {
                    throw new Exception("配置服务地址无效。");
                }

                _esbConfig.ESBServer = ipaddress.FirstOrDefault(p => p.AddressFamily != AddressFamily.InterNetworkV6).ToString();
            }

            return(_esbConfig);
        }
コード例 #2
0
        public static void WriteConfig(string esbServer, int esbPort, bool autoStrat = false)
        {
            ESBConfig config = new ESBConfig();

            config.ESBServer = esbServer;
            config.ESBPort   = esbPort;
            config.AutoStart = autoStrat;
            SerializerHelper.SerializerToXML(config, configfile);
        }
コード例 #3
0
        public ESBService(int sNo, bool supportTcpServiceRidrect = false, bool supportUdpServiceRedirect = false)
            : base(ESBConfig.ReadConfig().ESBServer, ESBConfig.ReadConfig().ESBPort, false)
        {
            this.ServiceNo      = sNo;
            this.BeferLogout   += this.UnRegisterService;
            this.OnClientReset += ESBService_OnClientReset;

            this.SupportTcpServiceRidrect  = supportTcpServiceRidrect;
            this.SupportUDPServiceRedirect = supportUdpServiceRedirect;
        }
コード例 #4
0
 internal ESBClient()
     : base(ESBConfig.ReadConfig().ESBServer, ESBConfig.ReadConfig().ESBPort, ESBConfig.ReadConfig().IsSecurity, ESBConfig.ReadConfig().AutoStart)
 {
 }