类Cloneable<T>实现了LiteMDA.Common.ICloneable<T>以及System.ICloneable接口,可以作为基类为实体类提供Clone()支持。因为还是不得不基于反射,虽然加入了部分缓存,性能肯定还是会受影响,如果对性能要求较高则还需为实体类手动实现LiteMDA.Common.ICloneable<T>和System.ICloneable接口。实际的实现中,Cloneable<T>隐藏了object System.ICloneable.Clone()而只暴露T LiteMDA.Common.ICloneable<T>.Clone()。
由于实际使用中,对于应用于实体类来讲,原则上要么是值类型或者string类型,要么就必须实现LiteMDA.Common.ICloneable<T>接口,因此,用于实体类的基类时,Cloneable<T>原则上不会发生Clone出的对象内的某个成员和被Clone成员指向同一个对象实例的情况。
不过如果对于其它对类型没有以上限制的地方请慎用,一般会报错!
ICloneable.cs












Cloneable.cs


















































































//文章结束