public static dynamic DeserializePlist(this ICakeContext context, FilePath file) { using (var stream = File.OpenRead(file.FullPath)) { var document = XDocument.Load(stream); return(PlistConvert.Deserialize(document.Root)); } }
public static dynamic DeserializePlist(this ICakeContext context, FilePath path) { var file = context.FileSystem.GetFile(path); using (var stream = file.OpenRead()) { var document = XDocument.Load(stream); return(PlistConvert.Deserialize(document.Root)); } }
public static void SerializePlist(this ICakeContext context, FilePath file, object value) { var doc = PlistConvert.SerializeDocument(value); string result; using (var sw = new MemoryStream()) using (var strw = new StreamWriter(sw)) { doc.Save(strw, SaveOptions.DisableFormatting); result = Encoding.UTF8.GetString(sw.ToArray()); } File.WriteAllText(file.FullPath, result); }
public static void SerializePlist(this ICakeContext context, FilePath path, object value) { var doc = PlistConvert.SerializeDocument(value); string result; using (var sw = new MemoryStream()) using (var strw = new StreamWriter(sw)) { doc.Save(strw); result = new UTF8Encoding(false).GetString(sw.ToArray()); } var file = context.FileSystem.GetFile(path); using (var stream = file.OpenWrite()) { using (var write = new StreamWriter(stream, new UTF8Encoding(false), 1024, true)) { write.Write(result); } } }
public static string SerializePlist(this ICakeContext context, object value) { return(PlistConvert.Serialize(value).ToString()); }
public static dynamic DeserializePlist(this ICakeContext context, string xml) { return(PlistConvert.Deserialize(XElement.Parse(xml))); }