コード例 #1
0
 public static EPuzzleUserInfoContainer CreateFrom(string directoryName)
 {
     if (GetNamesOfSettingsFiles(directoryName).Any())
     {
         return LoadAllFilesFrom(directoryName);
     }
     else
     {
         var container = new EPuzzleUserInfoContainer();
         container.Items.Add(new EPuzzleUserInfo());
         return container;
     }
 }
コード例 #2
0
 public static EPuzzleUserInfoContainer LoadAllFilesFrom(string directoryName)
 {
     var container = new EPuzzleUserInfoContainer();
     var settingsFiles = GetNamesOfSettingsFiles(directoryName);
     if (!settingsFiles.Any()) throw new ApplicationException(string.Format("No settings files were found at the specified directory. : '{0}'", directoryName));
     var resultsFiles = settingsFiles.Select(x =>
     {
         var match = Regex.Match(x, @"\Settings\.([^.]+)\.xml$");
         if (!match.Success) throw new ApplicationException(string.Format("The name '{0}' of the settings file is invalid.", x));
         return Path.Combine(directoryName, string.Format("Results.{0}.dat", match.Groups[1].Value));
     });
     var userInfos = settingsFiles.Zip(resultsFiles, (settings, results) => EPuzzleUserInfo.Load(settings, results));
     container.Items.AddRange(userInfos.OrderBy(x => x.UserName));
     return container;
 }