/// <summary> /// Initializes a new instance of the <see cref="DictionaryTypeDescriptor"/> class. /// </summary> /// <param name="data">A dictionary mapping property names to property values.</param> /// <param name="types">A dictionary mapping property names to property types.</param> public DictionaryTypeDescriptor(IDictionary <string, object> data, IDictionary <string, Type> types) { if (data == null) { throw new ArgumentNullException("data", "data should not be null."); } _data = data; _propertyDescriptors = new List <DictionaryPropertyDescriptor>(); foreach (KeyValuePair <string, object> pair in _data) { Type type; if (types == null || !types.TryGetValue(pair.Key, out type)) { type = typeof(object); } DictionaryPropertyDescriptor propertyDescriptor = new DictionaryPropertyDescriptor(data, pair.Key, type); propertyDescriptor.AddValueChanged(this, (s, e) => OnPropertyChanged(pair.Key)); _propertyDescriptors.Add(propertyDescriptor); } }
/// <summary> /// Initializes a new instance of the <see cref="DictionaryTypeDescriptor"/> class. /// </summary> /// <param name="data">A dictionary mapping property names to property values.</param> /// <param name="types">A dictionary mapping property names to property types.</param> public DictionaryTypeDescriptor(IDictionary<string, object> data, IDictionary<string, Type> types) { if (data == null) { throw new ArgumentNullException("data", "data should not be null."); } _data = data; _propertyDescriptors = new List<DictionaryPropertyDescriptor>(); foreach (KeyValuePair<string, object> pair in _data) { Type type; if (types == null || !types.TryGetValue(pair.Key, out type)) { type = typeof(object); } DictionaryPropertyDescriptor propertyDescriptor = new DictionaryPropertyDescriptor(data, pair.Key, type); propertyDescriptor.AddValueChanged(this, (s, e) => OnPropertyChanged(pair.Key)); _propertyDescriptors.Add(propertyDescriptor); } }