Beispiel #1
0
        protected bool Equals(WeeklyReleaseSchedule other)
        {
            if (this.Value != null && other.Value != null)
            {
                if (!this.Value.SequenceEqual(other.Value))
                {
                    return(false);
                }
            }
            else if (this.Value != null || other.Value != null)
            {
                return(false);
            }

            return(true);
        }
        public static bool TryParse(IReadOnlyList <HourOfWeek> value, out WeeklyReleaseSchedule weeklyReleaseSchedule, out IReadOnlyCollection <string> errorMessages)
        {
            var errorMessageList = new List <string>();

            errorMessages = errorMessageList;

            if (IsEmpty(value))
            {
                // TryParse should never fail, so report null as an error instead of ArgumentNullException.
                errorMessageList.Add("Value required");
            }
            else
            {
                if (value.Count > MaxElements)
                {
                    errorMessageList.Add(string.Format("Must have no more than {0} release times", MaxElements));
                }

                if (value.Distinct().Count() != value.Count)
                {
                    errorMessageList.Add("Release times must be unique");
                }
            }

            if (errorMessageList.Count > 0)
            {
                weeklyReleaseSchedule = null;
                return(false);
            }

            weeklyReleaseSchedule = new WeeklyReleaseSchedule
            {
                Value = value.OrderBy(_ => _.Value).ToArray()
            };

            return(true);
        }
        public static bool TryParse(IReadOnlyList <HourOfWeek> value, out WeeklyReleaseSchedule weeklyReleaseSchedule)
        {
            IReadOnlyCollection <string> errorMessages;

            return(TryParse(value, out weeklyReleaseSchedule, out errorMessages));
        }