Example #1
0
        public static void InitLogger()
        {
            if (!Directory.Exists(LogFolder))
                Directory.CreateDirectory(LogFolder);

            var logs = new DirectoryInfo(LogFolder).GetFiles().OrderBy(s => s.LastWriteTime).ToList();
            while (logs.Count() >= ServerMain.settings.maximumLogs)
            {
                var first = logs.First();
                first.Delete();
                logs.Remove(first);
            }
        }
Example #2
0
 public static FileInfo FindSolution(string path)
 {
     var solutions =  new DirectoryInfo(path).GetFiles("*.sln", SearchOption.AllDirectories);
     if (solutions.Length == 0)
         throw new Exception("No solution found");
     if (solutions.Length == 1)
         return solutions.First();
     // candidates.Length > 1
     var candidatesByDepth = solutions.GroupBy(x => x.FullName.Count(ch => ch == '/')).ToList();
     var minKey2 = candidatesByDepth.Min(x => x.Key);
     var topLevelCandidates = candidatesByDepth.First(x => x.Key == minKey2);
     if (topLevelCandidates.Count() == 1)
         return topLevelCandidates.First();
     //TopLevelCandidates > 1
     var dirName = Path.GetFileName(path);
     var matchesName = solutions.Where(x => x.Name == dirName).ToList();
     if (matchesName.Count == 1)
         return matchesName.First();
     throw new Exception("Could not find solution");
 }