本文整理汇总了C#中Microsoft.Practices.EnterpriseLibrary.Configuration.Design.ConfigurationNode.AddNode方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigurationNode.AddNode方法的具体用法?C# ConfigurationNode.AddNode怎么用?C# ConfigurationNode.AddNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Practices.EnterpriseLibrary.Configuration.Design.ConfigurationNode
的用法示例。
在下文中一共展示了ConfigurationNode.AddNode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTraceListeners
private void AddTraceListeners(ConfigurationNode node, TraceSourceData data)
{
foreach (TraceListenerReferenceData refData in data.TraceListeners)
{
TraceListenerReferenceNode referenceNode = new TraceListenerReferenceNode(refData);
foreach(TraceListenerNode listenerNode in listeners.Nodes)
{
if (listenerNode.Name == referenceNode.Name)
{
referenceNode.ReferencedTraceListener = listenerNode;
}
}
node.AddNode(referenceNode);
}
}
示例2: CreateEncryptionNode
private void CreateEncryptionNode(ConfigurationNode storageNode, string storageEncryption)
{
if (string.IsNullOrEmpty(storageEncryption)) return;
StorageEncryptionProviderData encryptionProviderData = cacheManagerSettings.EncryptionProviders.Get(storageEncryption);
if (null == encryptionProviderData)
{
LogError(storageNode, string.Format(CultureInfo.CurrentUICulture, Resources.ExceptionNoEncrypitonProviderDefined, storageEncryption));
return;
}
ConfigurationNode encyrptionNode = NodeCreationService.CreateNodeByDataType(encryptionProviderData.GetType(), new object[] { encryptionProviderData });
if (null == encyrptionNode)
{
LogNodeMapError(storageNode, encryptionProviderData.GetType());
return;
}
storageNode.AddNode(encyrptionNode);
}
示例3: ExecuteCore
/// <summary>
/// <para>Creates an instance of the child node class and adds it as a child of the parent node. The node will be a <see cref="HashAlgorithmProviderNode"/>.</para>
/// </summary>
/// <param name="node">
/// <para>The parent node to add the newly created <see cref="AddChildNodeCommand.ChildNode"/>.</para>
/// </param>
protected override void ExecuteCore(ConfigurationNode node)
{
INodeNameCreationService service = ServiceHelper.GetNameCreationService(ServiceProvider);
Debug.Assert(service != null, "Could not find the INodeNameCreationService");
TypeSelectorUI selector = new TypeSelectorUI(
typeof(SHA1Managed),
typeof(HashAlgorithm),
TypeSelectorIncludes.None
);
DialogResult typeResult = selector.ShowDialog();
if (typeResult == DialogResult.OK)
{
Type selectedAlgorithmType = selector.SelectedType;
if (selector.SelectedType.IsSubclassOf(typeof(KeyedHashAlgorithm)))
{
CryptographicKeyWizard keyWizard = new CryptographicKeyWizard(new KeyedHashAlgorithmKeyCreator(selector.SelectedType));
DialogResult keyResult = keyWizard.ShowDialog();
if (keyResult == DialogResult.OK)
{
KeyedHashAlgorithmProviderNode providerNode = new KeyedHashAlgorithmProviderNode();
providerNode.Key = keyWizard.KeySettings;
providerNode.AlgorithmType = selector.SelectedType;
node.AddNode(providerNode);
providerNode.Name = service.GetUniqueName(selector.SelectedType.Name, providerNode, providerNode.Parent);
}
}
else
{
base.ExecuteCore(node);
HashAlgorithmProviderNode providerNode = (HashAlgorithmProviderNode)ChildNode;
providerNode.AlgorithmType = selectedAlgorithmType;
providerNode.Name = service.GetUniqueName(selector.SelectedType.Name, providerNode, providerNode.Parent);
}
}
}
示例4: ExecuteCore
protected override void ExecuteCore(ConfigurationNode node)
{
IUIService uiService = ServiceHelper.GetUIService(ServiceProvider);
using (OpenFileDialog fileDialog = new OpenFileDialog())
{
fileDialog.Filter = Resources.EnvironmentDeltaFileDialogFilter;
fileDialog.CheckFileExists = true;
fileDialog.CheckPathExists = true;
fileDialog.AddExtension = true;
fileDialog.DefaultExt = Resources.DefaultEnvironmentDeltaFileExtension;
fileDialog.RestoreDirectory = true;
if (DialogResult.OK == uiService.ShowOpenDialog(fileDialog))
{
uiService.BeginUpdate();
try
{
EnvironmentNodeBuilder nodeBuilder = new EnvironmentNodeBuilder(ServiceProvider);
EnvironmentNode childNode = nodeBuilder.Build(fileDialog.FileName, node.Hierarchy);
node.AddNode(childNode);
uiService.SetUIDirty(node.Hierarchy);
uiService.ActivateNode(childNode);
}
catch (Exception e)
{
uiService.ShowError(e, Resources.ErrorOpeningEnvironmentMergeFile);
}
finally
{
uiService.EndUpdate();
}
}
}
}
示例5: ExecuteCore
/// <summary>
/// Creates an instance of the child node class and adds it as a child of the parent node.
/// </summary>
/// <param name="node">
/// The parent node to add the newly created <see cref="ChildNode"/>.
/// </param>
protected override void ExecuteCore(ConfigurationNode node)
{
try
{
UIService.BeginUpdate();
childNode = CreateChild();
node.AddNode(childNode);
UIService.SetUIDirty(node.Hierarchy);
UIService.ActivateNode(childNode);
}
finally
{
UIService.EndUpdate();
}
}
示例6: ExecuteCore
/// <summary>
/// Adds either a <see cref="FieldNode"/>, <see cref="MethodNode"/> or <see cref="PropertyNode"/> to the current <see cref="RuleSetNode"/>,
/// based on the selected member.
/// </summary>
/// <param name="node">The parent node to newly added configuration node.</param>
protected override void ExecuteCore(ConfigurationNode node)
{
try
{
UIService.BeginUpdate();
Type type = FindType(node);
if (type != null)
{
IUIService uiService = ServiceHelper.GetUIService(serviceProvider);
TypeMemberChooser memberChooser = new TypeMemberChooser(uiService);
foreach (MemberInfo memberInfo in memberChooser.ChooseMembers(type))
{
if (memberInfo != null)
{
if (node.Nodes.Contains(memberInfo.Name)) continue;
ConfigurationNode childNode = null;
if (memberInfo is PropertyInfo)
{
childNode = new PropertyNode(memberInfo.Name);
}
else if (memberInfo is MethodInfo)
{
childNode = new MethodNode(memberInfo.Name);
}
else if (memberInfo is FieldInfo)
{
childNode = new FieldNode(memberInfo.Name);
}
else
{
Debug.Assert(false, "memberInfo should be either PropertyInfo, MethodInfo or FieldInfo");
}
node.AddNode(childNode);
UIService.SetUIDirty(node.Hierarchy);
}
}
}
}
finally
{
UIService.EndUpdate();
}
}