/// <summary> /// <para>Edits the specified object's value using the editor style indicated by <see cref="GetEditStyle"/>. This should be a <see cref="DpapiSettings"/> object.</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. This should be a <see cref="DpapiSettings"/> object.</para></param> /// <returns><para>The new value of the <see cref="DpapiSettings"/> object.</para></returns> /// <seealso cref="UITypeEditor.EditValue(ITypeDescriptorContext, IServiceProvider, object)"/> 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)); using (DpapiSettingsEditorUI dialog = new DpapiSettingsEditorUI(required)) { if (ConfirmMessage.Length > 0) { dialog.ConfirmMessage = this.ConfirmMessage; } DpapiSettings dpapiSettings = value as DpapiSettings; InitializeDialog(dialog, dpapiSettings); DpapiSettingsData newSettingsData = dialog.DpapiSettingsData; return(HandleResult(service.ShowDialog(dialog), dpapiSettings, newSettingsData)); } } } return(value); }
private void InitializeDialog(DpapiSettingsEditorUI dialog, DpapiSettings settings) { if (settings != null) { dialog.DpapiSettingsData = new DpapiSettingsData(); dialog.DpapiSettingsData.Mode = settings.Mode; dialog.DpapiSettingsData.Entropy = settings.Entropy; } dialog.DisplaySettings(); }
protected override void ExecuteCore(ConfigurationNode node) { DpapiSettingsEditorUI dpapi = new DpapiSettingsEditorUI(); DialogResult result = dpapi.ShowDialog(); if (result == DialogResult.OK) { base.ExecuteCore(node); DpapiSymmetricCryptoProviderNode cryptoNode = (DpapiSymmetricCryptoProviderNode)ChildNode; DpapiSettings settings = new DpapiSettings(dpapi.DpapiSettingsData); cryptoNode.DataProtectionMode = settings; } }
/// <summary> /// <para>Edits the specified object's value using the editor style indicated by <see cref="GetEditStyle"/>. This should be a <see cref="DpapiSettings"/> object.</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. This should be a <see cref="DpapiSettings"/> object.</para></param> /// <returns><para>The new value of the <see cref="DpapiSettings"/> object.</para></returns> /// <seealso cref="UITypeEditor.EditValue(ITypeDescriptorContext, IServiceProvider, object)"/> 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)); using (DpapiSettingsEditorUI dialog = new DpapiSettingsEditorUI(required)) { if (ConfirmMessage.Length > 0) { dialog.ConfirmMessage = this.ConfirmMessage; } DpapiSettings dpapiSettings = value as DpapiSettings; InitializeDialog(dialog, dpapiSettings); DpapiSettingsData newSettingsData = dialog.DpapiSettingsData; return HandleResult(service.ShowDialog(dialog), dpapiSettings, newSettingsData); } } } return value; }