コード例 #1
0
 public static string ToJson <T>(T entity, bool format = true)
 {
     return(format
            // pretty or...
         ? JsonConvert.SerializeObject(entity, Formatting.Indented)
            // fast!
         : JsonSerializer.SerializeToString(entity));
 }
コード例 #2
0
        private void ServiceStackBechmark <T>(T obj, int count)
        {
            return;

            try
            {
                long      initlength = 0;
                Stopwatch sw;
                //-----------------------------------
                var sstSerializer = new ServiceStack.Text.JsonSerializer <T>();


                var initSerialized = sstSerializer.SerializeToString(obj);
                initlength = initSerialized.Length;
                sstSerializer.DeserializeFromString(initSerialized);


                using (var sharperMem = new MemoryStream())
                {
                    sw = Stopwatch.StartNew();
                    for (int i = 0; i < count; i++)
                    {
                        sstSerializer.SerializeToString(obj);
                    }
                }
                sw.Stop();
                Log("ServiceStackText Serialize		took: "+ ToString(sw.Elapsed) + "  data-size: " + initlength);


                sw = Stopwatch.StartNew();
                for (int i = 0; i < count; i++)
                {
                    sstSerializer.DeserializeFromString(initSerialized);
                }
                sw.Stop();
                Log("ServiceStackText Deserialize		took: "+ ToString(sw.Elapsed));
            }
            catch (Exception ex)
            {
                Log("ServiceStackText failed, " + ex.Message);
            }
        }
コード例 #3
0
        private async Task CreateCognitoSecretFileAsync()
        {
            foreach (var cognitoClient in this._configSettings.ExtraAWSConfig.CognitoClients)
            {
                cognitoClient.ClientSecret = await _awsCognitoHelper.GetClientSecretForAppClientAsync(cognitoClient)
                                             .ConfigureAwait(false);
            }

            await FileHelper.CreateFileWithContentAsync(Path.Combine(this._configSettings.SecretsDockerFolderPath,
                                                                     this._configSettings.ExtraAWSConfig.CognitoSecretsFileName),
                                                        JsonSerializer.SerializeToString(this._configSettings.ExtraAWSConfig.CognitoClients))
            .ConfigureAwait(false);
        }
コード例 #4
0
ファイル: JsonExtensions.cs プロジェクト: w393278126/platform
 public static string ToJson(this object obj)
 {
     return(JsonSerializer.SerializeToString(obj));
 }
コード例 #5
0
ファイル: Serializers.cs プロジェクト: gkurts/jwt
 public string Serialize(object obj)
 {
     return(JsonSerializer.SerializeToString(obj));
 }
コード例 #6
0
 public string ServiceStack_Serialize()
 {
     return(JsonSerializer.SerializeToString(RootSampleObject));
 }
コード例 #7
0
 /// <summary>
 /// Serializes object to a string
 /// </summary>
 /// <param name="obj">Object to serialize</param>
 /// <returns>Serialized string of the object</returns>
 public string Serialize <T>(T obj)
 {
     return(Serializer.SerializeToString(obj));
 }