public static bool IsAsymmetricJson(this BehaviorChain chain)
        {
            if (chain.ConnegInputNode() == null && chain.ConnegOutputNode() == null)
            {
                return(false);
            }

            if (chain.ActionOutputType() != null)
            {
                var output = chain.ConnegOutputNode();
                if (output.SelectedFormatterTypes.Count() != 1)
                {
                    return(false);
                }

                if (output.SelectedFormatterTypes.Single() != typeof(JsonFormatter))
                {
                    return(false);
                }
            }

            if (chain.InputType() != null)
            {
                var input = chain.ConnegInputNode();

                if (!input.AllowHttpFormPosts)
                {
                    return(false);
                }

                if (input.SelectedFormatterTypes.Count() != 1)
                {
                    return(false);
                }

                if (input.SelectedFormatterTypes.Single() != typeof(JsonFormatter))
                {
                    return(false);
                }
            }

            return(true);
        }
        // This should not do anything if there are conneg nodes
        public static void ApplyConneg(this BehaviorChain chain)
        {
            var inputType = chain.InputType();

            if (chain.ConnegInputNode() == null && inputType != null)
            {
                var inputNode = new ConnegInputNode(inputType);
                var action    = chain.FirstCall();
                action.AddBefore(inputNode);
            }

            var actionOutputType = chain.ActionOutputType();

            if (chain.ConnegOutputNode() == null && actionOutputType != null && actionOutputType != typeof(void) && actionOutputType != typeof(HttpStatusCode))
            {
                var outputNode = new ConnegOutputNode(actionOutputType);
                var action     = chain.Last(x => x is ActionCall);
                action.AddAfter(outputNode);
            }
        }
Exemplo n.º 3
0
 public string Text(BehaviorChain chain)
 {
     return(chain.ActionOutputType().Name);
 }
Exemplo n.º 4
0
        public void WriteBody(BehaviorChain chain, HtmlTag row, HtmlTag cell)
        {
            var outputType = chain.ActionOutputType();

            cell.Append(new LinkTag(outputType.Name, _examplePageUrl + "?model=" + outputType.FullName));
        }
Exemplo n.º 5
0
 public static bool IsAjaxContinuation(BehaviorChain chain)
 {
     var outputType = chain.ActionOutputType();
     return outputType != null && outputType.CanBeCastTo<AjaxContinuation>();
 }
Exemplo n.º 6
0
 public void WriteBody(BehaviorChain chain, HtmlTag row, HtmlTag cell)
 {
     var outputType = chain.ActionOutputType();
     cell.Child(new LinkTag(outputType.Name, _examplePageUrl + "?model=" + outputType.FullName));
 }
Exemplo n.º 7
0
 public string Text(BehaviorChain chain)
 {
     return chain.ActionOutputType().Name;
 }
Exemplo n.º 8
0
        public static bool IsAjaxContinuation(BehaviorChain chain)
        {
            var outputType = chain.ActionOutputType();

            return(outputType != null && outputType.CanBeCastTo <AjaxContinuation>());
        }