public SM4Event FindEventInLocation(string eventName, SM4Location location) { foreach (var sm4Event in location.eventList.eventList) { if (sm4Event.eventName == eventName) { return(sm4Event); } } return(null); }
public List <SM4Event> FindValidEventsInLocation(SM4Location location) { List <SM4Event> validEvents = new List <SM4Event>(); foreach (var sm4Event in location.eventList.eventList) { if (SM4CheckIfEventValid.instance.CheckIfEventValid(sm4Event)) { validEvents.Add(sm4Event); } } return(validEvents); }
public void LoadEventsIntoEventList(string eventXmlFilePath) { XDocument doc; try { doc = XDocument.Load(eventXmlFilePath); } catch { doc = null; } XElement xElement = null; try { xElement = doc.Descendants("Region").First(); } catch { xElement = null; } if (xElement == null) { ErrorLogger.LogErrorInFile("In " + this.name + "Region was null"); return; } foreach (var xRegion in xElement.Elements()) { if (xRegion.NodeType != XmlNodeType.Comment) { var region = new SM4Region(); region.regionName = xRegion.Name.ToString(); evCon.regions.Add(region); } } foreach (var region in evCon.regions) { XElement xAreas = null; try { xAreas = doc.Descendants(region.regionName).First(); } catch { xAreas = null; } foreach (var xArea in xAreas.Elements()) { if (xArea.NodeType != XmlNodeType.Comment) { SM4Area area = new SM4Area(); area.areaName = xArea.Name.LocalName; region.areas.Add(area); } } foreach (var area in region.areas) { XElement xLocations = null; try { xLocations = doc.Descendants(area.areaName).First(); } catch { xLocations = null; } foreach (var xLocation in xLocations.Elements()) { if (xLocation.NodeType != XmlNodeType.Comment) { SM4Location location = new SM4Location(); location.locationName = xLocation.Name.LocalName; location.eventList.listName = location.locationName; area.locations.Add(location); } } foreach (var location in area.locations) { try { XElement xLocationSubArea = doc.Descendants(location.locationName).First(); XElement xLocationSubtree = XElement.Load(xLocationSubArea.CreateNavigator().ReadSubtree()); XElement xEvents = xLocationSubtree.Descendants("Events").First(); foreach (var xEvent in xEvents.Elements()) { if (xEvent.NodeType != XmlNodeType.Comment) { SM4Event sm4Event = new SM4Event(); sm4Event.xElement = xEvent; foreach (var xAttribute in xEvent.Attributes()) { sm4Event.attributes.Add( new KeyValuePair <string, string> (xAttribute.Name.ToString(), xAttribute.Value.ToString()) ); } sm4Event.eventName = xEvent.Name.LocalName; location.eventList.eventList.Add(sm4Event); } } } catch { } } } } }
public List <SM4Event> FindValidEventsInLocation(SM4Location location) { return(FindValidEventsInList(location.eventList.eventList)); }