Ejemplo n.º 1
0
 /// <summary>
 /// Return the hash code of this object.
 /// </summary>
 /// <returns>The hash code of this object.</returns>
 public override Int32 GetHashCode()
 {
     unchecked
     {
         return(IsTwentyFourSevenOpen.GetHashCode() * 3 ^
                RegularHours.Aggregate(0, (hashCode, dimension) => hashCode ^ dimension.GetHashCode()) ^
                ExceptionalOpenings.Aggregate(0, (hashCode, period) => hashCode ^ period.GetHashCode()) ^
                ExceptionalClosings.Aggregate(0, (hashCode, period) => hashCode ^ period.GetHashCode()));
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="CustomHoursSerializer">A delegate to serialize custom hours JSON objects.</param>
        public JObject ToJSON(CustomJObjectSerializerDelegate <Hours> CustomHoursSerializer = null)
        {
            var JSON = JSONObject.Create(

                new JProperty("twentyfourseven", IsTwentyFourSevenOpen),

                RegularHours.SafeAny()
                               ? new JProperty("regular_hours", new JArray(RegularHours.Select(hours => hours.ToJSON())))
                               : null,

                ExceptionalOpenings.SafeAny()
                               ? new JProperty("exceptional_openings", new JArray(ExceptionalOpenings.Select(opening => opening.ToJSON())))
                               : null,

                ExceptionalClosings.SafeAny()
                               ? new JProperty("exceptional_closings", new JArray(ExceptionalClosings.Select(closing => closing.ToJSON())))
                               : null

                );

            return(CustomHoursSerializer != null
                       ? CustomHoursSerializer(this, JSON)
                       : JSON);
        }