/// <summary> /// Creates an instance of Products from a JSON string /// </summary> /// <param name="json">The JSON string</param> /// <returns>A Products object instance</returns> public static Products FromJson(string json) { List <DataLayer.Product.SerializableProduct> zs = Newtonsoft.Json.JsonConvert.DeserializeObject <List <DataLayer.Product.SerializableProduct> >(json); Products tmp = new Products(); foreach (DataLayer.Product.SerializableProduct z in zs) { tmp.Add(Product.FromJson(Newtonsoft.Json.JsonConvert.SerializeObject(z))); } if (zs.Count > 0) { Encryption64 decryptor = new Encryption64(); tmp._connectionString = decryptor.Decrypt(zs[0].SerializationConnectionString, DataLayer.Universal.LayerGenEncryptionKey); } return(tmp); }
/// <summary> /// Creates an instance of Products from an XML string /// </summary> /// <param name="xml">The XML string</param> /// <returns>A Products object instance</returns> public static Products FromXml(string xml) { System.Xml.Serialization.XmlSerializer xType = new System.Xml.Serialization.XmlSerializer(typeof(List <DataLayer.Product.SerializableProduct>)); List <DataLayer.Product.SerializableProduct> zc; Products tmp = new Products(); using (System.IO.StringReader sr = new System.IO.StringReader(xml)) { zc = (List <DataLayer.Product.SerializableProduct>)xType.Deserialize(sr); } foreach (DataLayer.Product.SerializableProduct z in zc) { tmp.Add(Product.FromJson(Newtonsoft.Json.JsonConvert.SerializeObject(z))); } if (zc.Count > 0) { Encryption64 decryptor = new Encryption64(); tmp._connectionString = decryptor.Decrypt(zc[0].SerializationConnectionString, DataLayer.Universal.LayerGenEncryptionKey); } return(tmp); }