public void JsonSerialization_ReturnsExpected() { var property = new PropertyValueDescriptor("value", "origin"); var result = Serialize(property); Assert.Equal("{\"value\":\"value\",\"origin\":\"origin\"}", result); }
public void Constructor_SetsValues() { var property = new PropertyValueDescriptor("value", "origin"); Assert.Equal("value", property.Value); Assert.Equal("origin", property.Origin); }
public virtual List <Dictionary <string, PropertyDescriptor> > GetPropertyValues( ) { List <Dictionary <string, PropertyDescriptor> > result = new List <Dictionary <string, PropertyDescriptor> >( ); Dictionary <string, PropertyDescriptor> propertyValues = new Dictionary <string, PropertyDescriptor>(StringComparer.CurrentCultureIgnoreCase); Dictionary <string, PropertyDescriptor> dynamicPropertyValues = new Dictionary <string, PropertyDescriptor>(StringComparer.CurrentCultureIgnoreCase); result.Add(propertyValues); result.Add(dynamicPropertyValues); TypeDescriptionProvider typeProvider = TypeDescriptor.GetProvider(typeof(DomainObjectWithPropertyValues)); var propDescriptors = typeProvider.GetTypeDescriptor(typeof(DomainObjectWithPropertyValues), this).GetProperties( ).Cast <PropertyDescriptor>( ); var propertyInfos = propDescriptors.Where(p => !p.IsReadOnly); PropertyValueDescriptor propValueDescriptor = null; foreach (PropertyDescriptor item in propertyInfos) { if (!propertyValues.ContainsKey(item.Name)) { propertyValues.Add(item.Name, item); } propValueDescriptor = item as PropertyValueDescriptor; if (propValueDescriptor != null) { if (!string.IsNullOrEmpty(propValueDescriptor.CustomField.ExternalMessageKey)) //only add it to the collection if the external message key is not empty { if (!dynamicPropertyValues.ContainsKey(propValueDescriptor.CustomField.ExternalMessageKey)) { dynamicPropertyValues.Add(propValueDescriptor.CustomField.ExternalMessageKey, item); //add to the dynamic property collection. } } else { if (!dynamicPropertyValues.ContainsKey(item.Name)) { dynamicPropertyValues.Add(item.Name, item); //add to the dynamic property collection. } } } } return(result); }