 Data.csģ

76.    using System;
77.    using System.Collections; 
78.    using System.Xml; 
79.    using System.IO; 
80.
81.    namespace PocketDice 
82.    { 
83.
84.    public class HighScoreRecord 
85.    { 
86.        private int _score = -1; 
87.        private string _name = ""; 
88.        private DateTime _date; 
89.
90.        public int Score 
91.        { 
92.            get{return _score;} 
93.            set{_score = value;} 
94.        } 
95.            public string Name 
96.        { 
97.            get{return _name;} 
98.            set{_name = value;} 
99.        } 
100.       public DateTime Date 
101.       { 
102.           get{return _date;} 
103.           set{_date = value;} 
104.    } 
105.
106.    public HighScoreRecord() 
107.    { 
108.    } 
109.
110.    public HighScoreRecord(XmlTextReader xml) 
111.    { 
112.        // ĶXmlTextReader 
113.        _score = int.Parse(xml.GetAttribute("score")); 
114.        _name = xml.GetAttribute("name"); 
115.        _date = XmlConvert.ToDateTime(xml.GetAttribute("date"),
"yyyy-MM-dd"); 
116.    } 
117.
118.    public HighScoreRecord(HighScoreRecord source) 
119.    { 
120.          _score = source.Score;
121.          _name = source.Name; 
122.          _date = source.Date; 
123.    } 
124.
125.    public void WriteXmlRecord(XmlTextWriter xml) 
126.    { 
127.        xml.WriteStartElement("HighScore"); 
128.
129.        xml.WriteStartAttribute("score",""); 
130.            xml.WriteString(_score.ToString()); 
131.        xml.WriteEndAttribute(); 
132.
133.        xml.WriteStartAttribute("name",""); 
134.            xml.WriteString(_name); 
135.        xml.WriteEndAttribute(); 
136.
137.        xml.WriteStartAttribute("date", ""); 
138.           xml.WriteString(_date.ToString("yyyy-MM-dd")); 
139.        xml.WriteEndAttribute(); 
140.
141.        xml.WriteEndElement(); 
142.    } 
143.
144.  } 
145.
