public static ChoConfigurationMetaDataState Register(string configSectionName, string metaDataFileName)
        {
            ChoGuard.ArgumentNotNullOrEmpty(configSectionName, "ConfigSectionName");
            ChoGuard.ArgumentNotNullOrEmpty(metaDataFileName, "MetaDataFileName");

            lock (_configMetaData.SyncRoot)
            {
                if (_configMetaData.ContainsKey(configSectionName))
                {
                    _configMetaData.Remove(configSectionName);
                }

                ChoConfigurationMetaDataState configurationMetaDataState = new ChoConfigurationMetaDataState();
                _configMetaData.Add(configSectionName, configurationMetaDataState);

                configurationMetaDataState.ConfigSectionName        = configSectionName;
                configurationMetaDataState.MetaDataFileName         = metaDataFileName;
                configurationMetaDataState.FileWatcher              = new ChoFileWatcher(metaDataFileName);
                configurationMetaDataState.FileWatcher.FileChanged += (target, e) => configurationMetaDataState.OnConfigurationMetaDataChanged();

                configurationMetaDataState.FileWatcher.StartWatching();

                return(configurationMetaDataState);
            }
        }
예제 #2
0
        public static void UnregisterMe(Type type)
        {
            ChoGuard.ArgumentNotNull(type, "Type");

            if (!_onDomainUnloadHandlers.ContainsKey(type))
            {
                return;
            }
            _onDomainUnloadHandlers.Remove(type);
        }
예제 #3
0
        public static ChoIniDocument GetDocument(string filePath)
        {
            lock (_iniDocuments.SyncRoot)
            {
                if (IsModified(filePath) && _iniDocuments.ContainsKey(filePath))
                {
                    _iniDocuments.Remove(filePath);
                }

                return(LoadDocument(filePath));
            }
        }
예제 #4
0
        public bool Remove(string name)
        {
            ChoGuard.ArgumentNotNullOrEmpty(name, "Name");
            lock (_padLock)
            {
                if (!_propertyReplacers.ContainsKey(name))
                {
                    return(false);
                }

                _propertyReplacers.Remove(name);
                return(true);
            }
        }
예제 #5
0
        private void _Remove(IChoProfile profile)
        {
            if (!_childProfiles.ContainsKey(profile.ProfilerName))
            {
                return;
            }

            if (_childProfiles[profile.ProfilerName] is IDisposable)
            {
                ((IDisposable)_childProfiles[profile.ProfilerName]).Dispose();
            }

            _childProfiles.Remove(profile.ProfilerName);
        }
예제 #6
0
        private static void Adjust <T>(string logFileName, ChoDictionary <string, T> objDictionary,
                                       ChoObjTypeConfigurable[] objTypeConfigurables, ChoDefaultObjectKey typeName) where T : class
        {
            if (objTypeConfigurables != null && objTypeConfigurables.Length > 0)
            {
                foreach (ChoObjTypeConfigurable objTypeConfigurable in objTypeConfigurables)
                {
                    if (objTypeConfigurable == null)
                    {
                        continue;
                    }
                    try
                    {
                        string key = objTypeConfigurable.Name;

                        T obj = default(T);
                        if (!String.IsNullOrEmpty(objTypeConfigurable.Type))
                        {
                            obj = ChoObjectManagementFactory.CreateInstance(objTypeConfigurable.Type) as T;
                            if (obj == null)
                            {
                                ChoStreamProfile.WriteLine(ChoLogDirectories.Settings, Path.ChangeExtension(logFileName, ChoExt.Err),
                                                           String.Format("Failed to create {0} object.", objTypeConfigurable.Type));
                            }
                        }

                        if (obj != null)
                        {
                            key = ChoObjectNameableAttribute.GetName(obj.GetType(), typeName);
                        }

                        if (objTypeConfigurable.Action == Action.Remove &&
                            objDictionary.ContainsKey(key))
                        {
                            objDictionary.Remove(key);
                        }
                        else if (!objDictionary.ContainsKey(key) && obj != null)
                        {
                            objDictionary.Add(key, obj);
                        }
                    }
                    catch (Exception ex)
                    {
                        ChoStreamProfile.WriteLine(ChoLogDirectories.Settings, Path.ChangeExtension(logFileName, ChoExt.Err),
                                                   String.Format("Failed to create {0} object. {1}", objTypeConfigurable.Type, ex.Message));
                    }
                }
            }
        }
예제 #7
0
        private void AddToMap(ChoDictionary <string, string> typeShortNameMap, ChoBufferProfileEx errProfile, Type type, string typeShortName, bool overrideType)
        {
            if (typeShortNameMap.ContainsKey(typeShortName))
            {
                if (!overrideType)
                {
                    errProfile.AppendLine(String.Format("Type: {0}, ShortName: {1}", type.SimpleQualifiedName(), typeShortName));
                    return;
                }
                else
                {
                    ChoTrace.Debug(String.Format("DELETED: Type: {0}, ShortName: {1}", typeShortNameMap[typeShortName], typeShortName));
                    typeShortNameMap.Remove(typeShortName);
                }
            }

            typeShortNameMap.Add(typeShortName, type.SimpleQualifiedName());

            ChoTrace.Debug(String.Format("ADDED: Type: {0}, ShortName: {1}", type.SimpleQualifiedName(), typeShortName));
        }