Ejemplo n.º 1
0
        public Attempt(User user, Level level, FileInfo attemptFile)
        {
            this.user        = user;
            this.level       = level;
            this.attemptFile = attemptFile;

            Match match = attemptFilenameRegex.Match(Path.GetFileName(attemptFile.FullName));

            this.attemptNum = int.Parse(match.Groups["attemptNum"].Value);

            int year   = int.Parse(match.Groups["year"].Value);
            int month  = int.Parse(match.Groups["month"].Value);
            int day    = int.Parse(match.Groups["day"].Value);
            int hour   = int.Parse(match.Groups["hour"].Value);
            int minute = int.Parse(match.Groups["minute"].Value);
            int second = int.Parse(match.Groups["second"].Value);

            this.timestamp = new DateTime(year: year, month: month, day: day,
                                          hour: hour, minute: minute, second: second,
                                          kind: DateTimeKind.Utc);

            if (match.Groups["rating"].Success)
            {
                this.rating = int.Parse(match.Groups["rating"].Value);
            }
            else
            {
                this.rating = null;
            }

            this.language = LanguageUtil.FromExtension(match.Groups["ext"].Value);
        }