Ejemplo n.º 1
0
 public static T Deserialize <T>(string data) where T : class
 {
     using (var deserializer = new XmlDeserializerHelper())
     {
         var d = new XmlDocument();
         d.LoadXml(data);
         return(deserializer.Deserialize(d) as T);
     }
 }
Ejemplo n.º 2
0
        public static T Clone <T>(T item) where T : class
        {
            using (var serializer = new XmlSerializerHelper {
                IgnoreSerializableAttribute = true
            })
            {
                using (var deserializer = new XmlDeserializerHelper())
                {
                    var dictionary = new Dictionary <Type, Dictionary <int, IEntityClass> >();
                    PropertyComparor.ExtractEntities(item, dictionary);

                    var xmlDocument = serializer.Serialize(item);
                    var clone       = deserializer.Deserialize(xmlDocument, dictionary) as T;
                    return(clone);
                }
            }
        }