protected override void WriteTo(object item, TextWriter writer, WriterContext context)
        {
            if (item == null)
            {
                return;
            }

            FormUrlEncodingSerializer serializer = new FormUrlEncodingSerializer(item.GetType());

            serializer.Serialize(writer, item, context.Session.SerializerSettings);
        }
예제 #2
0
 public void WriteTo(object entity, OpenRasta.Web.IHttpEntity response, string[] codecParameters)
 {
     using (TextWriter writer = new StreamWriter(response.Stream))
     {
         Encoding enc = null;
         if (Context.Request.Headers["Accept-Charset"] != null)
         {
             enc = Encoding.GetEncoding(Context.Request.Headers["Accept-Charset"]);
         }
         ObjectSerializerSettings settings = new ObjectSerializerSettings {
             Encoding = enc
         };
         FormUrlEncodingSerializer serializer = new FormUrlEncodingSerializer(entity.GetType());
         serializer.Serialize(writer, entity, settings);
     }
 }