当前位置: 首页>>代码示例>>C#>>正文


C# StringDictionary.ReplaceHashtable方法代码示例

本文整理汇总了C#中System.Collections.Specialized.StringDictionary.ReplaceHashtable方法的典型用法代码示例。如果您正苦于以下问题:C# StringDictionary.ReplaceHashtable方法的具体用法?C# StringDictionary.ReplaceHashtable怎么用?C# StringDictionary.ReplaceHashtable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.Specialized.StringDictionary的用法示例。


在下文中一共展示了StringDictionary.ReplaceHashtable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetAttributes

        internal void SetAttributes(Hashtable attribs) {
            TraceUtils.VerifyAttributes(attribs, GetSupportedAttributes(), this);

            attributes = new StringDictionary();
            attributes.ReplaceHashtable(attribs);
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:6,代码来源:TraceListener.cs

示例2: Initialize

        private void Initialize() {
            if (!_initCalled) {
                lock(this) {
                    if (_initCalled)
                        return;
                    
                    SourceElementsCollection sourceElements = DiagnosticsConfiguration.Sources;
    
                    if (sourceElements != null) {
                        SourceElement sourceElement = sourceElements[sourceName];
                        if (sourceElement != null) {
                            if (!String.IsNullOrEmpty(sourceElement.SwitchName)) {
                                CreateSwitch(sourceElement.SwitchType, sourceElement.SwitchName);
                            }
                            else {
                                CreateSwitch(sourceElement.SwitchType, sourceName);
    
                                if (!String.IsNullOrEmpty(sourceElement.SwitchValue)) 
                                    internalSwitch.Level = (SourceLevels) Enum.Parse(typeof(SourceLevels), sourceElement.SwitchValue);
                            }

                            listeners = sourceElement.Listeners.GetRuntimeObject();
    
                            attributes = new StringDictionary();
                            TraceUtils.VerifyAttributes(sourceElement.Attributes, GetSupportedAttributes(), this);
                            attributes.ReplaceHashtable(sourceElement.Attributes);
                        }
                        else
                            NoConfigInit();
                    }
                    else
                        NoConfigInit();
    
                    _initCalled = true;
                }
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:37,代码来源:TraceSource.cs

示例3: InitializeWithStatus

        private bool InitializeWithStatus() {
            if (!initialized) {

                lock (IntializedLock) {

                    if (initialized || initializing) {
                        return false;
                    }

                    // This method is re-entrent during intitialization, since calls to OnValueChanged() in subclasses could end up having InitializeWithStatus()
                    // called again, we don't want to get caught in an infinite loop.
                    initializing = true;

                    if (switchSettings == null) {
                        if (!InitializeConfigSettings()) {
                            initialized = true;
                            initializing = false;
                            return false;
                        }
                    }

                    if (switchSettings != null) {
                        SwitchElement mySettings = switchSettings[displayName];
                        if (mySettings != null) {
                            string value = mySettings.Value;
                            if (value != null) {
                                this.Value = value;
                            } else
                                this.Value = defaultValue;

                            try {
                                TraceUtils.VerifyAttributes(mySettings.Attributes, GetSupportedAttributes(), this);
                            } catch (ConfigurationException) {
                                // if VerifyAttributes throws, clean up a little bit so we're not in a bad state. 
                                initialized = false;
                                initializing = false;
                                throw;
                            }

                            attributes = new StringDictionary();
                            attributes.ReplaceHashtable(mySettings.Attributes);
                        } else {
                            // We don't use the property here because we don't want to catch exceptions 
                            // and rethrow them as ConfigurationException.  In this case there's no config. 
                            switchValueString = defaultValue;
                            OnValueChanged();
                        }
                    } else {
                        // We don't use the property here because we don't want to catch exceptions 
                        // and rethrow them as ConfigurationException.  In this case there's no config. 
                        switchValueString = defaultValue;
                        OnValueChanged();
                    }

                    initialized = true;
                    initializing = false;
                }
            }

            return true;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:61,代码来源:Switch.cs

示例4: Refresh

        internal void Refresh() {
            if (!_initCalled) {
                Initialize();
                return;
            }

            SourceElementsCollection sources = DiagnosticsConfiguration.Sources;

            if (sources != null) {
                SourceElement sourceElement = sources[Name];
                if (sourceElement != null) {

                    // first check if the type changed
                    if ((String.IsNullOrEmpty(sourceElement.SwitchType) && internalSwitch.GetType() != typeof(SourceSwitch)) ||
                         (sourceElement.SwitchType != internalSwitch.GetType().AssemblyQualifiedName)) {

                        if (!String.IsNullOrEmpty(sourceElement.SwitchName)) {
                            CreateSwitch(sourceElement.SwitchType, sourceElement.SwitchName);
                        }
                        else {
                            CreateSwitch(sourceElement.SwitchType, Name);
                        
                            if (!String.IsNullOrEmpty(sourceElement.SwitchValue)) 
                                internalSwitch.Level = (SourceLevels) Enum.Parse(typeof(SourceLevels), sourceElement.SwitchValue);
                        }
                    }
                    else if (!String.IsNullOrEmpty(sourceElement.SwitchName)) {
                        // create a new switch if the name changed, otherwise just refresh. 
                        if (sourceElement.SwitchName != internalSwitch.DisplayName)
                            CreateSwitch(sourceElement.SwitchType, sourceElement.SwitchName);
                        else
                            internalSwitch.Refresh();
                    }
                    else {
                        // the switchValue changed.  Just update our internalSwitch. 
                        if (!String.IsNullOrEmpty(sourceElement.SwitchValue)) 
                            internalSwitch.Level = (SourceLevels) Enum.Parse(typeof(SourceLevels), sourceElement.SwitchValue);
                        else
                            internalSwitch.Level = SourceLevels.Off;
                    }

                    TraceListenerCollection newListenerCollection = new TraceListenerCollection();
                    foreach (ListenerElement listenerElement in sourceElement.Listeners) {
                        TraceListener listener = listeners[listenerElement.Name];
                        if (listener != null) {
                            newListenerCollection.Add(listenerElement.RefreshRuntimeObject(listener));
                        }
                        else {
                            newListenerCollection.Add(listenerElement.GetRuntimeObject());
                        }
                    }

                    TraceUtils.VerifyAttributes(sourceElement.Attributes, GetSupportedAttributes(), this);

                    attributes  = new StringDictionary();
                    attributes.ReplaceHashtable(sourceElement.Attributes);

                    listeners = newListenerCollection;
                }
                else {
                    // there was no config, so clear whatever we have.  
                    internalSwitch.Level = switchLevel;
                    listeners.Clear();
                    attributes = null;
                }
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:67,代码来源:TraceSource.cs


注:本文中的System.Collections.Specialized.StringDictionary.ReplaceHashtable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。