Example #1
0
        public void SetConfigurationStateChangeEventHandler(object key, ChoConfigurationStateChangedEventHandler configurationStateChanged)
        {
            ChoGuard.ArgumentNotNull(key, "key");
            ChoGuard.ArgumentNotNull(configurationStateChanged, "configurationStateChanged");

            _eventHandlerList.AddOrUpdate(key, configurationStateChanged);
        }
        public static T Register <T>()
        {
            using (ChoCoreFrxConfigurationManager <T> coreFrxConfigurationManager = new ChoCoreFrxConfigurationManager <T>())
            {
                T instance = coreFrxConfigurationManager.ConfigObject;

                if (instance is IChoObjectChangeWatcheable)
                {
                    if (!ChoAppFrxSettings.Me.DisableFrxConfig)
                    {
                        ChoConfigurationChangeFileWatcher fileWatcher = null;
                        fileWatcher = new ChoConfigurationChangeFileWatcher("{0}_FileWatcher".FormatString(typeof(T).Name), coreFrxConfigurationManager.ConfigFilePath);
                        fileWatcher.DoNotUseGlobalQueue = true;
                        fileWatcher.SetConfigurationChangedEventHandler("{0}_FileWatcher".FormatString(typeof(T).Name), (sender1, e1) =>
                        {
                            using (ChoCoreFrxConfigurationManager <T> coreFrxConfigurationManager1 = new ChoCoreFrxConfigurationManager <T>())
                            {
                                T instance1 = coreFrxConfigurationManager1.ConfigObject;
                                if (instance1 is IChoObjectChangeWatcheable)
                                {
                                    ((IChoObjectChangeWatcheable)instance1).OnObjectChanged(instance1, null);
                                }
                            }
                        });

                        _dictService.AddOrUpdate(typeof(T), fileWatcher);

                        ChoEnvironmentSettings.SetEnvironmentChangedEventHandlerNoCall(typeof(T).Name, ((sender, e) =>
                        {
                            using (ChoCoreFrxConfigurationManager <T> coreFrxConfigurationManager1 = new ChoCoreFrxConfigurationManager <T>())
                            {
                                T instance1 = coreFrxConfigurationManager1.ConfigObject;
                                if (instance1 is IChoObjectChangeWatcheable)
                                {
                                    ((IChoObjectChangeWatcheable)instance1).OnObjectChanged(instance1, null);
                                }
                            }
                        }));

                        if (fileWatcher != null)
                        {
                            fileWatcher.StartWatching();
                        }
                    }
                }

                return(instance);
            }
        }
Example #3
0
        private static void Register(string name, IChoProfile profile, bool force)
        {
            string              typeProfileName = null;
            MemberInfo          memberInfo      = null;
            ChoProfileAttribute memberAttribute = null;
            ChoProfileAttribute typeAttribute   = null;

            string profileName = GetProfileName(name, out memberInfo, out typeProfileName, out memberAttribute, out typeAttribute);

            if (force)
            {
                MemberProfileCache.AddOrUpdate(profileName, profile);
            }
            else
            {
                MemberProfileCache.GetOrAdd(profileName, profile);
            }
        }