public void Add(DynamicProperty property) { if (property == null) { throw new ArgumentNullException("property"); } properties.Add(Tuple.Create(property.ForType, property.Name), property); }
public void Can_get_property_for_subtypes() { var properties = new DynamicPropertyProvider(); properties.Add(DynamicProperty.For <Person>("Test", p => 0)); DynamicProperty property; Assert.True(properties.TryGetProperty(typeof(Employee), "Test", out property)); }
public void Can_add_dynamic_property_to_object_in_viewmodel() { dynamic viewmodel = new DynamicViewModel(); viewmodel.Customer = new Customer { Id = 1 }; viewmodel.Add(DynamicProperty.For <Customer>("Url", c => "/customer/" + c.Id)); Assert.Equal("/customer/1", viewmodel.Customer.Url); }
public DynamicProperty_For_SomeClass() { property = DynamicProperty.For <SomeClass>("Test", c => "value"); }
public void Add(DynamicProperty dynamicProperty) { dynamicProperties.Add(dynamicProperty); }
public bool TryGetProperty(Type forType, string propertyName, out DynamicProperty property) { var key = Tuple.Create(forType, propertyName); return(properties.TryGetValue(key, out property)); }