@@ -188,47 +188,34 @@ public abstract class DavIso8601Date<TEntry> : DavTypedProperty<TEntry, DateTime
188
188
{
189
189
private readonly Iso8601DateConverter _converter ;
190
190
191
- protected DavIso8601Date ( IHttpContextAccessor httpContextAccessor )
191
+ protected DavIso8601Date ( )
192
192
{
193
- _converter = new Iso8601DateConverter ( httpContextAccessor ) ;
193
+ _converter = Iso8601DateConverter . Instance ;
194
194
}
195
195
196
196
private class Iso8601DateConverter : IConverter
197
197
{
198
- private readonly IHttpContextAccessor _httpContextAccessor ;
199
-
200
- public Iso8601DateConverter ( IHttpContextAccessor httpContextAccessor )
198
+ internal static readonly Iso8601DateConverter Instance = new ( ) ;
199
+ Iso8601DateConverter ( )
201
200
{
202
- _httpContextAccessor = httpContextAccessor ;
203
201
}
204
202
205
203
public object ToXml ( DateTime value )
206
204
{
207
205
// The older built-in Windows WebDAV clients have a problem, so
208
206
// they cannot deal with more than 3 digits for the
209
207
// milliseconds.
210
- if ( HasIso8601FractionBug )
211
- {
212
- // We need to recreate the date again, because the Windows 7
213
- // WebDAV client cannot
214
- var dt = new DateTime ( value . Year , value . Month , value . Day , value . Hour , value . Minute , value . Second , value . Millisecond , DateTimeKind . Utc ) ;
215
- return XmlConvert . ToString ( dt , XmlDateTimeSerializationMode . Utc ) ;
216
- }
217
208
218
- return XmlConvert . ToString ( value , XmlDateTimeSerializationMode . Utc ) ;
209
+ // P.S. I think the previous comment meant "less than 3 digits".
210
+
211
+ // We need to recreate the date again, because the Windows 7
212
+ // WebDAV client cannot
213
+ var dt = new DateTime ( value . Year , value . Month , value . Day , value . Hour , value . Minute , value . Second , value . Millisecond , DateTimeKind . Utc ) ;
214
+ return XmlConvert . ToString ( dt , XmlDateTimeSerializationMode . Utc ) ;
219
215
}
220
216
221
217
public DateTime FromXml ( object value ) => XmlConvert . ToDateTime ( ( string ) value , XmlDateTimeSerializationMode . Utc ) ;
222
218
223
- private bool HasIso8601FractionBug
224
- {
225
- get
226
- {
227
- var userAgent = _httpContextAccessor . HttpContext ? . Request . Headers . UserAgent . FirstOrDefault ( ) ;
228
- _ = userAgent ; // TODO: Determine if this bug is present based on the user-agent
229
- return true ;
230
- }
231
- }
232
219
}
233
220
234
221
/// <summary>
0 commit comments