本文整理汇总了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);
}
示例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;
}
}
}
示例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;
}
示例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;
}
}
}