/// <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="SymmetricAlgorithmProviderNode"/>.</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) { TypeSelectorUI selector = new TypeSelectorUI( typeof(RijndaelManaged), typeof(SymmetricAlgorithm), TypeSelectorIncludes.None ); DialogResult typeResult = selector.ShowDialog(); if (typeResult == DialogResult.OK) { Type algorithmType = selector.SelectedType; CryptographicKeyWizard keyManager = new CryptographicKeyWizard(new SymmetricAlgorithmKeyCreator(algorithmType)); DialogResult keyResult = keyManager.ShowDialog(); if (keyResult == DialogResult.OK) { INodeNameCreationService service = ServiceHelper.GetNameCreationService(ServiceProvider); Debug.Assert(service != null, "Could not find the INodeNameCreationService"); base.ExecuteCore(node); SymmetricAlgorithmProviderNode providerNode = (SymmetricAlgorithmProviderNode)ChildNode; providerNode.AlgorithmType = selector.SelectedType; providerNode.Name = service.GetUniqueName(selector.SelectedType.Name, providerNode, providerNode.Parent); providerNode.Key = keyManager.KeySettings; } } }
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; } } }
protected override void ExecuteCore(ConfigurationNode node) { TypeSelectorUI selector = new TypeSelectorUI( typeof(Exception), typeof(Exception), TypeSelectorIncludeFlags.BaseType | TypeSelectorIncludeFlags.AbstractTypes); DialogResult result = selector.ShowDialog(); if (result == DialogResult.OK) { base.ExecuteCore(node); ExceptionTypeNode typeNode = (ExceptionTypeNode)ChildNode; typeNode.TypeName = selector.SelectedType.AssemblyQualifiedName; typeNode.PostHandlingAction = PostHandlingAction.NotifyRethrow; try { typeNode.Name = selector.SelectedType.Name; } catch (InvalidOperationException) { typeNode.Remove(); UIService.ShowError(SR.DuplicateExceptionTypeErrorMessage(selector.SelectedType.Name)); } } }
internal Type ResolveType() { if (type != null) { return(type); } string typeString = typeName; if (!String.IsNullOrEmpty(assemblyName)) { typeString = string.Concat(typeString, ", ", assemblyName); } type = Type.GetType(typeString, false); if (type == null) { IUIService uiService = ServiceHelper.GetUIService(Site); DialogResult dialogResult = uiService.ShowMessage(string.Format(Resources.ResolveTypeManuallyMessage, typeName), Resources.ResolveTypeManuallyCaption, System.Windows.Forms.MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { using (TypeSelectorUI typeSelector = new TypeSelectorUI(typeof(object), typeof(object), TypeSelectorIncludes.AbstractTypes)) { if (DialogResult.OK == typeSelector.ShowDialog()) { type = typeSelector.SelectedType; } } } } return(type); }
protected override void ExecuteCore(ConfigurationNode node) { TypeSelectorUI selector = new TypeSelectorUI(null, typeof(System.Exception)); selector.Text = SR.SelectTypeDialogCaption; DialogResult result = selector.ShowDialog(); if (result == DialogResult.OK) { base.ExecuteCore(node); if (typeof(ITypeDependentExceptionHandler).IsInstanceOfType(ChildNode)) { ((ITypeDependentExceptionHandler)ChildNode).SetSelectedType(selector.SelectedType); } } }
/// <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); } } }
private void selectAlgorithmButton_Click(object sender, EventArgs e) { using (new WaitCursor()) { TypeSelectorUI dialog = new TypeSelectorUI( typeof(RijndaelManaged), typeof(SymmetricAlgorithm), TypeSelectorIncludeFlags.Default); dialog.ShowDialog(); if (dialog.DialogResult == DialogResult.OK) { symmetricAlgorithmType = dialog.SelectedType; symmetricAlgorithmLabel.Text = symmetricAlgorithmType.Name; nextButton.Enabled = true; } } }