|
20 | 20 |
|
21 | 21 | using System; |
22 | 22 | using System.IO; |
| 23 | +#if ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
23 | 24 | using System.Runtime.InteropServices.ComTypes; |
| 25 | +#endif // ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
24 | 26 |
|
25 | 27 | using MsgPack.Serialization.DefaultSerializers; |
26 | 28 |
|
@@ -51,7 +53,9 @@ private static void TestSerializationCore( SerializationContext context, DateTim |
51 | 53 | Timestamp = now, |
52 | 54 | DateTime = dateTimeNow.AddSeconds( 1 ).UtcDateTime, |
53 | 55 | DateTimeOffset = dateTimeNow.AddSeconds( 2 ), |
| 56 | +#if ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
54 | 57 | FileTime = now.Add( TimeSpan.FromSeconds( 3 ) ).ToDateTime().ToWin32FileTimeUtc() |
| 58 | +#endif // ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
55 | 59 | }; |
56 | 60 |
|
57 | 61 | using ( var buffer = new MemoryStream() ) |
@@ -117,23 +121,29 @@ private static void TestSerializationCore( SerializationContext context, DateTim |
117 | 121 | Assert.That( result.Timestamp, Is.EqualTo( new Timestamp( now.UnixEpochSecondsPart, now.NanosecondsPart / 100 * 100 ) ) ); |
118 | 122 | Assert.That( result.DateTime, Is.EqualTo( now.ToDateTime().AddSeconds( 1 ) ) ); |
119 | 123 | Assert.That( result.DateTimeOffset, Is.EqualTo( now.ToDateTimeOffset().AddSeconds( 2 ) ) ); |
| 124 | +#if ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
120 | 125 | Assert.That( result.FileTime, Is.EqualTo( now.Add( TimeSpan.FromSeconds( 3 ).Subtract( TimeSpan.FromTicks( now.NanosecondsPart % 100 ) ) ).ToDateTime().ToWin32FileTimeUtc() ) ); |
| 126 | +#endif // ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
121 | 127 | break; |
122 | 128 | } |
123 | 129 | case DateTimeConversionMethod.UnixEpoc: |
124 | 130 | { |
125 | 131 | Assert.That( result.Timestamp, Is.EqualTo( new Timestamp( now.UnixEpochSecondsPart, now.NanosecondsPart / 1000000 * 1000000 ) ) ); |
126 | 132 | Assert.That( result.DateTime, Is.EqualTo( now.ToDateTime().AddSeconds( 1 ).Subtract( TimeSpan.FromTicks( now.NanosecondsPart / 100 % 10000 ) ) ) ); |
127 | 133 | Assert.That( result.DateTimeOffset, Is.EqualTo( now.ToDateTimeOffset().AddSeconds( 2 ).Subtract( TimeSpan.FromTicks( now.NanosecondsPart / 100 % 10000 ) ) ) ); |
| 134 | +#if ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
128 | 135 | Assert.That( result.FileTime, Is.EqualTo( now.Add( TimeSpan.FromSeconds( 3 ).Subtract( TimeSpan.FromTicks( now.NanosecondsPart / 100 % 10000 ) ) ).ToDateTime().ToWin32FileTimeUtc() ) ); |
| 136 | +#endif // ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
129 | 137 | break; |
130 | 138 | } |
131 | 139 | case DateTimeConversionMethod.Timestamp: |
132 | 140 | { |
133 | 141 | Assert.That( result.Timestamp, Is.EqualTo( now ) ); |
134 | 142 | Assert.That( result.DateTime, Is.EqualTo( now.ToDateTime().AddSeconds( 1 ) ) ); |
135 | 143 | Assert.That( result.DateTimeOffset, Is.EqualTo( now.ToDateTimeOffset().AddSeconds( 2 ) ) ); |
| 144 | +#if ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
136 | 145 | Assert.That( result.FileTime, Is.EqualTo( now.Add( TimeSpan.FromSeconds( 3 ) ).ToDateTime().ToWin32FileTimeUtc() ) ); |
| 146 | +#endif // ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
137 | 147 | break; |
138 | 148 | } |
139 | 149 | } |
@@ -230,23 +240,29 @@ private static void TestDeserializationCore( DateTimeConversionMethod kind ) |
230 | 240 | Assert.That( result.Timestamp, Is.EqualTo( new Timestamp( now.UnixEpochSecondsPart, now.NanosecondsPart / 100 * 100 ) ) ); |
231 | 241 | Assert.That( result.DateTime, Is.EqualTo( now.ToDateTime().AddSeconds( 1 ) ) ); |
232 | 242 | Assert.That( result.DateTimeOffset, Is.EqualTo( now.ToDateTimeOffset().AddSeconds( 2 )) ); |
| 243 | +#if ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
233 | 244 | Assert.That( result.FileTime, Is.EqualTo( now.Add( TimeSpan.FromSeconds( 3 ).Subtract( TimeSpan.FromTicks( now.NanosecondsPart % 100 ) ) ).ToDateTime().ToWin32FileTimeUtc() ) ); |
| 245 | +#endif // ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
234 | 246 | break; |
235 | 247 | } |
236 | 248 | case DateTimeConversionMethod.UnixEpoc: |
237 | 249 | { |
238 | 250 | Assert.That( result.Timestamp, Is.EqualTo( new Timestamp( now.UnixEpochSecondsPart, now.NanosecondsPart / 1000000 * 1000000 ) ) ); |
239 | 251 | Assert.That( result.DateTime, Is.EqualTo( now.ToDateTime().AddSeconds( 1 ).Subtract( TimeSpan.FromTicks( now.NanosecondsPart / 100 % 10000 ) ) ) ); |
240 | 252 | Assert.That( result.DateTimeOffset, Is.EqualTo( now.ToDateTimeOffset().AddSeconds( 2 ).Subtract( TimeSpan.FromTicks( now.NanosecondsPart / 100 % 10000 ) ) ) ); |
| 253 | +#if ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
241 | 254 | Assert.That( result.FileTime, Is.EqualTo( now.Add( TimeSpan.FromSeconds( 3 ).Subtract( TimeSpan.FromTicks( now.NanosecondsPart / 100 % 10000 ) ) ).ToDateTime().ToWin32FileTimeUtc() ) ); |
| 255 | +#endif // ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
242 | 256 | break; |
243 | 257 | } |
244 | 258 | case DateTimeConversionMethod.Timestamp: |
245 | 259 | { |
246 | 260 | Assert.That( result.Timestamp, Is.EqualTo( now ) ); |
247 | 261 | Assert.That( result.DateTime, Is.EqualTo( now.ToDateTime().AddSeconds( 1 ) ) ); |
248 | 262 | Assert.That( result.DateTimeOffset, Is.EqualTo( now.ToDateTimeOffset().AddSeconds( 2 ) ) ); |
| 263 | +#if ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
249 | 264 | Assert.That( result.FileTime, Is.EqualTo( now.Add( TimeSpan.FromSeconds( 3 ) ).ToDateTime().ToWin32FileTimeUtc() ) ); |
| 265 | +#endif // ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
250 | 266 | break; |
251 | 267 | } |
252 | 268 | } |
@@ -274,15 +290,21 @@ public void TestDeserialization_FromUnixEpoc() |
274 | 290 |
|
275 | 291 | public class ClassHasTimestamp |
276 | 292 | { |
| 293 | +#if ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
277 | 294 | internal const int MemberCount = 4; |
| 295 | +#else // ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
| 296 | + internal const int MemberCount = 3; |
| 297 | +#endif // ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
278 | 298 |
|
279 | 299 | [MessagePackMember( 0 )] |
280 | 300 | public Timestamp Timestamp { get; set; } |
281 | 301 | [MessagePackMember( 1 )] |
282 | 302 | public DateTime DateTime { get; set; } |
283 | 303 | [MessagePackMember( 2 )] |
284 | 304 | public DateTimeOffset DateTimeOffset { get; set; } |
| 305 | +#if ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
285 | 306 | [MessagePackMember( 3 )] |
286 | 307 | public FILETIME FileTime { get; set; } |
| 308 | +#endif // ( !SILVERLIGHT || WINDOWS_PHONE ) && !XAMARIN && !UNITY && !UNITY |
287 | 309 | } |
288 | 310 | } |
0 commit comments