ParseTribeAsync() public static méthode

public static ParseTribeAsync ( string fileName ) : Task
fileName string
Résultat Task
Exemple #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>
        /// <returns>The async task context containing the resulting container.</returns>
        public static async Task <ArkDataContainer> CreateAsync(string directory)
        {
            if (!Directory.Exists(directory))
            {
                throw new DirectoryNotFoundException("The ARK data directory couldn't be found.");
            }

            var playerFiles = Directory.GetFiles(directory).Where(p => p.ToLower().Contains(".arkprofile")).ToArray();
            var tribeFiles  = Directory.GetFiles(directory).Where(p => p.ToLower().Contains(".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(await Parser.ParsePlayerAsync(playerFiles[i]));
            }

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

            container.LinkPlayerTribe();

            return(container);
        }
        /// <summary>
        /// Instantiates the DataContainer and parses all the user-data files
        /// </summary>
        /// <returns>The async task context containing the resulting container.</returns>
        public static async Task <DataContainer> CreateAsync(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(await Parser.ParsePlayerAsync(file));
            }

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

            container.LinkPlayerTribe();

            return(container);
        }