コード例 #1
0
        static List <CutSets> ReadAllCutSets(XmlReader reader)
        {
            List <CutSets> cutSets = new List <CutSets>();

            reader.ReadStartElement();

            while (reader.Name == "CutSets")
            {
                CutSets newCutSets = new CutSets();
                newCutSets.Order = reader.GetAttribute("order");

                reader.ReadStartElement();
                while (reader.Name == "CutSet")
                {
                    CutSet cutSet = new CutSet();

                    reader.ReadStartElement();

                    if (reader.Name == "Unavailability")
                    {
                        cutSet.Unavailability = reader.ReadElementContentAsString();
                    }
                    if (reader.Name == "UnavailabilitySort")
                    {
                        cutSet.UnavailabilitySort = reader.ReadElementContentAsString();
                    }

                    if (reader.Name == "Events")
                    {
                        reader.ReadStartElement();

                        while (reader.Name == "Event")
                        {
                            BasicEvent basicEvent = new BasicEvent();
                            basicEvent.PreviousId = int.Parse(reader.GetAttribute("ID"));
                            cutSet.Events.Add(basicEvent);

                            reader.Read();
                        }
                        reader.Read();
                    }

                    newCutSets.CutSetList.Add(cutSet);
                    reader.Read();
                }
                cutSets.Add(newCutSets);
                reader.Read();
            }
            reader.Read();

            return(cutSets);
        }
コード例 #2
0
        static List <BasicEvent> CombineEvents(List <BasicEvent> events)
        {
            List <BasicEvent> combinedEvents = new List <BasicEvent>();

            Dictionary <string, List <BasicEvent> > eventListDictionary = new Dictionary <string, List <BasicEvent> >();

            while (events.Count > 0)
            {
                if (!eventListDictionary.ContainsKey(events[0].Name))
                {
                    List <BasicEvent> newEvents = new List <BasicEvent>();
                    newEvents.Add(events[0]);

                    eventListDictionary.Add(events[0].Name, newEvents);
                }
                else
                {
                    eventListDictionary[events[0].Name].Add(events[0]);
                }

                events.RemoveAt(0);
            }

            foreach (KeyValuePair <string, List <BasicEvent> > basicEventKVP in eventListDictionary)
            {
                BasicEvent newEvent = new BasicEvent(basicEventKVP.Key);
                newEvent.ShortName      = basicEventKVP.Value[0].ShortName;
                newEvent.Description    = basicEventKVP.Value[0].Description;
                newEvent.Unavailability = basicEventKVP.Value[0].Unavailability;

                List <Effect> uncombinedEffects = new List <Effect>();
                foreach (BasicEvent basicEvent in basicEventKVP.Value)
                {
                    foreach (Effect effect in basicEvent.Effects)
                    {
                        uncombinedEffects.Add(effect);
                    }
                }
                newEvent.Effects    = CombineEffects(uncombinedEffects);
                newEvent.PreviousId = basicEventKVP.Value[0].PreviousId;
                combinedEvents.Add(newEvent);
                BasicEventsDictionary.Add(newEvent.Name, newEvent);
            }

            return(combinedEvents);
        }
コード例 #3
0
        static BasicEvent ReadEvent(XmlReader reader)
        {
            string        name           = "";
            string        shortName      = "";
            string        description    = "";
            string        unavailability = "";
            List <Effect> effects        = new List <Effect>();

            int        previousId = int.Parse(reader.GetAttribute("ID"));
            BasicEvent basicEvent = new BasicEvent();

            basicEvent.PreviousId          = previousId;
            basicEvent.HiPHOPSResultsIndex = HiP_HOPSResultsList.Count;

            if (!BasicEventsDictionaryList[HiP_HOPSResultsList.Count].ContainsKey(previousId))
            {
                reader.ReadStartElement();

                if (reader.Name == "Name")
                {
                    name            = reader.ReadElementContentAsString();
                    basicEvent.Name = name;
                }

                basicEvent.PreviousId = previousId;

                if (reader.Name == "ShortName")
                {
                    shortName            = reader.ReadElementContentAsString();
                    basicEvent.ShortName = shortName;
                }
                if (reader.Name == "Description")
                {
                    description            = reader.ReadElementContentAsString();
                    basicEvent.Description = description;
                }
                if (reader.Name == "Unavailability")
                {
                    unavailability            = reader.ReadElementContentAsString();
                    basicEvent.Unavailability = unavailability;
                }

                if (reader.Name == "Effects")
                {
                    reader.Read();

                    if (reader.Name == "Effect")
                    {
                        while (reader.Name == "Effect")
                        {
                            effects.Add(ReadEffect(reader));
                        }

                        reader.Read();
                    }
                    basicEvent.Effects = effects;
                }

                BasicEventsDictionaryList[HiP_HOPSResultsList.Count].Add(previousId, basicEvent);
            }
            else
            {
                reader.Read();
                return(BasicEventsDictionaryList[HiP_HOPSResultsList.Count][previousId]);
            }

            reader.Read();
            return(basicEvent);
        }