Example #1
0
        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));
            }
        }
Example #2
0
        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));
            }
        }
Example #3
0
        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);
        }
Example #4
0
        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);
                }
            }
        }
Example #5
0
 public static string SerializePlist(this ICakeContext context, object value)
 {
     return(PlistConvert.Serialize(value).ToString());
 }
Example #6
0
 public static dynamic DeserializePlist(this ICakeContext context, string xml)
 {
     return(PlistConvert.Deserialize(XElement.Parse(xml)));
 }