Ejemplo n.º 1
0
        public EntityOccasionSchedule(XContainer data, EntityOccasion occasion)
        {
            Id   = Convert.ToInt16(data.Element("id").Value);
            Type = data.Element("type").Value;
            if (data.Elements("feature").Any())
            {
                Features = new List <EntityOccasionScheduleFeature>();
            }
            foreach (var elem in data.Elements("feature"))
            {
                Features.Add(new EntityOccasionScheduleFeature(elem, this));
            }

            ThisOccasion = occasion;
        }
Ejemplo n.º 2
0
        internal override void Plus(XDocument xdoc)
        {
            foreach (var element in xdoc.Root.Elements())
            {
                var val = element.Value;
                int valI;
                int.TryParse(val, out valI);

                switch (element.Name.LocalName)
                {
                case "id":
                    break;

                case "race_id":
                    if (valI != -1 && World.Races.ContainsKey(valI))
                    {
                        Race = World.Races[valI];
                    }
                    break;

                case "type":
                    if (!Types.Contains(val))
                    {
                        Types.Add(val);
                    }
                    _entityType = (short)Types.IndexOf(val);
                    break;

                case "site_link":
                    var newSl = new EntitySiteLink(element, this);
                    if (SiteLinks == null)
                    {
                        SiteLinks = new Dictionary <int, List <EntitySiteLink> >();
                    }
                    if (!SiteLinks.ContainsKey(newSl.LinkType))
                    {
                        SiteLinks.Add(newSl.LinkType, new List <EntitySiteLink>());
                    }
                    SiteLinks[newSl.LinkType].Add(newSl);
                    break;

                case "entity_link":
                    var newEl = new EntityEntityLink(element, this);
                    if (EntityLinks == null)
                    {
                        EntityLinks = new Dictionary <int, List <EntityEntityLink> >();
                    }
                    if (!EntityLinks.ContainsKey(newEl.LinkType))
                    {
                        EntityLinks.Add(newEl.LinkType, new List <EntityEntityLink>());
                    }
                    EntityLinks[newEl.LinkType].Add(newEl);
                    break;

                case "children":
                    ChildrenIDs = val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => Convert.ToInt32(x)).ToList();
                    break;

                case "worship_id":
                    WorshipHfid = valI;
                    break;

                case "coords":
                    if (Coords == null)
                    {
                        Coords = new List <Point>();
                    }
                    foreach (var coordSplit in val.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(coord => coord.Split(',')).Where(coordSplit => coordSplit.Length == 2))
                    {
                        Coords.Add(new Point(Convert.ToInt32(coordSplit[0]), Convert.ToInt32(coordSplit[1])));
                    }
                    break;

                case "claims":
                    Claims = val.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
                             .Select(coord => coord.Split(','))
                             .Where(coordSplit => coordSplit.Length == 2)
                             .Select(split => new Point(Convert.ToInt32(split[0]), Convert.ToInt32(split[1])))
                             .ToList();
                    break;

                case "entity_position":
                    var newPosition = new EntityPosition(element, this);
                    if (Positions == null)
                    {
                        Positions = new List <EntityPosition>();
                    }
                    Positions.Add(newPosition);
                    break;

                case "entity_position_assignment":
                    var newPositionAssignment = new EntityPositionAssignment(element, this);
                    if (PositionAssignments == null)
                    {
                        PositionAssignments = new List <EntityPositionAssignment>();
                    }
                    PositionAssignments.Add(newPositionAssignment);
                    break;

                case "histfig_id":
                    if (MemberHfids == null)
                    {
                        MemberHfids = new List <int>();
                    }
                    MemberHfids.Add(valI);
                    break;

                case "histfig_ids":
                    MemberHfids = val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => Convert.ToInt32(x)).ToList();
                    break;

                case "occasion":
                    var newOccasion = new EntityOccasion(element, this);
                    if (Occasions == null)
                    {
                        Occasions = new List <EntityOccasion>();
                    }
                    Occasions.Add(newOccasion);
                    break;

                default:
                    DFXMLParser.UnexpectedXmlElement(xdoc.Root.Name.LocalName + "\t", element, xdoc.Root.ToString());
                    break;
                }
            }
        }