ParsePlayer() публичный статический Метод

public static ParsePlayer ( string fileName ) : ArkData.Player
fileName string
Результат ArkData.Player
Пример #1
0
        /// <summary>
        /// Instantiates the ArkDataContainer and parses all the user data files
        /// </summary>
        /// <param name="directory">The directory containing the profile and tribe files.</param>
        public static ArkDataContainer Create(string directory)
        {
            if (!Directory.Exists(directory))
            {
                throw new DirectoryNotFoundException("The ARK data directory couldn't be found.");
            }

            var playerFiles = Directory.GetFiles(directory).Where(p => Path.GetExtension(p).Equals(".arkprofile")).ToArray();
            var tribeFiles  = Directory.GetFiles(directory).Where(p => Path.GetExtension(p).Equals(".arktribe")).ToArray();

            if (playerFiles.Length == 0 && tribeFiles.Length == 0)
            {
                throw new FileLoadException("The directory did not contain any of the parseable files.");
            }

            var container = new ArkDataContainer();

            for (var i = 0; i < playerFiles.Length; i++)
            {
                container.Players.Add(Parser.ParsePlayer(playerFiles[i]));
            }

            for (var i = 0; i < tribeFiles.Length; i++)
            {
                container.Tribes.Add(Parser.ParseTribe(tribeFiles[i]));
            }

            container.LinkPlayerTribe();

            return(container);
        }
Пример #2
0
        /// <summary>
        /// Instantiates the DataContainer and parses all the user data files
        /// </summary>
        public static DataContainer Create(string playerFileFolder, string tribeFileFolder)
        {
            var playerFiles = new string[0];
            var tribeFiles  = new string[0];

            if (Directory.Exists(playerFileFolder))
            {
                playerFiles = Directory.GetFiles(playerFileFolder).Where(f => Path.GetFileNameWithoutExtension(f).StartsWith(DataFileDetails.PlayerFilePrefix) &&
                                                                         Path.GetFileNameWithoutExtension(f).EndsWith(DataFileDetails.PlayerFileSuffix) &&
                                                                         Path.GetExtension(f).Equals(DataFileDetails.PlayerFileExtension)).ToArray();
            }
            if (Directory.Exists(tribeFileFolder))
            {
                tribeFiles = Directory.GetFiles(tribeFileFolder).Where(f => Path.GetFileNameWithoutExtension(f).StartsWith(DataFileDetails.TribeFilePrefix) &&
                                                                       Path.GetFileNameWithoutExtension(f).EndsWith(DataFileDetails.TribeFileSuffix) &&
                                                                       Path.GetExtension(f).Equals(DataFileDetails.TribeFileExtension)).ToArray();
            }

            var container = new DataContainer();

            foreach (var file in playerFiles)
            {
                container.Players.Add(Parser.ParsePlayer(file));
            }

            foreach (var file in tribeFiles)
            {
                container.Tribes.Add(Parser.ParseTribe(file));
            }

            container.LinkPlayerTribe();

            return(container);
        }