示例#1
0
 public void Add(DynamicProperty property)
 {
     if (property == null)
     {
         throw new ArgumentNullException("property");
     }
     properties.Add(Tuple.Create(property.ForType, property.Name), property);
 }
示例#2
0
        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));
        }
示例#3
0
        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);
        }
示例#4
0
 public DynamicProperty_For_SomeClass()
 {
     property = DynamicProperty.For <SomeClass>("Test", c => "value");
 }
示例#5
0
 public void Add(DynamicProperty dynamicProperty)
 {
     dynamicProperties.Add(dynamicProperty);
 }
示例#6
0
        public bool TryGetProperty(Type forType, string propertyName, out DynamicProperty property)
        {
            var key = Tuple.Create(forType, propertyName);

            return(properties.TryGetValue(key, out property));
        }