/// <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); }
public void Clone() { SymmetricAlgorithmKeyCreator keyCreator = new SymmetricAlgorithmKeyCreator(typeof(RijndaelManaged).AssemblyQualifiedName); byte[] key = keyCreator.GenerateKey(); KeySettings settings = new KeySettings(keyCreator); settings.Key = key; KeySettings settingsClone = settings.Clone(); Assert.AreSame(keyCreator, settingsClone.KeyCreator); Assert.AreEqual(key, settingsClone.Key); }