protected override DoNext applyOutputs(IOutputNode node, BehaviorChain chain, ConnegSettings settings)
        {
            node.Add(settings.FormatterFor(MimeType.Json));
            node.Add(settings.FormatterFor(MimeType.Xml));

            return DoNext.Continue;
        }
        protected override DoNext applyOutputs(IOutputNode node, BehaviorChain chain, ConnegSettings settings)
        {
            var graph = settings.Graph ?? new ConnegGraph();
            graph.WriterTypesFor(node.ResourceType).Each(type => node.Add((IMediaWriter) Activator.CreateInstance(type)));

            return DoNext.Continue;
        }
        protected override DoNext applyInputs(IInputNode node, BehaviorChain chain, ConnegSettings settings)
        {
            var graph = settings.Graph ?? new ConnegGraph();
            graph.ReaderTypesFor(node.InputType()).Each(type => node.Add(Activator.CreateInstance((Type) type).As<IReader>()));

            return DoNext.Continue;
        }
Ejemplo n.º 4
0
        public void add_formatter_places_it_first()
        {
            var settings = new ConnegSettings();
            settings.AddFormatter(new AjaxAwareJsonSerializer());

            settings.FormatterFor(MimeType.Json)
                .ShouldBeOfType<AjaxAwareJsonSerializer>();
        }
        protected override DoNext applyInputs(IInputNode node, BehaviorChain chain, ConnegSettings settings)
        {
            node.Add(typeof(ModelBindingReader<>));
            node.Add(settings.FormatterFor(MimeType.Json));
            node.Add(settings.FormatterFor(MimeType.Xml));

            return DoNext.Continue;
        }
Ejemplo n.º 6
0
        protected override DoNext applyOutputs(IOutputNode node, BehaviorChain chain, ConnegSettings settings)
        {
            if (!chain.ResourceType().CanBeCastTo<AjaxContinuation>()) return DoNext.Continue;
       
            node.Add(typeof(AjaxContinuationWriter<>));

            return DoNext.Stop;
        }
Ejemplo n.º 7
0
        protected override DoNext applyInputs(IInputNode node, BehaviorChain chain, ConnegSettings settings)
        {
            if (!chain.ResourceType().CanBeCastTo<AjaxContinuation>()) return DoNext.Continue;

            node.Add(typeof(ModelBindingReader<>));
            node.Add(settings.FormatterFor(MimeType.Json));

            return DoNext.Stop;
        }
Ejemplo n.º 8
0
        protected override DoNext applyOutputs(IOutputNode node, BehaviorChain chain, ConnegSettings settings)
        {
            if (chain.ResourceType().CanBeCastTo<HtmlTag>() || chain.ResourceType().CanBeCastTo<HtmlDocument>())
            {
                node.Add(typeof(HtmlStringWriter<>));
                return DoNext.Stop;
            }

            return DoNext.Continue;
        }
Ejemplo n.º 9
0
        protected override DoNext applyOutputs(IOutputNode node, BehaviorChain chain, ConnegSettings settings)
        {
            if (chain.ResourceType() == typeof (string))
            {
                node.Add(new StringWriter());

                return DoNext.Stop;
            }

            return base.applyOutputs(node, chain, settings);
        }
Ejemplo n.º 10
0
        protected override DoNext applyOutputs(IOutputNode node, BehaviorChain chain, ConnegSettings settings)
        {
            var candidates = settings.Views.Where(x => x.ViewModel == node.ResourceType).ToArray();
            if (candidates.Count() == 1)
            {
                if (!node.HasView())
                {
                    node.AddView(candidates.Single());
                }
            }

            return DoNext.Continue;
        }
Ejemplo n.º 11
0
 public MimetypeContext(ConnegSettings settings, ICurrentChain currentChain, IHttpRequest request)
 {
     _settings     = settings;
     _currentChain = currentChain;
     _request      = request;
 }
Ejemplo n.º 12
0
        public void use_a_custom_querystring_parameter()
        {
            var request = OwinHttpRequest.ForTesting();
            request.QueryString["Format"] = "Text";

            var settings = new ConnegSettings();
            settings.QuerystringParameters.Add(new ConnegQuerystring("Format", "Text", MimeType.Text));

            var mimeType = new CurrentMimeType("text/json", theOriginalMimetype);

            settings.InterpretQuerystring(mimeType, request);

            mimeType.AcceptTypes.Single().ShouldEqual(MimeType.Text.Value);
        }
Ejemplo n.º 13
0
 public void UseSettings(ConnegSettings settings)
 {
     _settings = settings;
 }
 public MimetypeContext(ConnegSettings settings, ICurrentChain currentChain, IHttpRequest request)
 {
     _settings = settings;
     _currentChain = currentChain;
     _request = request;
 }