Code Coverage Statistics for Source File
Newtonsoft.Json\Converters\DateTimeConverterBase.cs
Symbol Coverage: 100.00% (6 of 6)
Branch Coverage: 100.00% (8 of 8)
Cyclomatic Complexity Avg: 3.00 Max:5
Code Lines: 6
Symbol Coverage Trend
View:
L | V | Source |
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
||
6 |
namespace Newtonsoft.Json.Converters |
|
7 |
{ |
|
8 |
/// <summary> |
|
9 |
/// Provides a base class for converting a <see cref="DateTime"/> to and from JSON. |
|
10 |
/// </summary> |
|
11 |
public abstract class DateTimeConverterBase : JsonConverter |
|
12 |
{ |
|
13 |
/// <summary> |
|
14 |
/// Determines whether this instance can convert the specified object type. |
|
15 |
/// </summary> |
|
16 |
/// <param name="objectType">Type of the object.</param> |
|
17 |
/// <returns> |
|
18 |
/// <c>true</c> if this instance can convert the specified object type; otherwise, <c>false</c>. |
|
19 |
/// </returns> |
|
20 |
public override bool CanConvert(Type objectType) |
|
21 |
{ |
|
22 |
251 |
if (objectType == typeof(DateTime) || objectType == typeof(DateTime?))
|
23 |
77 |
return true;
|
24 |
#if !PocketPC && !NET20 |
|
25 |
174 |
if (objectType == typeof(DateTimeOffset) || objectType == typeof(DateTimeOffset?))
|
26 |
16 |
return true;
|
27 |
#endif |
|
28 |
||
29 |
158 |
return false;
|
30 |
251 |
}
|
31 |
} |
|
32 |
} |