public void GetterTest()
        {
            var getterIntegerProperty = ExpressionUtils.CreateGetter <SampleClass, int>(x => x.IntegerProperty);
            var getterStringProperty  = ExpressionUtils.CreateGetter <SampleClass, string>(x => x.StringProperty);

            SampleClass sampleClassInstance = new SampleClass()
            {
                IntegerProperty = 1,
                StringProperty  = "2"
            };

            Assert.AreEqual(1, getterIntegerProperty(sampleClassInstance));
            Assert.AreEqual("2", getterStringProperty(sampleClassInstance));
        }
Ejemplo n.º 2
0
        protected void AddProperty(EntityView entityView, TComponent component, Expression <Func <TComponent, object> > property,
                                   bool isReadOnly = true, bool isRequired = false)
        {
            var propertyInfo = ExpressionUtils.GetProperty(property);
            var getter       = ExpressionUtils.CreateGetter(property);

            entityView.Properties.Add(new ViewProperty
            {
                Name       = propertyInfo.Name,
                IsRequired = false,
                RawValue   = getter(component),
                IsReadOnly = false
            });
        }