/// <summary> /// 获取所有能够正常被解析的游戏信息。 /// Fetch all the game versions' information in the .minecraft/ folder. /// </summary> /// <returns>一个表,包含.minecraft文件夹中所有版本的所有信息。A list, containing all information of all games in .minecraft/ .</returns> public IEnumerable <VersionInfo> GetAllGames() { // 把每个DirectoryInfo类映射到VersionInfo类。 // Map each DirectoryInfo dir to VersionInfo class. return(new DirectoryInfo(GamePathHelper.GetVersionPath(RootPath)).EnumerateDirectories() .Select(dir => ToVersion(dir.Name)).Where(ver => ver != null)); }
/// <summary> /// 构造函数 /// </summary> /// <param name="rootPath"></param> /// <param name="clientToken"></param> public DefaultVersionLocator(string rootPath, Guid clientToken) { RootPath = rootPath; LauncherProfileParser = new DefaultLauncherProfileParser(rootPath, clientToken); if (!Directory.Exists(GamePathHelper.GetVersionPath(RootPath))) { Directory.CreateDirectory(GamePathHelper.GetVersionPath(RootPath)); } }
/// <summary> /// 构造函数。 /// Constructor. /// </summary> /// <param name="rootPath">指.minecraft/ Refers to .minecraft/</param> /// <param name="clientToken"></param> public DefaultVersionLocator(string rootPath, Guid clientToken) { RootPath = rootPath; // .minecraft/ LauncherProfileParser = new DefaultLauncherProfileParser(rootPath, clientToken); //防止给定路径不存在的时候Parser遍历文件夹爆炸。 //Prevents errors in the parser's folder traversal when the given path does not exist. if (!Directory.Exists(GamePathHelper.GetVersionPath(RootPath))) { Directory.CreateDirectory(GamePathHelper.GetVersionPath(RootPath)); } }
public override IEnumerable <VersionInfo> GetAllGames() { // 把每个DirectoryInfo类映射到VersionInfo类。 // Map each DirectoryInfo dir to VersionInfo class. var di = new DirectoryInfo(GamePathHelper.GetVersionPath(RootPath)); foreach (var dir in di.EnumerateDirectories()) { var version = ToVersion(dir.Name); if (version == null) { continue; } yield return(version); } }
/// <summary> /// 获取所有能够正常被解析的游戏信息 /// </summary> /// <returns></returns> public IEnumerable <VersionInfo> GetAllGames() { return(new DirectoryInfo(GamePathHelper.GetVersionPath(RootPath)).EnumerateDirectories() .Select(dir => ToVersion(dir.Name)).Where(ver => ver != null)); }