Takes a parrot declaration, wraps it and determines type
Inheritance: IValueTypeProvider
        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 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 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);
        }
Exemplo 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);
        }
Exemplo n.º 5
0
 public AspNetHost(IParrotWriterProvider parrotWriterProvider)
 {
     _parrotWriterProvider = parrotWriterProvider;
     ValueTypeProvider = new ValueTypeProvider();
     ModelValueProviderFactory = new ModelValueProviderFactory(ValueTypeProvider);
     AttributeRenderer = new AttributeRenderer();
     RendererFactory = new RendererFactory(new IRenderer[]
         {
             new HtmlRenderer(this),
             new StringLiteralRenderer(this),
             new DocTypeRenderer(this),
             new LayoutRenderer(this),
             new PartialRenderer(this),
             new ContentRenderer(this),
             new ForeachRenderer(this),
             new InputRenderer(this),
             new ConditionalRenderer(this),
             new ListRenderer(this),
             new SelfClosingRenderer(this),
             new ActionRenderer(this), 
             new DefineRenderer(this), 
         });
     PathResolver = new PathResolver();
 }
        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);
        }