コード例 #1
0
        public static MusicDataStore TestData()
        {
            MusicDataStore result = new MusicDataStore();

            //create same test date set as used for LINQ example
            return(result);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            MusicDataStore musicData = MusicDataStore.TestData();

            XmlSerializer formatter = new XmlSerializer(typeof(MusicDataStore));

            using (FileStream outputStream =
                       new FileStream("MusicTracks.xml", FileMode.OpenOrCreate, FileAccess.Write))
            {
                formatter.Serialize(outputStream, musicData);
            }

            MusicDataStore inputData;

            using (FileStream inputStream =
                       new FileStream("MusicTracks.xml", FileMode.Open, FileAccess.Read))
            {
                inputData = (MusicDataStore)formatter.Deserialize(inputStream);
            }
        }