Ejemplo n.º 1
0
 /// <summary>
 /// Constructs an instance of <see cref="Month"/> from integer year and month numbers.
 /// </summary>
 /// <param name="year">The number of the year being constructed. Must be in the inclusive range 1 to 9998.</param>
 /// <param name="month">The number of the month of the year for the month being constructed, with 1 representing
 /// January, 2 February etc.</param>
 /// <exception cref="ArgumentOutOfRangeException">Either the year or month parameters is outside of the range of permissible
 /// years or months respectively.</exception>
 public Month(int year, int month)
 {
     Preconditions.CheckArgumentOutOfRange(nameof(year), year, Constants.MinCalendarYearNum, Constants.MaxCalendarYearNum);
     Preconditions.CheckArgumentOutOfRange(nameof(month), month, 1, 12);
     _value = (year - 1) * 12 + month - 1;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructs an instance of <see cref="Month"/> by directly setting the private integer _value field.
 /// </summary>
 /// <param name="value">Integer value to assign to private _value field.</param>
 private Month(int value)
 {
     Preconditions.CheckArgumentOutOfRange(nameof(value), value, MinValue, MaxValue);
     _value = value;
 }
Ejemplo n.º 3
0
 /// <inheritdoc/>
 void IXmlSerializable.WriteXml(XmlWriter writer)
 {
     Preconditions.CheckParameterNotNull(writer, nameof(writer));
     writer.WriteString(ToString());
 }