/// <include file='doc\DateTimeFormatInfo.uex' path='docs/doc[@for="DateTimeFormatInfo.ReadOnly"]/*' /> public static DateTimeFormatInfo ReadOnly(DateTimeFormatInfo dtfi) { if (dtfi == null) { throw new ArgumentNullException("dtfi"); } if (dtfi.IsReadOnly) { return (dtfi); } DateTimeFormatInfo info = (DateTimeFormatInfo)(dtfi.MemberwiseClone()); info.m_isReadOnly = true; return (info); }
public static DateTimeFormatInfo ReadOnly(DateTimeFormatInfo dtfi) { if (dtfi == null) throw new ArgumentNullException("dtfi", Environment.GetResourceString("ArgumentNull_Obj")); if (dtfi.IsReadOnly) return dtfi; DateTimeFormatInfo dateTimeFormatInfo = (DateTimeFormatInfo) dtfi.MemberwiseClone(); dateTimeFormatInfo.calendar = Calendar.ReadOnly(dtfi.Calendar); dateTimeFormatInfo.m_isReadOnly = true; return dateTimeFormatInfo; }
public static DateTimeFormatInfo ReadOnly(DateTimeFormatInfo dtfi) { if (dtfi == null) { throw new ArgumentNullException("dtfi", Environment.GetResourceString("ArgumentNull_Obj")); } Contract.EndContractBlock(); if (dtfi.IsReadOnly) { return (dtfi); } DateTimeFormatInfo newInfo = (DateTimeFormatInfo)(dtfi.MemberwiseClone()); // We can use the data member calendar in the setter, instead of the property Calendar, // since the cloned copy should have the same state as the original copy. newInfo.calendar = Calendar.ReadOnly(dtfi.Calendar); newInfo.m_isReadOnly = true; return (newInfo); }
public static DateTimeFormatInfo ReadOnly(DateTimeFormatInfo dtfi) { if (dtfi == null) { throw new ArgumentNullException("dtfi", Environment.GetResourceString("ArgumentNull_Obj")); } if (dtfi.IsReadOnly) { return dtfi; } DateTimeFormatInfo info = (DateTimeFormatInfo) dtfi.MemberwiseClone(); info.Calendar = System.Globalization.Calendar.ReadOnly(info.Calendar); info.m_isReadOnly = true; return info; }