/// <summary> /// Edits the value of the specified object using the specified service provider and context. /// </summary> /// <param name="context">An <see cref="ITypeDescriptorContext"/> that can be used to gain additional context information. </param> /// <param name="provider">A service provider object through which editing services can be obtained.</param> /// <param name="value">The object to edit the value of.</param> /// <returns>The new value of the object. If the value of the object has not changed, this should return the same object it was passed.</returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context == null) { throw new ArgumentNullException("context"); } GenericDictionaryEditorAttribute attribute = context.PropertyDescriptor.Attributes[typeof(GenericDictionaryEditorAttribute)] as GenericDictionaryEditorAttribute; if (attribute != null) { this.m_EditorAttribute = attribute; if (this.m_EditorAttribute.KeyDefaultProviderType == null) { this.m_EditorAttribute.KeyDefaultProviderType = typeof(DefaultProvider <TKey>); } if (this.m_EditorAttribute.ValueDefaultProviderType == null) { this.m_EditorAttribute.ValueDefaultProviderType = typeof(DefaultProvider <TValue>); } } else { this.m_EditorAttribute = new GenericDictionaryEditorAttribute(); this.m_EditorAttribute.KeyDefaultProviderType = typeof(DefaultProvider <TKey>); this.m_EditorAttribute.ValueDefaultProviderType = typeof(DefaultProvider <TValue>); } return(base.EditValue(context, provider, value)); }
public EditableKeyValuePair(TKey key, TValue value, GenericDictionaryEditorAttribute editorAttribute) { this.Key = key; this.Value = value; if (editorAttribute == null) { throw new ArgumentNullException("editorAttribute"); } m_EditorAttribute = editorAttribute; }