Exemplo n.º 1
0
        public void TestXmlDocumentSeiralization()
        {
            var objTree = new ObjectTree
            {
                Foo = "Foo1",
                Bar = 1,
                Nested = new List<object>()
            };

            objTree.Nested.AddRange(new[]
                {
                    new ObjectTree{ Foo = "Foo2", Bar = 2},
                    new ObjectTree{ Foo = "Foo3", Bar = 3},
                });

            XmlDocument xmlDoc = objTree.ToXmlDocument();
            string xml = xmlDoc.ToXml();
            Assert.IsNotNull(xml);

            XmlNode parentElem = xmlDoc.DocumentElement;
            objTree.SerializeInto(parentElem);

            xml = xmlDoc.ToXml();
            Assert.IsNotNull(xml);

            xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(xml);
            ObjectTree newObjectTree = xmlDoc.Deserialize<ObjectTree>();
            Assert.IsNotNull(newObjectTree);

            ObjectTree nested = newObjectTree.AnyXml.Deserialize<ObjectTree>();
            Assert.AreEqual(1, nested.Bar);
            Assert.AreEqual(objTree.Nested.Count, nested.Nested.Count);
        }
Exemplo n.º 2
0
		public static LoggerConfig Load(string xmlFilePath = null) {
			if (xmlFilePath == null) {
				xmlFilePath = c_xmlFilePath;
			}
			var doc = new XmlDocument();
			doc.Load(xmlFilePath);
			var nav = doc.CreateNavigator();
			var ns = nav.GetNamespacesInScope(new XmlNamespaceScope());
			return doc.Deserialize<LoggerConfig>();
		}
Exemplo n.º 3
0
        public void Load(string levelName)
        {
            if (levelName.StartsWith("JAFM_WORKAROUND_SAVE:")) {
                string[] split = levelName.Split(new char[] {':'});
                Save(split[1], (split.Length > 2) ? bool.Parse(split[2]) : false);
                return;
            }
            if (levelName == "JAFM_WORKAROUND_CHANGELEVEL") {
                ChangeLevel(GameLevelManagerHelper.ChangeLevel_);
                return;
            }

            if (tmpLevel != null) {
                ClearArtSatellites();

                oldLevel = levelData;
                levelData = tmpLevel;
                tmpLevel = null;

                levelData.OnDeserialization();
                return;
            }

            levelName = FEZMod.ProcessLevelName(levelName);

            string filePath_ = ("Resources\\levels\\"+(levelName.ToLower())).Replace("\\", Path.DirectorySeparatorChar.ToString()).Replace("/", Path.DirectorySeparatorChar.ToString())+".";

            string filePathFMB = filePath_ + "fmb";
            FileInfo fileFMB = new FileInfo(filePathFMB);
            if (fileFMB.Exists) {
                ModLogger.Log("FEZMod", "Loading level from FMB: "+levelName);

                using (FileStream fs = new FileStream(fileFMB.FullName, FileMode.Open)) {
                    throw new FormatException("FEZMod can't load FMB files yet.");
                }

                return;
            }

            string filePathXML = filePath_+"xml";
            FileInfo fileXML = new FileInfo(filePathXML);
            if (!fileXML.Exists) {
                if (MemoryContentManager.AssetExists("LEVELS/"+levelName)) {
                    orig_Load(levelName);
                } else {
                    //Fallback: Spawn at the original VILLAGEVILLE_3D if the level wasn't found at all
                    ModLogger.Log("FEZMod", "Level not found: " + levelName + "; Falling back to the original VILLAGEVILLE_3D...");
                    orig_Load("VILLAGEVILLE_3D");
                }
                FEZMod.ProcessLevelData(levelData);
                GameLevelManagerHelper.Level = levelData;
                return;
            }

            ModLogger.Log("FEZMod", "Loading level from XML: "+levelName);

            ClearArtSatellites();

            oldLevel = levelData;

            FileStream fis = new FileStream(fileXML.FullName, FileMode.Open);
            XmlReader xmlReader = XmlReader.Create(fis);
            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.Load(xmlReader);
            xmlReader.Close();
            fis.Close();

            ContentManager cm = CMProvider.GetForLevel(levelName);
            levelData = (Level) xmlDocument.Deserialize(null, cm, true);
            levelData.Name = levelName;

            LevelSaveData save = GameState.SaveData.ThisLevel;
            if (save != null) {
                save.FirstVisit = false;
            }

            FEZMod.ProcessLevelData(levelData);
            GameLevelManagerHelper.Level = levelData;
        }
 public void ToXML2()
 {
     Assert.NotNull(TestItem.Serialize(new XMLSerializer(), FileLocation: @".\Testing\Test.xml"));
     XmlDocument Document = new XmlDocument();
     Document.LoadXml(new FileInfo(@".\Testing\Test.xml").Read());
     TestClass Temp = Document.Deserialize<TestClass>(new XMLSerializer());
     Assert.Equal(123, Temp.ID);
     Assert.Equal("This is test content", Temp.Content);
 }