/// <summary> /// Edits the specified object's value using the editor style indicated by <seealso cref="UITypeEditor.GetEditStyle()"/>. /// </summary> /// <param name="context"> /// An <see cref="ITypeDescriptorContext"/> that can be used to gain additional context information. /// </param> /// <param name="provider"> /// An <see cref="IServiceProvider"/> that this editor can use to obtain services. /// </param> /// <param name="value"> /// The object to edit. /// </param> /// <returns> /// The fully qualifed type name for the chosen type. /// </returns> 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 currentTypeName = value as string; Type currentType = (currentTypeName == null) ? value as Type : Type.GetType(currentTypeName, false); BaseTypeAttribute baseTypeAttribute = GetBaseType(context); using (TypeSelectorUI form = new TypeSelectorUI(currentType, baseTypeAttribute.BaseType, baseTypeAttribute.TypeSelectorIncludes, baseTypeAttribute.ConfigurationType)) { if (service.ShowDialog(form) == DialogResult.OK) { if (form.SelectedType != null) { currentType = form.SelectedType; } } } if (currentType != null) { return(currentType.AssemblyQualifiedName); } } } return(value); }
/// <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; } } }
/// <summary> /// Edits the specified object's value using the editor style indicated by <seealso cref="UITypeEditor.GetEditStyle()"/>. /// </summary> /// <param name="context"> /// An <see cref="ITypeDescriptorContext"/> that can be used to gain additional context information. /// </param> /// <param name="provider"> /// An <see cref="IServiceProvider"/> that this editor can use to obtain services. /// </param> /// <param name="value"> /// The object to edit. /// </param> /// <returns> /// The fully qualifed type name for the chosen type. /// </returns> 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)); Type currentType = (Type)value; BaseTypeAttribute baseTypeAttribute = GetBaseType(context); using (TypeSelectorUI form = new TypeSelectorUI(currentType, baseTypeAttribute.BaseType, baseTypeAttribute.TypeSelectorIncludes, baseTypeAttribute.ConfigurationType)) { if (service.ShowDialog(form) == DialogResult.OK) { if (form.SelectedType != null) { currentType = form.SelectedType; } } } return currentType; } } return value; }
/// <summary> /// <para>Edits the specified object's value using the editor style indicated by <seealso cref="UITypeEditor.GetEditStyle"/>.</para> /// </summary> /// <param name="context"> /// <para>An <see cref="ITypeDescriptorContext"/> that can be used to gain additional context information.</para> /// </param> /// <param name="provider"> /// <para>An <see cref="IServiceProvider"/> that this editor can use to obtain services.</para> /// </param> /// <param name="value"> /// <para>The object to edit.</para> /// </param> /// <returns> /// The fully qualifed type name for the chosen type. /// </returns> 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 currentTypeName = (string)value; Type currentType = null; if ((currentTypeName != null) && (currentTypeName.Length != 0)) { currentType = Type.GetType(currentTypeName, false); } BaseTypeAttribute baseTypeAttribute = this.GetBaseType(context); using (TypeSelectorUI form = new TypeSelectorUI(currentType, baseTypeAttribute.BaseType, baseTypeAttribute.IncludeFlags)) { if (service.ShowDialog(form) == DialogResult.OK) { if (form.SelectedType != null) { currentTypeName = form.SelectedType.AssemblyQualifiedName; } } } return currentTypeName; } } return value; }
/// <summary> /// <para>Edits the specified object's value using the editor style indicated by <seealso cref="UITypeEditor.GetEditStyle"/>.</para> /// </summary> /// <param name="context"> /// <para>An <see cref="ITypeDescriptorContext"/> that can be used to gain additional context information.</para> /// </param> /// <param name="provider"> /// <para>An <see cref="IServiceProvider"/> that this editor can use to obtain services.</para> /// </param> /// <param name="value"> /// <para>The object to edit.</para> /// </param> /// <returns> /// The fully qualifed type name for the chosen type. /// </returns> 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 currentTypeName = (string)value; Type currentType = null; if ((currentTypeName != null) && (currentTypeName.Length != 0)) { currentType = Type.GetType(currentTypeName, false); } BaseTypeAttribute baseTypeAttribute = this.GetBaseType(context); using (TypeSelectorUI form = new TypeSelectorUI(currentType, baseTypeAttribute.BaseType, baseTypeAttribute.IncludeFlags)) { if (service.ShowDialog(form) == DialogResult.OK) { if (form.SelectedType != null) { currentTypeName = form.SelectedType.AssemblyQualifiedName; } } } return(currentTypeName); } } return(value); }
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)); } } }
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); } } }
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; }