terça-feira, 15 de maio de 2018

Flurl custom Json settings

            Flurl.Http.FlurlHttp.Configure(settings =>
            {
                settings.JsonSerializer = new Flurl.Http.Configuration.NewtonsoftJsonSerializer(WebAPI.helper.serializerSettings);
            });

public static class helper
    {
        ///

        /// Utilize este arquivo helper.cs
        /// Atencao em todo o sistema deve usar esta mesma configuracao, Server e no Client,
        /// exemplo no Azure Function e no site SistemaMulti
        ///

        public static Newtonsoft.Json.JsonSerializerSettings serializerSettings = new Newtonsoft.Json.JsonSerializerSettings()
        {
            ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
            PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.All,    //????.Arrays,
            TypeNameHandling = Newtonsoft.Json.TypeNameHandling.All,
            //Formatting = Newtonsoft.Json.Formatting.Indented,

        };
        public static string ToUTF8String(this System.IO.Stream se)
        {
            using (var reader = new System.IO.StreamReader(se, Encoding.UTF8))
            {
                string value = reader.ReadToEnd();
                return value;
            }
        }
    }

Nenhum comentário :