private League ParseLeagueNode(XmlNode xmlNodeLeague)
        {
            try
            {
                League league = new League();

                foreach (XmlNode xmlNode in xmlNodeLeague.ChildNodes)
                {
                    switch (xmlNode.Name)
                    {
                    case Tags.LeagueID:
                        league.leagueIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;

                    case Tags.LeagueName:
                        league.leagueNameField = xmlNode.InnerText;
                        break;
                    }
                }
                return(league);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        private AwayTeam ParseAwayTeamNode(XmlNode awayTeamNode)
        {
            try
            {
                AwayTeam awayTeam = new AwayTeam();

                if (awayTeamNode.ChildNodes != null)
                {
                    foreach (XmlNode xmlNode in awayTeamNode.ChildNodes)
                    {
                        switch (xmlNode.Name)
                        {
                        case Tags.AwayTeamID:
                            awayTeam.awayTeamIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                            break;

                        case Tags.AwayTeamName:
                            awayTeam.awayTeamNameField = xmlNode.InnerText;
                            break;
                        }
                    }
                }

                return(awayTeam);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private Region ParseRegionNode(XmlNode xmlNodeRegion)
        {
            try
            {
                Region region = new Region();

                foreach (XmlNode xmlNode in xmlNodeRegion.ChildNodes)
                {
                    switch (xmlNode.Name)
                    {
                    case Tags.RegionID:
                        region.regionIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;

                    case Tags.RegionName:
                        region.regionNameField = xmlNode.InnerText;
                        break;
                    }
                }
                return(region);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        private HomeTeam ParseHomeTeamNode(XmlNode homeTeamNode)
        {
            try
            {
                HomeTeam homeTeam = new HomeTeam();

                if (homeTeamNode.ChildNodes != null)
                {
                    foreach (XmlNode xmlNode in homeTeamNode.ChildNodes)
                    {
                        switch (xmlNode.Name)
                        {
                        case Tags.HomeTeamID:
                            homeTeam.homeTeamIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                            break;

                        case Tags.HomeTeamName:
                            homeTeam.homeTeamNameField = xmlNode.InnerText;
                            break;
                        }
                    }
                }

                return(homeTeam);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private Player ParsePlayerNode(XmlNode playerNode)
        {
            try
            {
                Player player = new Player();

                foreach (XmlNode xmlNode in playerNode.ChildNodes)
                {
                    switch (xmlNode.Name)
                    {
                    case Tags.PlayerID:
                        player.playerIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;

                    case Tags.PlayerName:
                        player.playerNameField = xmlNode.InnerText;
                        break;

                    case Tags.TeamId:
                        player.teamIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;
                    }
                }

                return(player);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #6
0
        private Arena ParseArenaNode(XmlNode arenaNode)
        {
            try
            {
                Arena arena = new Arena();

                if (arenaNode.ChildNodes != null)
                {
                    foreach (XmlNode xmlNode in arenaNode.ChildNodes)
                    {
                        switch (xmlNode.Name)
                        {
                        case Tags.ArenaID:
                            arena.arenaIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                            break;

                        case Tags.ArenaName:
                            arena.arenaNameField = xmlNode.InnerText;
                            break;
                        }
                    }
                }

                return(arena);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #7
0
        private Cup ParseCupNode(XmlNode cupNode)
        {
            try
            {
                Cup cup = new Cup();

                foreach (XmlNode xmlNode in cupNode.ChildNodes)
                {
                    switch (xmlNode.Name)
                    {
                    case Tags.CupID:
                    {
                        cup.cupIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;
                    }

                    case Tags.CupName:
                    {
                        cup.cupNameField = xmlNode.InnerText;
                        break;
                    }
                    }
                }

                return(cup);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private LeagueLevelUnit ParseLeagueLevelUnitNode(XmlNode leagueLevelUnitNode)
        {
            try {
                LeagueLevelUnit leagueLevelUnit = new LeagueLevelUnit();

                foreach (XmlNode xmlNode in leagueLevelUnitNode.ChildNodes)
                {
                    switch (xmlNode.Name)
                    {
                    case Tags.LeagueLevelUnitID:
                        leagueLevelUnit.leagueLevelUnitIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;

                    case Tags.LeagueLevelUnitName:
                        leagueLevelUnit.leagueLevelUnitNameField = xmlNode.InnerText;
                        break;

                    case Tags.LeagueLevel:
                        leagueLevelUnit.leagueLevelField = GenericFunctions.ConvertStringToByte(xmlNode.InnerText);
                        break;
                    }
                }

                return(leagueLevelUnit);
            } catch (Exception ex) {
                throw ex;
            }
        }
        protected override void ParseSpecificNode(System.Xml.XmlNode xmlNode, HM.Entities.Hattrick.HattrickBase entity)
        {
            LeagueFixtures leagueFixtures = (LeagueFixtures)entity;

            switch (xmlNode.Name)
            {
            case Tags.LeagueLevelUnitID:
                leagueFixtures.leagueLevelUnitIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                break;

            case Tags.LeagueLevelUnitName:
                leagueFixtures.leagueLevelUnitNameField = xmlNode.InnerText;
                break;

            case Tags.Season:
                leagueFixtures.seasonField = Convert.ToInt32(xmlNode.InnerText);
                break;

            case Tags.Match:
                leagueFixtures.matchListField.Add(ParseMatchNode(xmlNode));
                break;

            default:
                throw new Exception(string.Format("Invalid XML: LeagueFixtures.xml", Tags.Match));
            }
        }
        private Flag ParseFlagNode(XmlNode flagsListNode)
        {
            try {
                Flag flag = new Flag();

                foreach (XmlNode xmlNode in flagsListNode.ChildNodes)
                {
                    switch (xmlNode.Name)
                    {
                    case Tags.LeagueId:
                        flag.leagueIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;

                    case Tags.LeagueName:
                        flag.leagueNameField = xmlNode.InnerText;
                        break;

                    case Tags.CountryCode:
                        flag.countryCodeField = xmlNode.InnerText;
                        break;
                    }
                }

                return(flag);
            } catch (Exception ex) {
                throw ex;
            }
        }
        private Seller ParseSellerNode(XmlNode sellerNode)
        {
            try
            {
                Seller seller = new Seller();

                foreach (XmlNode xmlNode in sellerNode.ChildNodes)
                {
                    switch (xmlNode.Name)
                    {
                    case Tags.SellerTeamID:
                        seller.sellerTeamIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;

                    case Tags.SellerTeamName:
                        seller.sellerTeamNameField = xmlNode.InnerText;
                        break;
                    }
                }

                return(seller);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private Buyer ParseBuyerNode(XmlNode buyerNode)
        {
            try
            {
                Buyer buyer = new Buyer();

                foreach (XmlNode xmlNode in buyerNode.ChildNodes)
                {
                    switch (xmlNode.Name)
                    {
                    case Tags.BuyerTeamID:
                        buyer.buyerTeamIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;

                    case Tags.BuyerTeamName:
                        buyer.buyerTeamNameField = xmlNode.InnerText;
                        break;
                    }
                }

                return(buyer);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private Team ParseTeamNode(XmlNode teamNode)
        {
            try {
                Team team = new Team();

                foreach (XmlNode xmlNode in teamNode.ChildNodes)
                {
                    switch (xmlNode.Name)
                    {
                    case Tags.TeamID:
                        team.teamIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;

                    case Tags.TeamName:
                        team.teamNameField = xmlNode.InnerText;
                        break;

                    case Tags.PlayerList:
                        if (xmlNode.ChildNodes != null)
                        {
                            team.playerListField = ParsePlayerListNode(xmlNode);
                        }
                        break;
                    }
                }

                return(team);
            } catch (Exception ex) {
                throw ex;
            }
        }
        private List <PlayerCategories> ParseCategoryNode(XmlNode categoryNode)
        {
            List <PlayerCategories> playerCategories = new List <PlayerCategories>();

            foreach (XmlNode xmlPlayerNode in categoryNode.ChildNodes)
            {
                if (xmlPlayerNode.ChildNodes != null)
                {
                    PlayerCategories cat = new PlayerCategories();

                    foreach (XmlNode xmlNode in xmlPlayerNode.ChildNodes)
                    {
                        switch (xmlNode.Name)
                        {
                        case Tags.PlayerID:
                            cat.PlayerIDField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                            break;

                        case Tags.PlayerCategoryId:
                            cat.PlayerCategoryField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                            break;
                        }
                    }

                    playerCategories.Add(cat);
                }
            }

            return(playerCategories);
        }
Пример #15
0
        private YouthSquad ParseYouthSquadNode(XmlNode youthSquadNode)
        {
            try
            {
                YouthSquad youthSquad = new YouthSquad();

                foreach (XmlNode xmlNode in youthSquadNode.ChildNodes)
                {
                    switch (xmlNode.Name)
                    {
                    case Tags.Investment:
                        youthSquad.investmentField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;

                    case Tags.HasPromoted:
                        youthSquad.hasPromotedField = GenericFunctions.ConvertStringToBool(xmlNode.InnerText);
                        break;

                    case Tags.YouthLevel:
                        youthSquad.youthLevelField = GenericFunctions.ConvertStringToByte(xmlNode.InnerText);
                        break;
                    }
                }

                return(youthSquad);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private Arena ParseArenaNode(XmlNode xmlNode)
        {
            try
            {
                Arena arena = new Arena();

                if (xmlNode.ChildNodes != null)
                {
                    foreach (XmlNode arenaNode in xmlNode.ChildNodes)
                    {
                        switch (arenaNode.Name)
                        {
                        case Tags.ArenaID:
                            arena.arenaIdField = GenericFunctions.ConvertStringToUInt(arenaNode.InnerText);
                            break;

                        case Tags.ArenaName:
                            arena.arenaNameField = arenaNode.InnerText;
                            break;

                        case Tags.WeatherID:
                            arena.weatherIdField = (Weather)Convert.ToInt32(arenaNode.InnerText);
                            break;

                        case Tags.SoldTotal:
                            arena.soldTotalField = GenericFunctions.ConvertStringToUInt(arenaNode.InnerText);
                            break;

                        case Tags.SoldTerraces:
                            arena.soldTerracesField = GenericFunctions.ConvertStringToUInt(arenaNode.InnerText);
                            break;

                        case Tags.SoldBasic:
                            arena.soldBasicField = GenericFunctions.ConvertStringToUInt(arenaNode.InnerText);
                            break;

                        case Tags.SoldRoof:
                            arena.soldRoofField = GenericFunctions.ConvertStringToUInt(arenaNode.InnerText);
                            break;

                        case Tags.SoldVIP:
                            arena.soldVipField = GenericFunctions.ConvertStringToUInt(arenaNode.InnerText);
                            break;
                        }
                    }
                }

                return(arena);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private CurrentCapacity ParseCurrentCapacityNode(XmlNode xmlNodeCurrentCapacity)
        {
            try
            {
                CurrentCapacity currentCapacity = new CurrentCapacity();

                if (xmlNodeCurrentCapacity.ChildNodes != null)
                {
                    foreach (XmlNode xmlNode in xmlNodeCurrentCapacity.ChildNodes)
                    {
                        switch (xmlNode.Name)
                        {
                        case Tags.RebuiltDate:
                            if (xmlNode.Attributes[Tags.Available] != null)
                            {
                                currentCapacity.availableField = GenericFunctions.ConvertStringToBool(xmlNode.Attributes[Tags.Available].Value);

                                if (currentCapacity.availableField)
                                {
                                    currentCapacity.rebuiltDateField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText);
                                }
                            }
                            break;

                        case Tags.Basic:
                            currentCapacity.basicField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                            break;

                        case Tags.Terraces:
                            currentCapacity.terracesField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                            break;

                        case Tags.Roof:
                            currentCapacity.roofField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                            break;

                        case Tags.VIP:
                            currentCapacity.vipField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                            break;

                        case Tags.Total:
                            currentCapacity.totalField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                            break;
                        }
                    }
                }
                return(currentCapacity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private Event ParseEventNode(XmlNode xmlNode)
        {
            try
            {
                Event eventField = new Event();

                if (xmlNode.Attributes[Tags.Index] != null)
                {
                    eventField.indexField = Convert.ToInt32(xmlNode.Attributes[Tags.Index].Value);
                }

                if (xmlNode.ChildNodes != null)
                {
                    foreach (XmlNode eventNode in xmlNode.ChildNodes)
                    {
                        switch (xmlNode.Name)
                        {
                        case Tags.Minute:
                            eventField.minuteField = GenericFunctions.ConvertStringToByte(eventNode.InnerText);
                            break;

                        case Tags.SubjectPlayerID:
                            eventField.subjectPlayerIdField = GenericFunctions.ConvertStringToUInt(eventNode.InnerText);
                            break;

                        case Tags.SubjectTeamID:
                            eventField.subjectTeamIdField = GenericFunctions.ConvertStringToUInt(eventNode.InnerText);
                            break;

                        case Tags.ObjectPlayerID:
                            eventField.objectPlayerIdField = GenericFunctions.ConvertStringToUInt(eventNode.InnerText);
                            break;

                        case Tags.EventKey:
                            eventField.eventKeyField = eventNode.InnerText;
                            break;

                        case Tags.EventText:
                            eventField.eventTextField = eventNode.InnerText;
                            break;
                        }
                    }
                }

                return(eventField);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private Match ParseMatchNode(XmlNode matchNode)
        {
            try {
                Match match = new Match();

                foreach (XmlNode xmlNode in matchNode.ChildNodes)
                {
                    switch (xmlNode.Name)
                    {
                    case Tags.MatchId:
                        match.matchIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;

                    case Tags.HomeTeam:
                        if (xmlNode.ChildNodes != null)
                        {
                            match.homeTeamField = ParseHomeTeamNode(xmlNode);
                        }
                        break;

                    case Tags.AwayTeam:
                        if (xmlNode.ChildNodes != null)
                        {
                            match.awayTeamField = ParseAwayTeamNode(xmlNode);
                        }
                        break;

                    case Tags.MatchDate:
                        match.matchDateField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText);
                        break;

                    case Tags.MatchType:
                        match.matchTypeField = (MatchType)Convert.ToInt32(xmlNode.InnerText);
                        break;

                    case Tags.HomeGoals:
                        match.homeGoalsField = GenericFunctions.ConvertStringToByte(xmlNode.InnerText);
                        break;

                    case Tags.AwayGoals:
                        match.awayGoalsField = GenericFunctions.ConvertStringToByte(xmlNode.InnerText);
                        break;
                    }
                }

                return(match);
            } catch (Exception ex) {
                throw ex;
            }
        }
        private Goal ParseGoalNode(XmlNode xmlNode)
        {
            try
            {
                Goal goal = new Goal();

                if (xmlNode.Attributes[Tags.Index] != null)
                {
                    goal.indexField = Convert.ToInt32(xmlNode.Attributes[Tags.Index].Value);
                }
                if (xmlNode.ChildNodes != null)
                {
                    foreach (XmlNode goalNode in xmlNode.ChildNodes)
                    {
                        switch (goalNode.Name)
                        {
                        case Tags.ScorerPlayerID:
                            goal.scorerPlayerIdField = GenericFunctions.ConvertStringToUInt(goalNode.InnerText);
                            break;

                        case Tags.ScorerPlayerName:
                            goal.scorerPlayerNameField = goalNode.InnerText;
                            break;

                        case Tags.ScorerTeamID:
                            goal.scorerTeamIdField = GenericFunctions.ConvertStringToUInt(goalNode.InnerText);
                            break;

                        case Tags.ScorerHomeGoals:
                            goal.scorerHomeGoalsField = GenericFunctions.ConvertStringToByte(goalNode.InnerText);
                            break;

                        case Tags.ScorerAwayGoals:
                            goal.scorerAwayGoalsField = GenericFunctions.ConvertStringToByte(goalNode.InnerText);
                            break;

                        case Tags.ScorerMinute:
                            goal.scorerMinuteField = GenericFunctions.ConvertStringToByte(goalNode.InnerText);
                            break;
                        }
                    }
                }

                return(goal);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #21
0
        private Player ParsePlayerNode(XmlNode playerNode)
        {
            try
            {
                Player player = new Player();

                if (playerNode.ChildNodes != null)
                {
                    foreach (XmlNode xmlNode in playerNode.ChildNodes)
                    {
                        switch (xmlNode.Name)
                        {
                        case Tags.PlayerID:
                            player.playerIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                            break;

                        case Tags.RoleID:
                            player.roleIdField = (Role)Convert.ToInt32(xmlNode.InnerText);
                            break;

                        case Tags.PlayerName:
                            player.playerNameField = xmlNode.InnerText;
                            break;

                        case Tags.RatingStars:
                            player.ratingStarsField = GenericFunctions.ConvertStringToDecimal(xmlNode.InnerText);
                            break;

                        case Tags.RatingStarsEndOfMatch:
                            player.ratingStarsEndOfMatchField = GenericFunctions.ConvertStringToDecimal(xmlNode.InnerText);
                            break;

                        case Tags.PositionCode:
                            player.positionCodeField = (PositionCode)Convert.ToInt32(xmlNode.InnerText);
                            break;

                        case Tags.Behaviour:
                            player.behaviourField = (Behaviour)Convert.ToInt32(xmlNode.InnerText);
                            break;
                        }
                    }
                }

                return(player);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private Transfer ParseTransferNode(XmlNode transferNode)
        {
            try
            {
                Transfer transfer = new Transfer();

                foreach (XmlNode xmlNode in transferNode.ChildNodes)
                {
                    switch (xmlNode.Name)
                    {
                    case Tags.TransferID:
                        transfer.transferIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;

                    case Tags.Deadline:
                        transfer.deadlineField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText);
                        break;

                    case Tags.Buyer:
                        if (xmlNode.ChildNodes != null)
                        {
                            transfer.buyerField = ParseBuyerNode(xmlNode);
                        }
                        break;

                    case Tags.Seller:
                        if (xmlNode.ChildNodes != null)
                        {
                            transfer.sellerField = ParseSellerNode(xmlNode);
                        }
                        break;

                    case Tags.Price:
                        transfer.priceField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;

                    case Tags.TSI:
                        transfer.tsiField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;
                    }
                }

                return(transfer);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private Booking ParseBookingNode(XmlNode xmlNode)
        {
            try
            {
                Booking booking = new Booking();

                if (xmlNode.Attributes[Tags.Index] != null)
                {
                    booking.indexField = Convert.ToInt32(xmlNode.Attributes[Tags.Index].Value);
                }

                if (xmlNode.ChildNodes != null)
                {
                    foreach (XmlNode bookingNode in xmlNode.ChildNodes)
                    {
                        switch (bookingNode.Name)
                        {
                        case Tags.BookingPlayerID:
                            booking.bookingPlayerIdField = GenericFunctions.ConvertStringToUInt(bookingNode.InnerText);
                            break;

                        case Tags.BookingPlayerName:
                            booking.bookingPlayerNameField = bookingNode.InnerText;
                            break;

                        case Tags.BookingTeamID:
                            booking.bookingTeamIdField = GenericFunctions.ConvertStringToUInt(bookingNode.InnerText);
                            break;

                        case Tags.BookingType:
                            booking.bookingTypeField = Convert.ToInt32(bookingNode.InnerText);
                            break;

                        case Tags.BookingMinute:
                            booking.bookingMinuteField = GenericFunctions.ConvertStringToByte(bookingNode.InnerText);
                            break;
                        }
                    }
                }

                return(booking);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #24
0
        private Specialists ParseSpecialistsNode(XmlNode specialistsNode)
        {
            try
            {
                Specialists specialists = new Specialists();

                foreach (XmlNode xmlNode in specialistsNode.ChildNodes)
                {
                    switch (xmlNode.Name)
                    {
                    case Tags.KeeperTrainers:
                        specialists.keeperTrainersField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;

                    case Tags.AssistantTrainers:
                        specialists.assistantTrainersField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;

                    case Tags.Psychologists:
                        specialists.psychologistsField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;

                    case Tags.PressSpokesmen:
                        specialists.pressSpokesmenField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;

                    case Tags.Economists:
                        specialists.economistsField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;

                    case Tags.Physiotherapists:
                        specialists.physiotherapistsField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;

                    case Tags.Doctors:
                        specialists.doctorsField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;
                    }
                }

                return(specialists);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private ArenaDetails ParseArenaNode(XmlNode xmlNodeArena, ArenaDetails arena)
        {
            try
            {
                foreach (XmlNode xmlNode in xmlNodeArena.ChildNodes)
                {
                    switch (xmlNode.Name)
                    {
                    case Tags.ArenaID:
                        arena.arenaIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;

                    case Tags.ArenaName:
                        arena.arenaNameField = xmlNode.InnerText;
                        break;

                    case Tags.Team:
                        arena.teamField = ParseTeamNode(xmlNode);
                        break;

                    case Tags.League:
                        arena.leagueField = ParseLeagueNode(xmlNode);
                        break;

                    case Tags.Region:
                        arena.regionField = ParseRegionNode(xmlNode);
                        break;

                    case Tags.CurrentCapacity:
                        arena.currentCapacityField = ParseCurrentCapacityNode(xmlNode);
                        break;

                    case Tags.ExpandedCapacity:
                        arena.expandedCapacityField = ParseExpandedCapacityNode(xmlNode);
                        break;
                    }
                }

                return(arena);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Reads the xml document and populates internal state with its data.
        /// </summary>
        /// <param name="xmlDocument">Xml document</param>
        public void ReadXml(XmlDocument xmlDocument)
        {
            if (xmlDocument.DocumentElement.ChildNodes != null)
            {
                //Iterates thru each node in HattrickData node
                foreach (XmlNode xmlNode in xmlDocument.DocumentElement.ChildNodes)
                {
                    bool generalNode = false;
                    switch (xmlNode.Name)
                    {
                    case Tags.FileName: {
                        this.fileNameField = xmlNode.InnerText;
                        generalNode        = true;
                        break;
                    }

                    case Tags.Version: {
                        this.versionField = GenericFunctions.ConvertStringToDecimal(xmlNode.InnerText);
                        generalNode       = true;
                        break;
                    }

                    case Tags.UserID: {
                        this.userIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        generalNode      = true;
                        break;
                    }

                    case Tags.FetchedDate: {
                        this.fetchedDateField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText);
                        generalNode           = true;
                        break;
                    }
                    }

                    if (!generalNode)
                    {
                        // Not one of the general nodes,
                        // try reading it as a specific node
                        //ReadSpecificNode(xmlNode);
                    }
                }
            }
        }
        private AwayTeam ParseAwayTeamNode(XmlNode awayTeamNode)
        {
            AwayTeam awayTeam = new AwayTeam();

            foreach (XmlNode xmlNodeAwayTeam in awayTeamNode.ChildNodes)
            {
                switch (xmlNodeAwayTeam.Name)
                {
                case Tags.AwayTeamID:
                    awayTeam.awayTeamIdField = GenericFunctions.ConvertStringToUInt(xmlNodeAwayTeam.InnerText);
                    break;

                case Tags.AwayTeamName:
                    awayTeam.awayTeamNameField = xmlNodeAwayTeam.InnerText;
                    break;
                }
            }
            return(awayTeam);
        }
Пример #28
0
        private Country ParseCountryNode(XmlNode countryNode)
        {
            try
            {
                Country country = new Country();

                foreach (XmlNode xmlNode in countryNode.ChildNodes)
                {
                    switch (xmlNode.Name)
                    {
                    case Tags.CountryID:
                    {
                        country.countryIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                        break;
                    }

                    case Tags.CountryName:
                    {
                        country.countryNameField = xmlNode.InnerText;
                        break;
                    }

                    case Tags.CurrencyName:
                    {
                        country.currencyNameField = xmlNode.InnerText;
                        break;
                    }

                    case Tags.CurrencyRate:
                    {
                        country.currencyRateField = GenericFunctions.ConvertStringToDecimal(xmlNode.InnerText);
                        break;
                    }
                    }
                }

                return(country);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected override void ParseSpecificNode(System.Xml.XmlNode xmlNode, HM.Entities.Hattrick.HattrickBase entity)
        {
            LeagueDetails leagueDetails = (LeagueDetails)entity;

            switch (xmlNode.Name)
            {
            case Tags.LeagueID:
                leagueDetails.leagueIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                break;

            case Tags.LeagueName:
                leagueDetails.leagueNameField = xmlNode.InnerText;
                break;

            case Tags.LeagueLevel:
                leagueDetails.leagueLevelField = GenericFunctions.ConvertStringToByte(xmlNode.InnerText);
                break;

            case Tags.MaxLevel:
                leagueDetails.maxLevelField = GenericFunctions.ConvertStringToByte(xmlNode.InnerText);
                break;

            case Tags.LeagueLevelUnitID:
                leagueDetails.leagueLevelUnitIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                break;

            case Tags.LeagueLevelUnitName:
                leagueDetails.leagueLevelUnitNameField = xmlNode.InnerText;
                break;

            case Tags.CurrentMatchRound:
                leagueDetails.currentMatchRound = GenericFunctions.ConvertStringToByte(xmlNode.InnerText);
                break;

            case Tags.Team:
                Team newTeam = ParseTeamNode(xmlNode);
                leagueDetails.teamField[newTeam.positionField - 1] = newTeam;
                break;

            default:
                throw new Exception(string.Format("Invalid XML: LeagueDetails.xml", Tags.Team));
            }
        }
        private Team ParseTeamNode(XmlNode teamArrayNode)
        {
            Team team = new Team();

            foreach (XmlNode teamNode in teamArrayNode.ChildNodes)
            {
                switch (teamNode.Name)
                {
                case Tags.TeamID:
                    team.teamIdField = GenericFunctions.ConvertStringToUInt(teamNode.InnerText);
                    break;

                case Tags.TeamName:
                    team.teamNameField = teamNode.InnerText;
                    break;

                case Tags.Position:
                    team.positionField = GenericFunctions.ConvertStringToByte(teamNode.InnerText);
                    break;

                case Tags.PositionChange:
                    team.positionChangeField = (PositionChange)Convert.ToInt32(teamNode.InnerText);
                    break;

                case Tags.Matches:
                    team.matchesField = GenericFunctions.ConvertStringToByte(teamNode.InnerText);
                    break;

                case Tags.GoalsFor:
                    team.goalsForField = GenericFunctions.ConvertStringToByte(teamNode.InnerText);
                    break;

                case Tags.GoalsAgainst:
                    team.goalsAgainstField = GenericFunctions.ConvertStringToByte(teamNode.InnerText);
                    break;

                case Tags.Points:
                    team.pointsField = GenericFunctions.ConvertStringToByte(teamNode.InnerText);
                    break;
                }
            }
            return(team);
        }