Example #1
0
        public static ParticipantMiscProperties Parse(string miscString)
        {
            var result = new ParticipantMiscProperties();

            var splitString = miscString.Split(';');

            if (splitString.Length == 3)
            {
                DateTime dateTimeBuffer;

                if (DateTime.TryParse(splitString[0], out dateTimeBuffer))
                {
                    result.UtcTimeMissing = dateTimeBuffer;
                }
                if (DateTime.TryParse(splitString[1], out dateTimeBuffer))
                {
                    result.UtcTimeMatchAssigned = dateTimeBuffer;
                }
                if (splitString[2] != "{NULL}")
                {
                    result.StationAssignment = splitString[2];
                }
            }

            return(result);
        }
Example #2
0
        public ObservableParticipant(Participant participant, TournamentContext context)
        {
            source         = participant;
            MiscProperties = new Dirtyable <ParticipantMiscProperties>(ParticipantMiscProperties.Parse(Misc));
            OwningContext  = context;

            //Check tournament start date, if it is later than missing time, clear the player's missing status. This happens in the case of a bracket reset
            var tournamentStart = context.Tournament.StartedAt;

            if (UtcTimeMissing.HasValue && tournamentStart.HasValue && UtcTimeMissing.Value.ToLocalTime() < tournamentStart.Value)
            {
                SetMissing(false);
            }

            //Do a similar check on station assignment time
            if (UtcTimeMatchAssigned.HasValue && tournamentStart.HasValue && UtcTimeMatchAssigned.Value.ToLocalTime() < tournamentStart.Value)
            {
                ClearStationAssignment();
            }

            //Listen for when properties changed to that changed events for the convenience properties can also be fired.
            this.PropertyChanged += (sender, e) =>
            {
                switch (e.PropertyName)
                {
                case "Misc":
                    //Handle misc string changes by parsing the new values and raising the properties that have changed
                    var oldMiscProperties = MiscProperties.Value;

                    //Suggest new value for misc properties. This will be ignored if dirty
                    MiscProperties.SuggestValue(ParticipantMiscProperties.Parse(Misc));
                    var miscProperties = MiscProperties.Value;

                    //Check for changes from old to new, raise those properties if changed
                    if (!object.Equals(oldMiscProperties.UtcTimeMissing, miscProperties.UtcTimeMissing))
                    {
                        this.Raise("UtcTimeMissing", PropertyChanged);
                    }
                    if (!object.Equals(oldMiscProperties.UtcTimeMatchAssigned, miscProperties.UtcTimeMatchAssigned))
                    {
                        this.Raise("UtcTimeMatchAssigned", PropertyChanged);
                    }
                    if (!object.Equals(oldMiscProperties.StationAssignment, miscProperties.StationAssignment))
                    {
                        this.Raise("StationAssignment", PropertyChanged);
                    }
                    break;

                case "UtcTimeMissing":
                    this.Raise("IsMissing", PropertyChanged);
                    this.Raise("TimeSinceMissing", PropertyChanged);
                    break;

                case "UtcTimeMatchAssigned":
                    this.Raise("TimeSinceAssigned", PropertyChanged);
                    this.Raise("IsAssignedToStation", PropertyChanged);
                    break;
                }
            };
        }
        public static ParticipantMiscProperties Parse(string miscString)
        {
            var result = new ParticipantMiscProperties();

            var splitString = miscString.Split(';');

            if (splitString.Length == 3)
            {
                DateTime dateTimeBuffer;

                if (DateTime.TryParse(splitString[0], out dateTimeBuffer)) result.UtcTimeMissing = dateTimeBuffer;
                if (DateTime.TryParse(splitString[1], out dateTimeBuffer)) result.UtcTimeMatchAssigned = dateTimeBuffer;
                if (splitString[2] != "{NULL}") result.StationAssignment = splitString[2];
            }

            return result;
        }