コード例 #1
0
ファイル: JavascriptRoute.cs プロジェクト: jrios/fubumvc
        public void WriteNode(IMediaNode node, IHttpRequest request, IChainResolver resolver)
        {
            var chain = Finder(resolver) as RoutedChain;

            if (chain == null)
            {
                throw new Exception("Unable to find a routed chain for a Javascript route named " + Name);
            }

            node.SetAttribute("name", Name);
            node.SetAttribute("method", Method);
            node.SetAttribute("url", request.ToFullUrl(chain.GetRoutePattern()));
            if (chain.Route.Input != null)
                node.SetAttribute("params", chain.Route.Input.RouteParameters.Select(x => x.Name).ToArray());
        }
コード例 #2
0
        public void Project <T>(IProjectionContext <T> context, IMediaNode childNode, IMediaNode parentNode, string nodeName)
        {
            var connegGraph    = context.Service <ConnegSettings>().Graph;
            var projectionType = connegGraph.WriterTypesFor(typeof(TValue))
                                 .FirstOrDefault(x => x.CanBeCastTo <IProjection <TValue> >() && x.IsConcreteWithDefaultCtor());

            var childContext = context.ContextFor(_value);

            if (projectionType == null)
            {
                parentNode.SetAttribute(nodeName, _value);
            }
            else
            {
                var projection = Activator.CreateInstance(projectionType).As <IProjection <TValue> >();
                projection.Write(childContext, childNode);
            }
        }
コード例 #3
0
ファイル: AccessorProjection.cs プロジェクト: DRHouk/fubumvc
        public void WriteValue(IValues <T> target, IMediaNode node)
        {
            var value = target.ValueFor(_accessor);

            node.SetAttribute(Name(), value);
        }
コード例 #4
0
        public void Write(IProjectionContext <T> context, IMediaNode node)
        {
            var value = Source(context);

            node.SetAttribute(AttributeName, value);
        }
コード例 #5
0
 public void Write(IProjectionContext <T> context, IMediaNode node)
 {
     node.SetAttribute(attributeName, source(context));
 }