Ejemplo n.º 1
0
 private static object ObjectFromXml(SecurityElement elObject)
 {
     if (elObject.Attribute("class") != null)
     {
         ISecurityEncodable securityEncodable = XMLUtil.CreateCodeGroup(elObject) as ISecurityEncodable;
         if (securityEncodable != null)
         {
             securityEncodable.FromXml(elObject);
             return((object)securityEncodable);
         }
     }
     return(new BinaryFormatter().Deserialize((Stream) new MemoryStream(Hex.DecodeHexString(elObject.Attribute("Data")))));
 }
Ejemplo n.º 2
0
        private static object ObjectFromXml(SecurityElement elObject)
        {
            if (elObject.Attribute("class") != null)
            {
                ISecurityEncodable encodable = XMLUtil.CreateCodeGroup(elObject) as ISecurityEncodable;
                if (encodable != null)
                {
                    encodable.FromXml(elObject);
                    return(encodable);
                }
            }
            MemoryStream    serializationStream = new MemoryStream(Hex.DecodeHexString(elObject.Attribute("Data")));
            BinaryFormatter formatter           = new BinaryFormatter();

            return(formatter.Deserialize(serializationStream));
        }
Ejemplo n.º 3
0
        private static Object ObjectFromXml(SecurityElement elObject)
        {
            BCLDebug.Assert(elObject != null, "You need to pass in a security element");

            if (elObject.Attribute("class") != null)
            {
                ISecurityEncodable encodableObj = XMLUtil.CreateCodeGroup(elObject) as ISecurityEncodable;
                if (encodableObj != null)
                {
                    encodableObj.FromXml(elObject);
                    return(encodableObj);
                }
            }

            string          objectData = elObject.Attribute("Data");
            MemoryStream    stream     = new MemoryStream(Hex.DecodeHexString(objectData));
            BinaryFormatter formatter  = new BinaryFormatter();

            return(formatter.Deserialize(stream));
        }