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;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// See <see cref="UITypeEditor.EditValue"/>.
        /// </summary>
        /// <param name="context">See <see cref="UITypeEditor.EditValue"/>.</param>
        /// <param name="provider">See <see cref="UITypeEditor.EditValue"/>.</param>
        /// <param name="value">See <see cref="UITypeEditor.EditValue"/>.</param>
        /// <returns>See <see cref="UITypeEditor.EditValue"/>.</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));

                    KeySettings keySettings = value as KeySettings;
                    if (keySettings == null)
                    {
                        throw new ArgumentException(SR.KeyManagerEditorRequiresKeyInfoProperty);
                    }

                    KeyManagerEditorUI dialog = new KeyManagerEditorUI(keySettings.Clone());
                    DialogResult dialogResult = service.ShowDialog(dialog);

                    if (dialogResult == DialogResult.Cancel)
                    {
                        return keySettings;
                    }
                    else
                    {
                        return dialog.KeySettings;
                    }
                }
            }
            return value;
        }
        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;
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// See <see cref="UITypeEditor.EditValue"/>.
        /// </summary>
        /// <param name="context">See <see cref="UITypeEditor.EditValue"/>.</param>
        /// <param name="provider">See <see cref="UITypeEditor.EditValue"/>.</param>
        /// <param name="value">See <see cref="UITypeEditor.EditValue"/>.</param>
        /// <returns>See <see cref="UITypeEditor.EditValue"/>.</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));

                    KeySettings keySettings = value as KeySettings;
                    if (keySettings == null)
                    {
                        throw new ArgumentException(SR.KeyManagerEditorRequiresKeyInfoProperty);
                    }

                    KeyManagerEditorUI dialog       = new KeyManagerEditorUI(keySettings.Clone());
                    DialogResult       dialogResult = service.ShowDialog(dialog);

                    if (dialogResult == DialogResult.Cancel)
                    {
                        return(keySettings);
                    }
                    else
                    {
                        return(dialog.KeySettings);
                    }
                }
            }
            return(value);
        }