コード例 #1
0
        private static void LoadSynClientConfig(IEnumerable <XElement> excludedTypes, IEnumerable <XElement> synTypes)
        {
            SynClientConfig config;

            foreach (XElement el in excludedTypes)
            {
                try
                {
                    string name = el.Attribute("name").Value;
                    if (string.IsNullOrEmpty(name))
                    {
                        LogProxy.Warn(SYNCLIENTTYPENAMEISNULL);
                        continue;
                    }

                    if (MySynClientConfig.ContainsKey(name))
                    {
                        continue;
                    }

                    config = new SynClientConfig(name, true, false);
                    MySynClientConfig[name] = config;
                }
                catch (Exception ex)
                {
                    LogProxy.Error(ex, false);
                }
            }

            foreach (XElement el in synTypes)
            {
                try
                {
                    string name = el.Attribute("name").Value;
                    if (string.IsNullOrEmpty(name))
                    {
                        LogProxy.Warn(SYNCLIENTTYPENAMEISNULL);
                        continue;
                    }

                    if (MySynClientConfig.ContainsKey(name))
                    {
                        continue;
                    }

                    bool isLazy = false;
                    if (el.Attribute("islazy") != null)
                    {
                        bool.TryParse(el.Attribute("islazy").Value.Trim(), out isLazy);
                    }

                    config = new SynClientConfig(name, false, isLazy);
                    MySynClientConfig[name] = config;
                }
                catch (Exception ex)
                {
                    LogProxy.Error(ex, false);
                }
            }
        }
コード例 #2
0
        private static bool IsBan(string typeName)
        {
            SynClientConfig config = SynClientConfig.Get(typeName);

            if (config == null)
            {
                return(false);
            }
            return(config.IsBan);
        }
コード例 #3
0
        public bool IsLazy <T>()
        {
            SynClientConfig config = SynClientConfig.Get <T>();

            if (config == null)
            {
                return(false);
            }
            return(config.IsLazy);
        }
コード例 #4
0
        private static void SynClientServiceInit()
        {
            SynClientCommConfig.Init();
            SynClientConfig.Init();

            ServerURI = SynClientCommConfig.ServerURI;

            if (SynClientCommConfig.PostDueTime > 0)
            {
                PostDueTime = SynClientCommConfig.PostDueTime * 1000;
            }

            if (SynClientCommConfig.PostPeriod > 0)
            {
                PostPeriod = SynClientCommConfig.PostPeriod;
            }

            if (SynClientCommConfig.GetDueTime > 0)
            {
                GetDueTime = SynClientCommConfig.GetDueTime * 1000;
            }

            if (SynClientCommConfig.GetPeriod > 0)
            {
                GetPeriod = SynClientCommConfig.GetPeriod;
            }

            if (SynClientCommConfig.PostTryInterval > 0)
            {
                PostTryInterval = SynClientCommConfig.PostTryInterval;
            }

            if (SynClientCommConfig.PostTryMultiple > 0)
            {
                PostTryMultiple = SynClientCommConfig.PostTryMultiple;
            }

            if (SynClientCommConfig.PostTrys > 0)
            {
                PostTrys = SynClientCommConfig.PostTrys;
            }

            if (SynClientCommConfig.ClearInterval > 0)
            {
                ClearInterval = SynClientCommConfig.ClearInterval * 1000;
            }

            SynServerService = (ISynServerService)Activator.GetObject(typeof(ISynServerService), ServerURI);

            TimerCallback callback;

            callback  = new TimerCallback(PostCallbackMethod);
            PostTimer = new Timer(callback, null, PostDueTime, PostPeriod);

            CurrentIndex   = SynServerService.CurrentIndex;
            SynServerAppId = SynServerService.CurrentAppId;
            LogProxy.InfoFormat(SERVERNOTE, SynServerAppId, CurrentIndex);

            callback = new TimerCallback(GetCallbackMethod);
            GetTimer = new Timer(callback, null, GetDueTime, GetPeriod);

            Thread t = new Thread(SynClearThreadMethod);

            t.Start();
        }