1234567891011121314151617181920212223242526272829 |
- using System;
- using System.IO;
- using System.Runtime.Serialization;
- using System.Runtime.Serialization.Formatters.Binary;
- namespace WWPipeLine.Commons
- {
- /// <summary>
- /// 类的扩展属性
- /// </summary>
- public class CloneExtended : ICloneable
- {
- public static object Clone(object obj)
- {
- BinaryFormatter Formatter = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.Clone));
- MemoryStream stream = new MemoryStream();
- Formatter.Serialize(stream, obj);
- stream.Position = 0;
- object clonedObj = Formatter.Deserialize(stream);
- stream.Close();
- return clonedObj;
- }
- public object Clone()
- {
- return null;
- }
- }
- }
|