Exemplo n.º 1
0
 protected void given_registration_codec <TCodec, TResource>(string mediaTypes)
 {
     foreach (var contentType in MediaType.Parse(mediaTypes))
     {
         Codecs.Add(CodecRegistration.FromResourceType(typeof(TResource),
                                                       typeof(TCodec),
                                                       TypeSystem,
                                                       contentType,
                                                       null,
                                                       null,
                                                       false));
     }
 }
Exemplo n.º 2
0
        protected void given_response_entity(object responseEntity, Type codecType, string contentType)
        {
            Context.Response.Entity.ContentType = new MediaType(contentType);

            Context.Environment.ResponseCodec = CodecRegistration.FromResourceType(responseEntity == null ? typeof(object) : responseEntity.GetType(),
                                                                                   codecType,
                                                                                   TypeSystem,
                                                                                   new MediaType(contentType),
                                                                                   null,
                                                                                   null,
                                                                                   false);
            given_response_entity(responseEntity);
        }
Exemplo n.º 3
0
        void GivenAResponseCodec <TCodec>(object config)
        {
            if (Context.PipelineData.ResponseCodec != null)
            {
                Context.PipelineData.ResponseCodec = null;
            }

            Context.PipelineData.ResponseCodec = CodecRegistration.FromResourceType(typeof(object),
                                                                                    typeof(TCodec),
                                                                                    TypeSystems.Default,
                                                                                    new MediaType("application/unknown"),
                                                                                    null,
                                                                                    config, false);
        }
        protected void GivenACodec <TCodec, TResource>(string mediaTypes, string config)
        {
            foreach (var mediaType in MediaType.Parse(mediaTypes))
            {
                Type resourceType = typeof(TResource);

                Codecs.Add(CodecRegistration.FromResourceType(resourceType,
                                                              typeof(TCodec),
                                                              TypeSystems.Default,
                                                              mediaType,
                                                              null,
                                                              config, false));
            }
        }