protected override void ExecuteCore(ConfigurationNode node) { TypeSelectorUI selector = new TypeSelectorUI( typeof(RijndaelManaged), typeof(SymmetricAlgorithm), TypeSelectorIncludeFlags.Default ); DialogResult typeResult = selector.ShowDialog(); if (typeResult == DialogResult.OK) { KeySettings keySettings = new KeySettings(new SymmetricAlgorithmKeyCreator(selector.SelectedType.AssemblyQualifiedName)); KeyManagerEditorUI keyManager = new KeyManagerEditorUI(keySettings); DialogResult keyResult = keyManager.ShowDialog(); if (keyResult == DialogResult.OK) { INodeNameCreationService service = GetService(typeof(INodeNameCreationService)) as INodeNameCreationService; Debug.Assert(service != null, "Could not find the INodeNameCreationService"); base.ExecuteCore(node); SymmetricAlgorithmProviderNode providerNode = (SymmetricAlgorithmProviderNode)ChildNode; providerNode.AlgorithmType = selector.SelectedType.AssemblyQualifiedName; providerNode.Name = service.GetUniqueDisplayName(providerNode.Parent, selector.SelectedType.Name); providerNode.Key = keyManager.KeySettings; } } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { Debug.Assert(provider != null, "No service provider; we cannot edit the value"); if (provider != null) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); Debug.Assert(edSvc != null, "No editor service; we cannot edit the value"); if (edSvc != null) { IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); string expression = (string)value; ConfigurationNode node = (ConfigurationNode)context.Instance; formUI.Expression = expression; formUI.RuleName = node.Name; DialogResult result = service.ShowDialog(formUI); if (result == DialogResult.OK) { expression = formUI.Expression; if (node.Name != formUI.RuleName) { INodeNameCreationService nameCreationService = node.Site.GetService(typeof(INodeNameCreationService)) as INodeNameCreationService; node.Name = nameCreationService.GetUniqueDisplayName(node, formUI.RuleName); } } return(expression); } } return(value); }
private void SetSiteName(string originalDisplayName, ConfigurationNode configurationNode) { INodeNameCreationService nodeNameCreationService = GetService(typeof(INodeNameCreationService)) as INodeNameCreationService; Debug.Assert(nodeNameCreationService != null, "The INodeNameCreationService needs to be implemented."); Debug.Assert(configurationNode.Site != null, "The Site was expeted not to be null"); //configurationNode.Site.Name = nodeNameCreationService.GetUniqueDisplayName(configurationNode.Parent, originalDisplayName); string name = nodeNameCreationService.GetUniqueDisplayName(configurationNode.Parent, originalDisplayName); configurationNode.Rename(name, DefaultNodeRename.ForceRename); }