public ExplorerEvent(ExplorerConfiguration configuration, XmlNode event_node) { foreach (XmlAttribute attribute in event_node.Attributes) { if (attribute.Name == configuration.getEventNameAttr()) { eventName = attribute.Value; } else if (attribute.Name == configuration.getEventStartTimeAttr()) { try { startDate = Convert.ToDateTime(attribute.Value); } catch (FormatException ex) { throw new ExplorerParseXMLException("Start Date is invalid for '" + eventName + "'", ex); } } else if (attribute.Name == configuration.getEventEndTimeAttr()) { try { endDate = Convert.ToDateTime(attribute.Value); } catch (FormatException ex) { throw new ExplorerParseXMLException("End Date is invalid for '" + eventName + "'", ex); } } else { throw new ExplorerParseXMLException("Unknown child node: " + attribute.Name, null); } } if (eventName == null) { throw new ExplorerParseXMLException( "Event Name not supplied for event tag. Node: '" + event_node.OuterXml + "'", null); } foreach (XmlNode childNode in event_node.ChildNodes) { if (childNode.Name == configuration.getEventTagTag()) { eventTags.Add(childNode.InnerText.ToLower()); } } }
public Explorer(String config_name, String file_name) { configuration = new ExplorerConfiguration(config_name); XmlTextReader xmlReader = new XmlTextReader(file_name); if (xmlReader.Read()) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(xmlReader); if (xmlDoc.ChildNodes.Count == 1 && xmlDoc.ChildNodes.Item(0).Name == configuration.getMapTag()) { rootMap = new ExplorerContentMap(configuration, xmlDoc.ChildNodes.Item(0)); } else { throw new ExplorerLoadXMLException("Multiple Root Tags or Root tag not '" + configuration.getMapTag() + "'", null); } } else { throw new ExplorerLoadXMLException("XML Document could not be read", null); } }
public ExplorerRegion(ExplorerConfiguration configuration, XmlNode region_node) { foreach (XmlAttribute attribute in region_node.Attributes) { if (attribute.Name == "name") { name = attribute.Value; } else if(attribute.Name == "defaultimageid") { defaultImageLocalId = attribute.Value; } else if (attribute.Name == "defaulttextid") { defaultTextLocalId = attribute.Value; } } if (name == null) { throw new ExplorerParseXMLException( "Name not supplied for content tag. Node: '" + region_node.OuterXml + "'", null); } foreach (XmlNode childNode in region_node.ChildNodes) { if (childNode.Name == configuration.getEventsTag()) { eventsContainer = new ExplorerEventsContainer(configuration, childNode); } else if (childNode.Name == configuration.getPointsTag()) { pointsContainer = new ExplorerPointsContainer(configuration, childNode); } else if (childNode.Name == configuration.getContentsTag()) { contentsContainer = new ExplorerContentsContainer(configuration, childNode); } } if(defaultImageLocalId != null) { ExplorerContentBase baseContentItem = contentsContainer.getByLocalId(defaultImageLocalId); if(baseContentItem == null) { defaultImageLocalId = null; throw new ExplorerParseXMLException( "Default Image ID provided does not exist in node. Node: '" + region_node.OuterXml + "'", null); } if(!(baseContentItem is ExplorerContentImage)) { defaultImageLocalId = null; throw new ExplorerParseXMLException( "Default Image ID provided does not reference an image. Node: '" + region_node.OuterXml + "'", null); } } if (defaultTextLocalId != null) { ExplorerContentBase baseContentItem = contentsContainer.getByLocalId(defaultTextLocalId); if (baseContentItem == null) { defaultTextLocalId = null; throw new ExplorerParseXMLException( "Default text ID provided does not exist in node. Node: '" + region_node.OuterXml + "'", null); } if (!(baseContentItem is ExplorerContentText)) { defaultTextLocalId = null; throw new ExplorerParseXMLException( "Default text ID provided does not reference an text. Node: '" + region_node.OuterXml + "'", null); } } }