using System; using System.Collections.Generic; using System.Linq; using System.Net.Http.Headers; using System.Runtime.Serialization.Formatters.Binary; using System.Text; using System.Threading.Tasks; namespace Shaker.Models { public interface IModel : ICloneable { } public abstract class BaseModel : IModel { public int Id = 0; public abstract object Clone(); } public static class IModelTools { public static TModel CloneBase(this TModel model) where TModel : IModel { return Newtonsoft.Json.JsonConvert.DeserializeObject(Newtonsoft.Json.JsonConvert.SerializeObject(model)) ?? Activator.CreateInstance(); } } }