Пример #1
0
        private static Guards CreateModel(Guards guards, LogDto logLine)
        {
            Regex idRegex = new Regex(@"^.*#(\d*).*$", RegexOptions.Compiled);

            if (logLine.Value.Contains('#'))
            {
                Match idMatch = idRegex.Match(logLine.Value);
                int   id      = int.Parse(idMatch.Groups[1].Value);
                var   guard   = new Guard(id);
                guards.Add(guard);
            }
            else
            {
                var sleepEvent = new SleepEvent
                {
                    DateTime        = logLine.DateTime,
                    IsFallingAsleep = logLine.Value.Contains("asleep")
                };
                guards.Add(sleepEvent);
            }
            return(guards);
        }
Пример #2
0
 public void Add(SleepEvent @event)
 {
     LastGuard.Events.Add(@event);
 }