Пример #1
0
        public static void SaveTutorial(TutorialStorage ts)
        {
            string        pathToSave = Path.Combine(_path, _saveFileName);
            Type          t          = typeof(TutorialStorage);
            Type          t2         = ts.GetType();
            XmlSerializer serializer = new XmlSerializer(typeof(TutorialStorage));//ts.GetType());

            using (FileStream fs = new FileStream(pathToSave, FileMode.OpenOrCreate, FileAccess.Write))
            {
                serializer.Serialize(fs, ts);
            }
        }
Пример #2
0
        public static TutorialStorage LoadTutorial()
        {
            string pathToLoad = Path.Combine(_path, _saveFileName);

            if (!File.Exists(pathToLoad))
            {
                return(new TutorialStorage());
            }

            TutorialStorage ts           = new TutorialStorage();
            XmlSerializer   deserializer = new XmlSerializer(ts.GetType());

            ts = null;
            using (FileStream fs = new FileStream(pathToLoad, FileMode.Open, FileAccess.Read))
            {
                ts = (TutorialStorage)deserializer.Deserialize(fs);
            }

            foreach (Tutorial t in ts.FullTutorials)
            {
                //if (t.Steps.Count > 0)
                //{
                //}
                //else
                //{
                foreach (Step s in t.Steps)
                {
                    foreach (String str in s.StringPath)
                    {
                        string[] array = str.Split('|');
                        s.Path.Add(new TypeIndexAssociation()
                        {
                            ElementType = Type.GetType(array[0], true), Index = Int32.Parse(array[1])
                        });
                    }
                }
                //}
            }

            return(ts);
        }
Пример #3
0
        public static TutorialStorage LoadTutorial()
        {
            string pathToLoad = Path.Combine(_path, _saveFileName);

            if (!File.Exists(pathToLoad))
            {
                return new TutorialStorage();
            }

            TutorialStorage ts = new TutorialStorage();
            XmlSerializer deserializer = new XmlSerializer(ts.GetType());
            ts = null;
            using (FileStream fs = new FileStream(pathToLoad, FileMode.Open, FileAccess.Read))
            {
                ts = (TutorialStorage)deserializer.Deserialize(fs);
            }

            foreach(Tutorial t in ts.FullTutorials)
            {
                //if (t.Steps.Count > 0)
                //{
                //}
                //else
                //{
                    foreach (Step s in t.Steps)
                    {
                        foreach (String str in s.StringPath)
                        {
                            string[] array = str.Split('|');
                            s.Path.Add(new TypeIndexAssociation() { ElementType = Type.GetType(array[0], true), Index = Int32.Parse(array[1]) });
                        }
                    }
                //}
            }

            return ts;
        }
Пример #4
0
 public static void SaveTutorial(TutorialStorage ts)
 {
     string pathToSave = Path.Combine(_path, _saveFileName);
     Type t = typeof(TutorialStorage);
     Type t2 = ts.GetType();
     XmlSerializer serializer = new XmlSerializer(typeof(TutorialStorage));//ts.GetType());
     using (FileStream fs = new FileStream(pathToSave, FileMode.OpenOrCreate, FileAccess.Write))
     {
         serializer.Serialize(fs, ts);
     }
 }