Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
                }
            }
        }