private static void AddResources(ISamResources toContainer, XmlNodeList fromNodes, List <SamResource> storeIn) { Int32 count = fromNodes.Count; XmlNode node; SamResource res = null; XmlAttribute a; Boolean failed = false; for (Int32 i = 0; i < count; i++) { node = fromNodes[i]; switch (node.LocalName) { case "library": case "swf": res = new SamResource(); res.ResourceType = ResourceNodeType.Swf; a = node.Attributes["import"]; if (a != null) { res.File = a.InnerText; } else { failed = true; } if (!failed) { res.File = a.InnerText; } a = node.Attributes["class"]; if (!failed && a != null) { res.Class = a.InnerText; } else if (node.LocalName == "swf") { failed = true; } break; case "ttf": res = new SamFont(); res.ResourceType = ResourceNodeType.Font; a = node.Attributes["import"]; if (a != null) { res.File = a.InnerText; } else { failed = true; } if (!failed) { res.File = a.InnerText; } a = node.Attributes["name"]; if (!failed && a == null) { failed = true; } AddFontRange((SamFont)res, node.ChildNodes); a = node.Attributes["class"]; if (a != null) { res.Class = a.InnerText; } break; case "sound": res = new SamResource(); res.ResourceType = ResourceNodeType.Sound; a = node.Attributes["import"]; if (a != null) { res.File = a.InnerText; } else { failed = true; } if (!failed) { res.File = a.InnerText; } a = node.Attributes["class"]; if (!failed && a != null) { res.Class = a.InnerText; } else { failed = true; } break; case "image": res = new SamResource(); res.ResourceType = ResourceNodeType.Image; a = node.Attributes["import"]; if (a != null) { res.File = a.InnerText; } else { failed = true; } if (!failed) { res.File = a.InnerText; } a = node.Attributes["class"]; if (!failed && a != null) { res.Class = a.InnerText; } else { failed = true; } break; case "binary": res = new SamResource(); res.ResourceType = ResourceNodeType.Binary; a = node.Attributes["import"]; if (a != null) { res.File = a.InnerText; } else { failed = true; } if (!failed) { res.File = a.InnerText; } a = node.Attributes["class"]; if (!failed && a != null) { res.Class = a.InnerText; } else { failed = true; } break; case "composite": res = new SamComposite(); res.ResourceType = ResourceNodeType.Compose; AddResources(res as ISamResources, node.ChildNodes, storeIn); break; } if (failed) { MessageBox.Show(LocaleHelper.GetErrorString( LocaleHelper.INVALID_FILE_ERROR)); return; } toContainer.Resources.Add(res); if (res.ResourceType != ResourceNodeType.Compose) { if (res.Class != null) { storeIn.Add(res); } } } }
private static void AddFontRange(SamFont fontNode, XmlNodeList fromNodes) { }