public void SerializeToStream <T>(T obj, Stream stream)
 {
     if (TextSerializer != null)
     {
         TextSerializer.SerializeToStream(obj, stream);
     }
     else if (UseBcl)
     {
         var serializer = new DataContractJsonSerializer(obj.GetType());
         serializer.WriteObject(stream, obj);
     }
     else
     {
         JsonSerializer.SerializeToStream(obj, stream);
     }
 }
        public void SerializeToStream <T>(T obj, Stream stream)
        {
            if (TextSerializer != null)
            {
                TextSerializer.SerializeToStream(obj, stream);
            }
#if !SILVERLIGHT && !MONOTOUCH && !XBOX && !ANDROIDINDIE
            else if (UseBcl)
            {
                var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(obj.GetType());
                serializer.WriteObject(stream, obj);
            }
#endif
            else
            {
                JsonSerializer.SerializeToStream(obj, stream);
            }
        }