public object GetEntityJsonInstance(string entityJson, Type entityType)
 {
     if (!SaveJsonSerializers.ContainsKey(entityType))
     {
         var serializer = new DataContractJsonSerializer(entityType);
         SaveJsonSerializers.Add(entityType, serializer);
     }
     return(SerializerProvider.DeserializeByJson(SaveJsonSerializers[entityType], entityJson));
 }
        public T GetEntityJsonInstance <T>(string entityJson) where T : class
        {
            Type entityType = typeof(T);

            if (!SaveJsonSerializers.ContainsKey(entityType))
            {
                var serializer = new DataContractJsonSerializer(entityType);
                SaveJsonSerializers.Add(entityType, serializer);
            }
            return((T)SerializerProvider.DeserializeByJson(SaveJsonSerializers[entityType], entityJson));
        }
        public string GetEntityJsonString(object entity)
        {
            if (entity == null)
            {
                return(string.Empty);
            }

            Type entityType = entity.GetType();

            if (entityType == typeof(string) ||
                entityType == typeof(bool))
            {
                return(entity.ToString());
            }
            if (!SaveJsonSerializers.ContainsKey(entityType))
            {
                var serializer = new DataContractJsonSerializer(entityType);
                SaveJsonSerializers.Add(entityType, serializer);
            }
            return(SerializerProvider.SerializeToJson(SaveJsonSerializers[entityType], entity));
        }