Exemplo n.º 1
0
        public static TEntity Clone <TEntity>(this TEntity source, JsonSerializerSettings settings = null)
        {
            if (source == null)
            {
                return(source);
            }

            if (settings == null)
            {
                settings = JsonAuditSerilizeOptions.Get();
            }

            string  json = JsonConvert.SerializeObject(source, settings);
            TEntity obj  = JsonConvert.DeserializeObject <TEntity>(json, new BooleanJsonConverter());

            return(obj);
        }
Exemplo n.º 2
0
        public static List <TEntity> Clone <TEntity>(this List <TEntity> source, JsonSerializerSettings settings = null)
        {
            if (source == null || source.Count == 0)
            {
                return(source);
            }

            if (settings == null)
            {
                settings = JsonAuditSerilizeOptions.Get();
            }

            List <TEntity> result = new List <TEntity>();

            foreach (var t in source)
            {
                result.Add(t.Clone());
            }

            return(result);
        }