Example #1
0
        /// <summary>
        /// Return a text-representation of this object.
        /// </summary>
        public override String ToString()

        => String.Concat(Periods.AggregateWith(", "),
                         " -> ",
                         On.AsString(),
                         UnstructuredText.IsNotNullOrEmpty()
                                 ? "; " + UnstructuredText
                                 : "");
Example #2
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="CustomOpeningTimesSerializer">A delegate to serialize custom opening time JSON objects.</param>
        public JObject ToJSON(CustomJObjectSerializerDelegate <OpeningTime> CustomOpeningTimesSerializer = null)
        {
            var JSON = JSONObject.Create(

                Periods.SafeAny()
                               ? new JProperty("Period", new JArray(Periods.Select(period => period.ToJSON())))
                               : null,

                new JProperty("on", On.AsString()),

                UnstructuredText.IsNotNullOrEmpty()
                               ? new JProperty("unstructuredOpeningTime", UnstructuredText)
                               : null

                );

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