Example #1
0
        public void execute(string path, List <UserControl> userControls, List <DrawLine> drawedLines)
        {
            DataContractJsonSerializer dataContractSerializer;

            using (MemoryStream memoryStream = new MemoryStream())
            {
                dataContractSerializer = new DataContractJsonSerializer(typeof(SerializableContext),
                                                                        new Type[] { typeof(SerializableContext), typeof(DrawLine) });
                dataContractSerializer.WriteObject(memoryStream, FillSerializebleContext.fill(userControls, drawedLines));
                string temp = Encoding.UTF8.GetString(memoryStream.ToArray());
                File.WriteAllText(path, temp);
            }
        }
Example #2
0
        public void execute(string path, List <UserControl> userControls, List <DrawLine> drawedLines)
        {
            XmlSerializer formatterForUserControls;


            using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
            {
                formatterForUserControls = new XmlSerializer
                                               (typeof(SerializableContext),
                                               new Type[] { typeof(SerializableContext), typeof(DrawLine) });

                formatterForUserControls.Serialize(fs,
                                                   FillSerializebleContext.fill(userControls, drawedLines));
            }
        }