Ejemplo n.º 1
0
        public static void SetStorageFile(string fileName)
        {
            if (!File.Exists(fileName))
            {
                var defaultDatabase = new ApplicationDatabase
                {
                    MyInt      = 11,
                    MyTextData = "The quick brown fox jumped over the lazy dog.",
                    NetWorth   = 25.21M,
                };
                using (var stream = new FileStream(fileName, FileMode.CreateNew))
                {
                    XamlServices.Save(stream, defaultDatabase);
                }
            }

            using (var stream = new FileStream(fileName, FileMode.Open))
            {
                MyData = (ApplicationDatabase)XamlServices.Load(stream);
            }
        }
Ejemplo n.º 2
0
        public static void SetStorageFile(string fileName)
        {
            if (!File.Exists(fileName))
            {
                var defaultDatabase = new ApplicationDatabase
                {
                    MyInt = 11,
                    MyTextData = "The quick brown fox jumped over the lazy dog.",
                    NetWorth = 25.21M,
                };
                using (var stream = new FileStream(fileName, FileMode.CreateNew))
                {
                    XamlServices.Save(stream, defaultDatabase);
                }
            }

            using (var stream = new FileStream(fileName, FileMode.Open))
            {
                MyData = (ApplicationDatabase) XamlServices.Load(stream);
            }
        }