public void with_the_normal_casing()
        {
            var projection = new Projection<SomeTarget>();

            //projection.CamelCaseAttributeNames();
            projection.Value(x => x.Name);
            projection.Value(x => x.Age);
            projection.Child(x => x.Child).Configure(_ =>
            {
                _.Value(x => x.Name);
            });

            var node = new DictionaryMediaNode();
            var someTarget = new SomeTarget
            {
                Active = true,
                Age = 40,
                Name = "Jeremy",
                Child = new SomeChild { Name = "Max" }
            };

            projection.As<IProjection<SomeTarget>>().Write(new ProjectionContext<SomeTarget>(new InMemoryServiceLocator(), someTarget), node);

            node.Values["Name"].ShouldEqual("Jeremy");
            node.Values["Age"].ShouldEqual(40);

            node.Values["Child"].As<IDictionary<string, object>>()["Name"].ShouldEqual("Max");
        }
        public IMediaNode Add()
        {
            var node = new DictionaryMediaNode();
            _list.Add(node.Values);

            return node;
        }
Ejemplo n.º 3
0
        public static IDictionary<string, object> Write(Action<IMediaNode> configuration)
        {
            var node = new DictionaryMediaNode();
            configuration(node);

            return node.Values;
        }
Ejemplo n.º 4
0
        public static IDictionary <string, object> Write(Action <IMediaNode> configuration)
        {
            var node = new DictionaryMediaNode();

            configuration(node);

            return(node.Values);
        }
Ejemplo n.º 5
0
        public IMediaNode Add()
        {
            var node = new DictionaryMediaNode();

            _list.Add(node.Values);

            return(node);
        }
Ejemplo n.º 6
0
        void IMediaWriter <T> .Write(string mimeType, IFubuRequestContext request, T resource)
        {
            var node    = new DictionaryMediaNode();
            var context = new ProjectionContext <T>(request.Services, new SimpleValues <T>(resource));

            write(context, node);

            request.Writer.Write(mimeType, JsonUtil.ToJson(node.Values));
        }
Ejemplo n.º 7
0
        Task IMediaWriter <T> .Write(string mimeType, IFubuRequestContext request, T resource)
        {
            var node    = new DictionaryMediaNode();
            var context = new ProjectionContext <T>(request.Services, new SimpleValues <T>(resource));

            write(context, node);

            var serializer = request.Services.GetInstance <IJsonSerializer>();

            return(request.Writer.Write(mimeType, serializer.Serialize(node.Values, false)));
        }
Ejemplo n.º 8
0
        public IDictionary<string, object> Write(IEnumerable<JavascriptRoute> routes)
        {
            var node = new DictionaryMediaNode();

            routes.Each(x => {
                var child = node.AddChild(x.Name);
                x.WriteNode(child, _request, _resolver);
            });

            return node.Values;
        }
        public void should_just_use_IProjectMyself_Project_in_accessor_projection()
        {
            var projection = AccessorProjection<ComplexValueHolder, ComplexValue>.For(x => x.Value);
            var target = new ComplexValueHolder
            {
                Value = new ComplexValue {Name = "Jeremy", Age = 38}
            };

            var context = new ProjectionContext<ComplexValueHolder>(new InMemoryServiceLocator(), target);

            var node = new DictionaryMediaNode();
            projection.As<IProjection<ComplexValueHolder>>().Write(context, node);

            node.Values["Value"].As<IDictionary<string, object>>()["Name"].ShouldBe("Jeremy");
            node.Values["Value"].As<IDictionary<string, object>>()["Age"].ShouldBe(38);
        }
Ejemplo n.º 10
0
        public IDictionary<string, object> Write(IEnumerable<JavascriptRoute> routes)
        {
            var node = new DictionaryMediaNode();

            routes.Each(x => {
                var child = node.AddChild(x.Name);
                var chain = x.FindChain(_resolver);
                child.SetAttribute("name", x.Name);
                child.SetAttribute("method", x.Method);

                child.SetAttribute("url", _routeData.ToUrl(chain));

                var parameters = _routeData.ToParameters(chain);
                if (parameters.Any())
                {
                    child.SetAttribute("params", parameters);
                }
                


            });

            return node.Values;
        }
Ejemplo n.º 11
0
 public void SetUp()
 {
     theNode = new DictionaryMediaNode();
 }