GetValue() public method

public GetValue ( object>.IDictionary documentHost, object model, Parrot valueType, object property, object &value ) : bool
documentHost object>.IDictionary
model object
valueType Parrot
property object
value object
return bool
        public void ExpandoObjectStringLiteral()
        {
            var valueType = ValueType.StringLiteral;
            dynamic property = "this is a string literal";
            var documentHost = new Dictionary<string, object>();

            IValueTypeProvider valueTypeProvider = new ValueTypeProvider();
            IModelValueProvider modelValueProvider = new ObjectModelValueProvider(valueTypeProvider);
            object result;
            modelValueProvider.GetValue(documentHost, null, valueType, property, out result);
            Assert.IsInstanceOf<string>(result);
            Assert.AreEqual(property, result as string);
        }
        public void Keyword()
        {
            var valueType = ValueType.Keyword;
            object property = false;
            var documentHost = new Dictionary<string, object>();

            IValueTypeProvider valueTypeProvider = new ValueTypeProvider();
            IModelValueProvider modelValueProvider = new ObjectModelValueProvider(valueTypeProvider);
            object result;
            modelValueProvider.GetValue(documentHost, null, valueType, property, out result);

            Assert.AreEqual(property, result);
        }
        public void Local()
        {
            var valueType = ValueType.Local;
            object property = "this";
            object model = new { Name = "Ben" };
            var documentHost = new Dictionary<string, object>();

            IValueTypeProvider valueTypeProvider = new ValueTypeProvider();
            IModelValueProvider modelValueProvider = new ObjectModelValueProvider(valueTypeProvider);
            object result;
            modelValueProvider.GetValue(documentHost, model, valueType, property, out result);

            Assert.AreEqual(model, result);
        }
Esempio n. 4
0
        public void NestedProperty()
        {
            var valueType = ValueType.Property;
            object property = "Name.FirstName";
            object model = new { Name = new { FirstName = "Ben", LastName = "Dornis" } };
            var documentHost = new Dictionary<string, object>();

            IValueTypeProvider valueTypeProvider = new ValueTypeProvider();
            IModelValueProvider modelValueProvider = new ObjectModelValueProvider(valueTypeProvider);
            object result;
            modelValueProvider.GetValue(documentHost, model, valueType, property, out result);

            Assert.AreEqual("Ben", result);
        }
        public void Property()
        {
            var valueType = ValueType.Property;
            object property = "Name";
            dynamic model = new ExpandoObject();
            model.Name = new ExpandoObject();
            model.Name = "Ben";
            var documentHost = new Dictionary<string, object>();

            IValueTypeProvider valueTypeProvider = new ValueTypeProvider();
            IModelValueProvider modelValueProvider = new ObjectModelValueProvider(valueTypeProvider);
            object result;
            modelValueProvider.GetValue(documentHost, model, valueType, property, out result);

            Assert.AreEqual("Ben", result);
        }