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));
            }
        }
Example #2
0
        protected override void ParseSpecificNode(System.Xml.XmlNode xmlNode, HM.Entities.Hattrick.HattrickBase entity)
        {
            try
            {
                WorldDetails worldDetails = (WorldDetails)entity;

                switch (xmlNode.Name)
                {
                case Tags.LeagueList:
                {
                    if (xmlNode.ChildNodes != null)
                    {
                        worldDetails.leagueListField = ParseLeagueListNode(xmlNode);
                    }
                    break;
                }

                default:
                    throw new Exception(string.Format("Invalid XML: WorldDetails.xml"));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected override void ParseSpecificNode(XmlNode xmlNode, HattrickBase entity)
        {
            try {
                Players players = (Players)entity;

                switch (xmlNode.Name) {
                    case Tags.UserIsSupporter:
                        players.userIsSupporterField = GenericFunctions.ConvertStringToBool(xmlNode.InnerText);
                        break;
                    case Tags.IsYouth:
                        players.isYouthField = GenericFunctions.ConvertStringToBool(xmlNode.InnerText);
                        break;
                    case Tags.ActionType:
                        players.actionTypeField = xmlNode.InnerText;
                        break;
                    case Tags.IsPlayingMatch:
                        players.isPlayingMatchField = GenericFunctions.ConvertStringToBool(xmlNode.InnerText);
                        break;
                    case Tags.Team:
                        if (xmlNode.ChildNodes != null) {
                            players.teamField = ParseTeamNode(xmlNode);
                        }
                        break;
                }
            } catch (Exception ex) {
                throw ex;
            }
        }
        protected override void ParseSpecificNode(XmlNode xmlNode, HattrickBase entity)
        {
            MatchLineup matchLineup = (MatchLineup)entity;

            switch (xmlNode.Name)
            {
                case Tags.MatchId:
                    matchLineup.matchIdField = GenericFunctions.ConvertStringToUInt(xmlNode.InnerText);
                    break;
                case Tags.IsYouth:
                    matchLineup.isYouthField = GenericFunctions.ConvertStringToBool(xmlNode.InnerText);
                    break;
                case Tags.MatchType:
                    matchLineup.matchTypeField = (MatchType)Convert.ToInt32(xmlNode.InnerText);
                    break;
                case Tags.MatchDate:
                    matchLineup.matchDateField = GenericFunctions.ConvertStringToDateTime(xmlNode.InnerText);
                    break;
                case Tags.HomeTeam:
                    matchLineup.homeTeamField = ParseHomeTeamNode(xmlNode);
                    break;
                case Tags.AwayTeam:
                    matchLineup.awayTeamField = ParseAwayTeamNode(xmlNode);
                    break;
                case Tags.Arena:
                    matchLineup.arenaField = ParseArenaNode(xmlNode);
                    break;
                case Tags.Team:
                    matchLineup.teamField = ParseTeamNode(xmlNode);
                    break;
            }
        }
        protected override void ParseSpecificNode(XmlNode xmlNode, HM.Entities.Hattrick.HattrickBase entity)
        {
            try
            {
                MatchDetails matchDetails = (MatchDetails)entity;

                switch (xmlNode.Name)
                {
                case Tags.UserIsSupporter:
                    matchDetails.userIsSupporterField = GenericFunctions.ConvertStringToBool(xmlNode.InnerText);
                    break;

                case Tags.IsYouth:
                    matchDetails.isYouthField = GenericFunctions.ConvertStringToBool(xmlNode.InnerText);
                    break;

                case Tags.Match:
                    matchDetails.matchField = ParseMatchNode(xmlNode);
                    break;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected override void ParseSpecificNode(XmlNode xmlNode, HattrickBase entity)
        {
            try {
                PlayersInternal players = (PlayersInternal)entity;

                switch (xmlNode.Name) {
                    case Tags.PlayerCategories:
                        if (xmlNode.ChildNodes != null) {
                            players.playerCategories = ParseCategoryNode(xmlNode);
                        }
                        break;
                }
            } catch (Exception ex) {
                throw ex;
            }
        }
        protected override void ParseSpecificNode(XmlNode xmlNode, HattrickBase entity)
        {
            Matches matches = (Matches)entity;

            switch (xmlNode.Name) {
                case Tags.IsYouth:
                    matches.isYouth = GenericFunctions.ConvertStringToBool(xmlNode.InnerText);
                    break;
                case Tags.Team:
                    if (xmlNode.ChildNodes != null) {
                        matches.team = ParseTeamNode(xmlNode);
                    }
                    break;
                default:
                    throw new Exception(string.Format("Invalid XML: Matches.xml", Tags.Team));
            }
        }
        protected override void ParseSpecificNode(XmlNode xmlNode, HattrickBase entity)
        {
            try {
                MatchesArchive matchesArchive = (MatchesArchive)entity;

                switch (xmlNode.Name) {
                    case Tags.IsYouth:
                        matchesArchive.isYouthField = GenericFunctions.ConvertStringToBool(xmlNode.InnerText);
                        break;
                    case Tags.Team:
                        if (xmlNode.ChildNodes != null) {
                            matchesArchive.teamField = ParseTeamNode(xmlNode);
                        }
                        break;
                }
            } 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));
            }
        }
        protected override void ParseSpecificNode(XmlNode xmlNode, HattrickBase entity)
        {
            try
            {
                ArenaDetails arena = (ArenaDetails)entity;

                switch (xmlNode.Name)
                {
                    case Tags.Arena:
                        arena = ParseArenaNode(xmlNode, arena);
                        break;
                    default:
                        throw new Exception("Invalid XML file.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected override void ParseSpecificNode(XmlNode xmlNode, HattrickBase entity)
        {
            try {
                TeamDetails teamDetails = (TeamDetails)entity;

                switch (xmlNode.Name) {
                    case Tags.User:
                        if (xmlNode.ChildNodes != null) {
                            teamDetails.userField = ParseUserNode(xmlNode);
                        }
                        break;
                    case Tags.Team:
                        if (xmlNode.ChildNodes != null) {
                            teamDetails.teamField = ParseTeamNode(xmlNode);
                        }
                        break;
                }
            } catch (Exception ex) {
                throw ex;
            }
        }
        protected override void ParseSpecificNode(XmlNode xmlNode, HattrickBase entity)
        {
            try
            {
                Club club = (Club)entity;

                switch (xmlNode.Name)
                {
                    case Tags.Team:
                        if (xmlNode.ChildNodes != null)
                        {
                            club.teamField = ParseTeamNode(xmlNode);
                        }
                        break;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #13
0
        protected override void ParseSpecificNode(System.Xml.XmlNode xmlNode, HM.Entities.Hattrick.HattrickBase entity)
        {
            try {
                Servers servers = (Servers)entity;

                switch (xmlNode.Name)
                {
                case Tags.RecommendedURL:
                    servers.recommendedUrlField = xmlNode.InnerText;
                    break;

                case Tags.Servers:
                    if (xmlNode.ChildNodes != null)
                    {
                        servers.serversField = ParseServersNode(xmlNode);
                    }
                    break;
                }
            } catch (Exception ex) {
                throw ex;
            }
        }
        /// <summary>
        /// Reads a HT xml file and returns a HattrickBase object
        /// </summary>
        /// <param name="xmlStream">Xml file content</param>
        /// <param name="fileType">HT file type to read</param>
        /// <returns>HattrickBase object loaded with readed data</returns>
        public HTEntities.HattrickBase ReadFile(Stream xmlStream, FileType fileType)
        {
            try {
                HTEntities.HattrickBase hattrickData = null;
                XmlDocument             xmlDocument  = new XmlDocument();
                xmlDocument.Load(xmlStream);

                switch (fileType)
                {
                case FileType.Achievements:
                    hattrickData = new Parsers.AchievementsParser().ParseXmlDocument(xmlDocument);
                    break;

                case FileType.ArenaDetails:
                    hattrickData = new Parsers.ArenaDetailsParser().ParseXmlDocument(xmlDocument);
                    break;

                case FileType.Club:
                    hattrickData = new Parsers.ClubParser().ParseXmlDocument(xmlDocument);
                    break;

                case FileType.Economy:
                    hattrickData = new Parsers.EconomyParser().ParseXmlDocument(xmlDocument);
                    break;

                case FileType.Servers:
                    hattrickData = new Parsers.ServersParser().ParseXmlDocument(xmlDocument);
                    break;

                case FileType.LeagueDetails:
                    hattrickData = new Parsers.LeagueDetailsParser().ParseXmlDocument(xmlDocument);
                    break;

                case FileType.LeagueFixtures:
                    hattrickData = new Parsers.LeagueFixturesParser().ParseXmlDocument(xmlDocument);
                    break;

                case FileType.MatchLineup:
                    hattrickData = new Parsers.MatchLineupParser().ParseXmlDocument(xmlDocument);
                    break;

                case FileType.Matches:
                    hattrickData = new Parsers.MatchesParser().ParseXmlDocument(xmlDocument);
                    break;

                case FileType.MatchesArchive:
                    hattrickData = new Parsers.MatchesArchiveParser().ParseXmlDocument(xmlDocument);
                    break;

                case FileType.MatchDetails:
                    hattrickData = new Parsers.MatchDetailsParser().ParseXmlDocument(xmlDocument);
                    break;

                case FileType.Players:
                    hattrickData = new Parsers.PlayersParser().ParseXmlDocument(xmlDocument);
                    break;

                case FileType.InternalPlayers:
                    hattrickData = new Parsers.PlayerInternalsParser().ParseXmlDocument(xmlDocument);
                    break;

                case FileType.TeamDetails:
                    hattrickData = new Parsers.TeamDetailsParser().ParseXmlDocument(xmlDocument);
                    break;

                case FileType.TransfersPlayer:
                    hattrickData = new Parsers.TransfersPlayerParser().ParseXmlDocument(xmlDocument);
                    break;

                case FileType.WorldDetails:
                    hattrickData = new Parsers.WorldDetailsParser().ParseXmlDocument(xmlDocument);
                    break;

                default:
                    throw new NotImplementedException();
                }

                xmlStream.Close();
                xmlStream.Dispose();

                return(hattrickData);
            } catch (Exception ex) {
                throw ex;
            }
        }
 /// <summary>
 /// Reads data from entity-specific XML node and populates entity with the data.
 /// </summary>
 /// <param name="xmlNode">XML node to read</param>
 /// <param name="entity">Entity to populate</param>
 protected abstract void ParseSpecificNode(XmlNode xmlNode, HattrickBase entity);