コード例 #1
0
        public static DocComments Load()
        {
            DocComments result = null;

            try
            {
                var reader = new XmlSerializer(typeof(DocComments));
                using (var file = new StreamReader(filename))
                {
                    // Deserialize the content of the file into a Book object.
                    result = (DocComments)reader.Deserialize(file);
                }
            }
            catch
            {
            }
            if (result == null)
            {
                result = new DocComments()
                {
                    Comments = new Comment[0]
                }
            }
            ;

            return(result);
        }
    }
コード例 #2
0
        public static void Save(DocComments comments)
        {
            var sw  = new StreamWriter(filename);
            var ser = new XmlSerializer(comments.GetType());

            ser.Serialize(sw, comments);
            sw.Close();
        }