// // Copyright (c) Microsoft Corporation. All rights reserved. // namespace System.Runtime.Serialization { using System.Globalization; /// /// This class is used to customize the way DateTime is /// serialized or deserialized by /// public class DateTimeFormat { private string formatString; private IFormatProvider formatProvider; private DateTimeStyles dateTimeStyles; /// /// Initailizes a new with the specified /// formatString and DateTimeFormatInfo.CurrentInfo as the /// formatProvider. /// /// Specifies the formatString to be used. public DateTimeFormat(string formatString) : this(formatString, DateTimeFormatInfo.CurrentInfo) { } /// /// Initailizes a new with the specified /// formatString and formatProvider. /// /// Specifies the formatString to be used. /// Specifies the formatProvider to be used. public DateTimeFormat(string formatString, IFormatProvider formatProvider) { if (formatString == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("formatString"); } if (formatProvider == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("formatProvider"); } this.formatString = formatString; this.formatProvider = formatProvider; this.dateTimeStyles = DateTimeStyles.RoundtripKind; } /// /// Gets the FormatString set on this instance. /// public string FormatString { get { return this.formatString; } } /// /// Gets the FormatProvider set on this instance. /// public IFormatProvider FormatProvider { get { return this.formatProvider; } } /// /// Gets or sets the on this instance. /// public DateTimeStyles DateTimeStyles { get { return this.dateTimeStyles; } set { this.dateTimeStyles = value; } } } }