private static void AddChild1(XmlData root) { var child1 = new XmlData("Child1"); child1.AddAttribute("Attr1", "Value with space"); child1.AddAttribute("Attr2", "Value2"); root.AddChild(child1); }
public static void CreateImageAndContentMetaData(string filePath, Size pixelSize, XmlData image) { CreateImage(filePath, pixelSize); image.AddAttribute("FileSize", new FileInfo(filePath).Length); image.AddAttribute("PixelSize", pixelSize.ToString()); }
protected override void LoadData(Stream fileData) { var glyph1 = new XmlData("Glyph"); glyph1.AddAttribute("Character", ' '); glyph1.AddAttribute("UV", "0 0 1 16"); glyph1.AddAttribute("AdvanceWidth", "7.34875"); glyph1.AddAttribute("LeftBearing", "0"); glyph1.AddAttribute("RightBearing", "4.21875"); var glyph2 = new XmlData("Glyph"); glyph2.AddAttribute("Character", 'a'); glyph2.AddAttribute("UV", "0 0 1 16"); glyph2.AddAttribute("AdvanceWidth", "7.34875"); glyph2.AddAttribute("LeftBearing", "0"); glyph2.AddAttribute("RightBearing", "4.21875"); var glyphs = new XmlData("Glyphs").AddChild(glyph1).AddChild(glyph2); var kerningPair = new XmlData("Kerning"); kerningPair.AddAttribute("First", " "); kerningPair.AddAttribute("Second", "a"); kerningPair.AddAttribute("Distance", "1"); var kernings = new XmlData("Kernings"); kernings.AddChild(kerningPair); var bitmap = new XmlData("Bitmap"); bitmap.AddAttribute("Name", "Verdana12Font"); bitmap.AddAttribute("Width", "128"); bitmap.AddAttribute("Height", "128"); Data = new XmlData("Font"); Data.AddAttribute("Family", "Verdana"); Data.AddAttribute("Size", "12"); Data.AddAttribute("Style", "AddOutline"); Data.AddAttribute("LineHeight", "16"); Data.AddChild(bitmap).AddChild(glyphs).AddChild(kernings); InitializeDescriptionAndMaterial(); }
private static XmlData CreateSpawnPoint() { var xmlData = new XmlData("SpawnPoint"); xmlData.AddAttribute("Name", "Spawn0"); xmlData.AddAttribute("Position", "2, 4"); return(xmlData); }
private static XmlData CreateExitPoint() { var xmlData = new XmlData("ExitPoint"); xmlData.AddAttribute("Name", "Exit0"); xmlData.AddAttribute("Position", "13, 4"); return(xmlData); }
private static void AddChild2(XmlData root) { var child2 = new XmlData("Child2"); child2.AddAttribute("Attr3", "Value3"); child2.AddAttribute("Attr4", "Value4"); child2.AddChild(new XmlData("Grandchild")); root.AddChild(child2); }
private static XmlData CreateTestGroup(string groupName, string formation) { var testGroup = new XmlData("Group"); testGroup.AddAttribute("Name", groupName); testGroup.AddAttribute("CreepTypeList", formation); testGroup.AddAttribute("SpawnIntervalList", "0.5"); return testGroup; }
private static XmlData CreateTestAdjustment() { var xmlData = new XmlData("TestAdjustment"); xmlData.AddAttribute("Attribute", "Hp"); xmlData.AddAttribute("Resist", ""); xmlData.AddAttribute("Adjustment", -100.0f); return(xmlData); }
public static XmlData CreateProjectMetaData(string projectName, string platformName) { var data = new XmlData(typeof(ContentMetaData).Name); data.AddAttribute("Name", projectName); data.AddAttribute("Type", "Scene"); data.AddAttribute("LastTimeUpdated", DateTime.Now.GetIsoDateTime()); data.AddAttribute("ContentDeviceName", platformName); return data; }
private static XmlData CreateTestGroup(string groupName, string formation) { var testGroup = new XmlData("Group"); testGroup.AddAttribute("Name", groupName); testGroup.AddAttribute("CreepTypeList", formation); testGroup.AddAttribute("SpawnIntervalList", "0.5"); return(testGroup); }
private static XmlData CreateAnimationNode() { var animation = new XmlData("ContentMetaData"); animation.AddAttribute("Name", "TestAnimation"); animation.AddAttribute("Type", "ImageAnimation"); var frame1 = CreateImageEntryAndFile("ImageAnimation01", new Size(64, 64)); var frame2 = CreateImageEntryAndFile("ImageAnimation02", new Size(64, 64)); return animation.AddChild(frame1).AddChild(frame2); }
private static XmlData CreateKerningPair(string name) { var xmlData = new XmlData(name); xmlData.AddAttribute("First", " "); xmlData.AddAttribute("Second", "a"); xmlData.AddAttribute("Distance", "1"); return(xmlData); }
private static XmlData CreateBitmap(string name) { var xmlData = new XmlData(name); xmlData.AddAttribute("Name", "Verdana12Font"); xmlData.AddAttribute("Width", "128"); xmlData.AddAttribute("Height", "128"); return(xmlData); }
private static XmlData CreateCreepData(string name, string type, string hp) { var testCreep = new XmlData("CreepData"); testCreep.AddAttribute("Name", name); testCreep.AddAttribute("Type", type); testCreep.AddAttribute("MaxHp", hp); return(testCreep); }
private static XmlData CreateModifier(string acid, string fire, string water) { var testModifier = new XmlData("Modifiers"); testModifier.AddAttribute("Acid", acid); testModifier.AddAttribute("Fire", fire); testModifier.AddAttribute("Water", water); return(testModifier); }
private static XmlData CreateDragonRangeBuff() { var xmlData = new XmlData("DragonRangeMultiplier"); xmlData.AddAttribute("Attribute", "Range"); xmlData.AddAttribute("Multiplier", 1.25f); xmlData.AddAttribute("Addition", 0.0f); xmlData.AddAttribute("Duration", 0.0f); return(xmlData); }
private static XmlData CreateFont(string name) { var xmlData = new XmlData(name); xmlData.AddAttribute("Family", "Verdana"); xmlData.AddAttribute("Size", "12"); xmlData.AddAttribute("Style", "AddOutline"); xmlData.AddAttribute("LineHeight", "16"); return(xmlData); }
private static XmlData CreatePiggyBankPayDayMultiplierBuff() { var xmlData = new XmlData("PiggyBankPayDayGoldMultiplier"); xmlData.AddAttribute("Attribute", "Gold"); xmlData.AddAttribute("Multiplier", 1.5f); xmlData.AddAttribute("Addition", 0.0f); xmlData.AddAttribute("Duration", 5.0f); return(xmlData); }
private static XmlData CreateTestGoldBuff() { var xmlData = new XmlData("TestGoldBuff"); xmlData.AddAttribute("Attribute", "Gold"); xmlData.AddAttribute("Multiplier", 2.0f); xmlData.AddAttribute("Addition", -3.0f); xmlData.AddAttribute("Duration", 5.0f); return(xmlData); }
private static XmlData CreatePenguinAttackFrequencyBuff() { var xmlData = new XmlData("PenguinAttackFrequencyMultiplier"); xmlData.AddAttribute("Attribute", "AttackFrequency"); xmlData.AddAttribute("Multiplier", 1.3333f); xmlData.AddAttribute("Addition", 0.0f); xmlData.AddAttribute("Duration", 0.0f); return(xmlData); }
private static XmlData CreateTestHpBuff() { var xmlData = new XmlData("TestHpBuff"); xmlData.AddAttribute("Attribute", "Hp"); xmlData.AddAttribute("Multiplier", 3.0f); xmlData.AddAttribute("Addition", 4.0f); xmlData.AddAttribute("Duration", 6.0f); return(xmlData); }
private static void AddBasicMetaDataValues(XmlData xmlMetaData, ContentMetaData metaData) { xmlMetaData.AddAttribute("Name", metaData.Name); xmlMetaData.AddAttribute("Type", metaData.Type); xmlMetaData.AddAttribute("LastTimeUpdated", metaData.LastTimeUpdated.GetIsoDateTime()); if (metaData.LocalFilePath == null) return; xmlMetaData.AddAttribute("LocalFilePath", metaData.LocalFilePath); xmlMetaData.AddAttribute("FileSize", metaData.FileSize); }
public XmlData BuildXmlData() { var xml = new XmlData("Level"); xml.AddAttribute("Name", "TestName"); xml.AddAttribute("Size", level.Size); AddPoints(xml, LevelTileType.SpawnPoint); AddPoints(xml, LevelTileType.ExitPoint); xml.AddChild("Map", level.ToTextForXml()); AddWaves(xml); return xml; }
private static XmlData CreateAnimationNode() { var animation = new XmlData("ContentMetaData"); animation.AddAttribute("Name", "TestAnimation"); animation.AddAttribute("Type", "ImageAnimation"); var frame1 = CreateImageEntryAndFile("ImageAnimation01", new Size(64, 64)); var frame2 = CreateImageEntryAndFile("ImageAnimation02", new Size(64, 64)); return(animation.AddChild(frame1).AddChild(frame2)); }
private void AddPoints(XmlData xml, LevelTileType pointType) { int counter = 0; foreach (var point in FindPoints(pointType)) { var pointXml = new XmlData(pointType.ToString()); pointXml.AddAttribute("Name", pointType.ToString().Replace("Point", "") + (counter++)); pointXml.AddAttribute("Position", point); xml.AddChild(pointXml); } }
private static XmlData CreateGlyph(string name, char character) { var xmlData = new XmlData(name); xmlData.AddAttribute("Character", character); xmlData.AddAttribute("UV", "0 0 1 16"); xmlData.AddAttribute("AdvanceWidth", "7.34875"); xmlData.AddAttribute("LeftBearing", "0"); xmlData.AddAttribute("RightBearing", "4.21875"); return(xmlData); }
private static Stream CreateMockGameLevel() { var xmlData = new XmlData("Level"); xmlData.AddAttribute("Name", "TestGameLevelInfo"); xmlData.AddAttribute("Size", "16, 10"); xmlData.AddChild(CreateSpawnPoint()); xmlData.AddChild(CreateExitPoint()); xmlData.AddChild("Map", KidsRoomMapInfo()); xmlData.AddChild("Wave", CreateWave()); return(new XmlFile(xmlData).ToMemoryStream()); }
public XmlData BuildXmlData() { var xml = new XmlData("Level"); xml.AddAttribute("Name", "TestName"); xml.AddAttribute("Size", level.Size); AddPoints(xml, LevelTileType.SpawnPoint); AddPoints(xml, LevelTileType.ExitPoint); xml.AddChild("Map", level.ToTextForXml()); AddWaves(xml); return(xml); }
private static XmlData CreateTestXmlData() { var root = new XmlData("Root"); var child1 = new XmlData("Child1", root); child1.AddAttribute("Attr1", "Value with space"); child1.AddAttribute("Attr2", "Value2"); var child2 = new XmlData("Child2", root); child2.AddAttribute("Attr3", "Value3"); child2.AddAttribute("Attr4", "Value4"); new XmlData("Grandchild", child2); return root; }
private void AddAppToStorageData(AppInfo app) { var appDataNode = new XmlData("App"); appDataNode.AddAttribute(XmlAttributeNameOfFileName, Path.GetFileName(app.FilePath)); appDataNode.AddAttribute(XmlAttributeNameOfPlatform, app.Platform); appDataNode.AddAttribute(XmlAttributeNameOfAppGuid, app.AppGuid); appDataNode.AddAttribute(XmlAttributeNameOfBuildDate, app.BuildDate); appDataNode.AddAttribute(XmlAttributeNameOfSolutionFilePath, app.SolutionFilePath); storageData.AddChild(appDataNode); UpdateStorageDataInSettings(); }
public void RemoveAttribute() { var root = new XmlData("root"); root.AddAttribute("attribute1", "value1"); root.AddAttribute("attribute2", "value2"); root.AddAttribute("attribute1", "value3"); root.RemoveAttribute("attribute1"); Assert.AreEqual(1, root.Attributes.Count); root.RemoveAttribute("attribute3"); Assert.AreEqual(1, root.Attributes.Count); }
private static XmlData CreateXmlEntryAndFile() { var xml = new XmlData("ContentMetaData"); xml.AddAttribute("Name", "Test").AddAttribute("Type", "Xml"); const string Filename = "Test.xml"; using (var textWriter = File.CreateText(Path.Combine(ContentProjectDirectoryName, Filename))) textWriter.WriteLine("<Test></Test>"); xml.AddAttribute("LocalFilePath", Filename); xml.AddAttribute("LastTimeUpdated", DateTime.Now); xml.AddAttribute("PlatformFileId", --platformFileId); return xml; }
private static XmlData CreateImageEntryAndFile(string name, Size pixelSize) { var image = new XmlData("ContentMetaData"); image.AddAttribute("Name", name); image.AddAttribute("Type", "Image"); string filename = name + ".png"; string filePath = Path.Combine(ContentProjectDirectoryName, filename); ContentDiskTestsExtensions.CreateImageAndContentMetaData(filePath, pixelSize, image); image.AddAttribute("LocalFilePath", filename); image.AddAttribute("LastTimeUpdated", DateTime.Now); image.AddAttribute("PlatformFileId", --platformFileId); return image; }
private static void CreateContentMetaDataAndRealFiles() { Directory.CreateDirectory(ContentProjectDirectoryName); var root = new XmlData("ContentMetaData"); root.AddAttribute("Name", "DeltaEngine.Content.Disk.Tests"); root.AddAttribute("Type", "Scene"); root.AddChild(CreateImageEntryAndFile("DeltaEngineLogo", new Size(128, 128))); root.AddChild(CreateImageEntryAndFile("SmallImage", new Size(32, 32))); root.AddChild(CreateAnimationNode()); root.AddChild(CreateXmlEntryAndFile()); var contentMetaData = new XmlFile(root); contentMetaData.Save(Path.Combine(ContentProjectDirectoryName, "ContentMetaData.xml")); }
public static void AddMetaDataEntry(this XmlData projectMetaData, ContentMetaData contentEntry) { var newEntry = new XmlData(typeof(ContentMetaData).Name); AddBasicMetaDataValues(newEntry, contentEntry); if (contentEntry.Language != null) newEntry.AddAttribute("Language", contentEntry.Language); if (contentEntry.PlatformFileId != 0) newEntry.AddAttribute("PlatformFileId", contentEntry.PlatformFileId); foreach (KeyValuePair<string, string> valuePair in contentEntry.Values) newEntry.AddAttribute(valuePair.Key, valuePair.Value); projectMetaData.AddChild(newEntry); }
private static XmlData CreateShallowTestXmlData() { var root = new XmlData("Root"); var child1 = new XmlData("Child1") { Value = "Tom" }; child1.AddAttribute("Attr1", "Value1"); child1.AddAttribute("Attr2", "Value2"); root.AddChild(child1); root.AddChild(null); var child2 = new XmlData("Child2"); child2.AddAttribute("Attr3", "Value3"); child2.AddAttribute("Attr4", "Value4"); root.AddChild(child2); return root; }
private static XmlData CreateXmlEntryAndFile() { var xml = new XmlData("ContentMetaData"); xml.AddAttribute("Name", "Test").AddAttribute("Type", "Xml"); const string Filename = "Test.xml"; using (var textWriter = File.CreateText(Path.Combine(ContentProjectDirectoryName, Filename))) textWriter.WriteLine("<Test></Test>"); xml.AddAttribute("LocalFilePath", Filename); xml.AddAttribute("LastTimeUpdated", DateTime.Now); xml.AddAttribute("PlatformFileId", --platformFileId); return(xml); }
private static XmlData CreateImageEntryAndFile(string name, Size pixelSize) { var image = new XmlData("ContentMetaData"); image.AddAttribute("Name", name); image.AddAttribute("Type", "Image"); string filename = name + ".png"; string filePath = Path.Combine(ContentProjectDirectoryName, filename); ContentDiskTestsExtensions.CreateImageAndContentMetaData(filePath, pixelSize, image); image.AddAttribute("LocalFilePath", filename); image.AddAttribute("LastTimeUpdated", DateTime.Now); image.AddAttribute("PlatformFileId", --platformFileId); return(image); }
public void AddAttribute() { var root = new XmlData("root"); root.AddAttribute("attribute", "value"); Assert.AreEqual(1, root.Attributes.Count); Assert.AreEqual(new XmlAttribute("attribute", "value"), root.Attributes[0]); }
public void AddAttributeObject() { var root = new XmlData("root"); root.AddAttribute("attribute", DayOfWeek.Friday); Assert.AreEqual(1, root.Attributes.Count); Assert.AreEqual(new XmlAttribute("attribute", "Friday"), root.Attributes[0]); }
private static void ImportXmlData(XmlNode node, ref XmlData data) { data.SetNodeName(node.Name); var attributes = node.Attributes; if (null != attributes) { int attriCount = attributes.Count; for (int idx = 0; idx < attriCount; ++idx) { var attribute = attributes[idx]; data.AddAttribute(attribute.Name, attribute.Value); } } var childNodes = node.ChildNodes; if (null == childNodes) { return; } int nodeCount = childNodes.Count; for (int idx = 0; idx < nodeCount; ++idx) { var childNode = childNodes.Item(idx); XmlData childData = new XmlData(); ImportXmlData(childNode, ref childData); data.AddChild(childData); } }
private static void SetCommand(XmlData root, string command, IEnumerable<Trigger> triggers) { var child = new XmlData("Command"); child.AddAttribute("Name", command); foreach (Trigger trigger in triggers) SetTrigger(trigger, child); root.AddChild(child); }
public void UpdateExistingAttributeWithSameValue() { var root = new XmlData("root"); root.AddAttribute("number", "123"); root.UpdateAttribute("number", "123"); Assert.AreEqual("123", root.GetAttributeValue("number")); }
public void GetAttributeValueAsInteger() { var root = new XmlData("root"); root.AddAttribute("number", "123"); Assert.AreEqual(123, root.GetAttributeValue("number", 0)); Assert.AreEqual("", root.GetAttributeValue("nonexistant", "")); }
public static void SaveToMapsXml(string filename, List<Map> maps) { XmlData xml=new XmlData(filename, true); maps.Sort(); XmlNode mapsnode=xml.AddRoot("maps"); foreach(Map i in maps) { XmlNode mapNode=xml.AddElement(mapsnode, "map"); xml.AddAttribute(mapNode, "id", i.ID); xml.AddAttribute(mapNode, "name", i.Name); } xml.Save(); }
private static XmlData CreateDeepTestXmlData() { XmlData root = CreateShallowTestXmlData(); var grandchild = new XmlData("Grandchild"); grandchild.AddAttribute("Attr5", "Value5"); root.Children[1].AddChild(grandchild); return root; }
private static Settings GetMockSettingsWithAlreadyBuiltApps() { var settings = new MockSettings(); var storageData = new XmlData("BuiltApps"); storageData.AddAttribute("StoragePath", storageData.Name); settings.SetValue(storageData.Name, storageData); var appsStorage = new AppsStorage(settings); appsStorage.AddApp(new WindowsAppInfo("Rebuildable app", Guid.NewGuid(), DateTime.Now) { SolutionFilePath = "A.sln" }); appsStorage.AddApp(new WindowsAppInfo("Non-Rebuildable app ", Guid.NewGuid(), DateTime.Now)); return settings; }
private static XmlData CreateTestTower(string name, string type, string shotType) { var testTower = new XmlData("TowerData"); testTower.AddAttribute("Name", name); testTower.AddAttribute("Type", type); testTower.AddAttribute("AttackType", shotType); testTower.AddAttribute("Range", "3.0"); testTower.AddAttribute("AttackFrequency", "0.5"); testTower.AddAttribute("AttackDamage", "35.0"); return testTower; }
public XmlData AsXmlData() { var xml = new XmlData("Wave"); xml.AddAttribute("WaitTime", WaitTime); xml.AddAttribute("SpawnInterval", SpawnInterval); xml.AddAttribute("ShortName", ShortName); xml.AddAttribute("MaxTime", MaxTime); xml.AddAttribute("MaxSpawnItems", MaxSpawnItems); xml.AddAttribute("SpawnTypeList", SpawnTypeList.ToText()); return xml; }
private static void CreateImageFile(XmlData image, string filename, Size pixelSize) { var newBitmap = new Bitmap((int)pixelSize.Width, (int)pixelSize.Height, PixelFormat.Format32bppArgb); for (int y = 0; y < newBitmap.Height; y++) for (int x = 0; x < newBitmap.Width; x++) newBitmap.SetPixel(x, y, Color.White); if (filename == "DeltaEngineLogo.png") newBitmap.SetPixel(50, 70, Color.FromArgb(0, 0, 0, 0)); string filePath = Path.Combine("Content", filename); newBitmap.Save(filePath); image.AddAttribute("FileSize", new FileInfo(filePath).Length); image.AddAttribute("PixelSize", pixelSize.ToString()); }
public void GetAttributeValue() { var root = new XmlData("root"); root.AddAttribute("attribute", "value"); Assert.AreEqual("value", root.GetAttributeValue("attribute")); Assert.AreEqual("", root.GetAttributeValue("attribute2")); }