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