1
1
using System ;
2
2
using System . Collections . Generic ;
3
+ using System . Globalization ;
3
4
using System . Linq ;
4
- using Octokit ;
5
5
using UnityEditor ;
6
6
using UnityEngine ;
7
7
using Application = UnityEngine . Application ;
@@ -19,18 +19,7 @@ public bool FirstRun
19
19
{
20
20
get
21
21
{
22
- if ( ! firstRunValue . HasValue )
23
- {
24
- firstRunValue = firstRun ;
25
- }
26
-
27
- if ( firstRun )
28
- {
29
- firstRun = false ;
30
- FirstRunAt = DateTimeOffset . Now ;
31
- Save ( true ) ;
32
- }
33
-
22
+ EnsureFirstRun ( ) ;
34
23
return firstRunValue . Value ;
35
24
}
36
25
}
@@ -39,17 +28,34 @@ public DateTimeOffset FirstRunAt
39
28
{
40
29
get
41
30
{
31
+ EnsureFirstRun ( ) ;
32
+
42
33
if ( ! firstRunAtValue . HasValue )
43
34
{
44
- firstRunAtValue = DateTimeOffset . Parse ( firstRunAtString ) ;
35
+ firstRunAtValue = DateTimeOffset . ParseExact ( firstRunAtString , Constants . Iso8601Format , CultureInfo . InvariantCulture ) ;
45
36
}
46
37
47
38
return firstRunAtValue . Value ;
48
39
}
49
40
private set
50
41
{
51
- firstRunAtString = value . ToString ( ) ;
52
- firstRunAtValue = null ;
42
+ firstRunAtString = value . ToString ( Constants . Iso8601Format ) ;
43
+ firstRunAtValue = value ;
44
+ }
45
+ }
46
+
47
+ private void EnsureFirstRun ( )
48
+ {
49
+ if ( ! firstRunValue . HasValue )
50
+ {
51
+ firstRunValue = firstRun ;
52
+ }
53
+
54
+ if ( firstRun )
55
+ {
56
+ firstRun = false ;
57
+ FirstRunAt = DateTimeOffset . Now ;
58
+ Save ( true ) ;
53
59
}
54
60
}
55
61
}
@@ -183,15 +189,23 @@ public DateTimeOffset LastUpdatedAt
183
189
{
184
190
if ( ! lastUpdatedAtValue . HasValue )
185
191
{
186
- lastUpdatedAtValue = DateTimeOffset . Parse ( LastUpdatedAtString ) ;
192
+ DateTimeOffset result ;
193
+ if ( DateTimeOffset . TryParseExact ( LastUpdatedAtString , Constants . Iso8601Format , CultureInfo . InvariantCulture , DateTimeStyles . None , out result ) )
194
+ {
195
+ lastUpdatedAtValue = result ;
196
+ }
197
+ else
198
+ {
199
+ lastUpdatedAtValue = DateTimeOffset . MinValue ;
200
+ }
187
201
}
188
202
189
203
return lastUpdatedAtValue . Value ;
190
204
}
191
205
set
192
206
{
193
- LastUpdatedAtString = value . ToString ( ) ;
194
- lastUpdatedAtValue = null ;
207
+ LastUpdatedAtString = value . ToString ( Constants . Iso8601Format ) ;
208
+ lastUpdatedAtValue = value ;
195
209
}
196
210
}
197
211
@@ -201,15 +215,23 @@ public DateTimeOffset LastVerifiedAt
201
215
{
202
216
if ( ! lastVerifiedAtValue . HasValue )
203
217
{
204
- lastVerifiedAtValue = DateTimeOffset . Parse ( LastVerifiedAtString ) ;
218
+ DateTimeOffset result ;
219
+ if ( DateTimeOffset . TryParseExact ( LastVerifiedAtString , Constants . Iso8601Format , CultureInfo . InvariantCulture , DateTimeStyles . None , out result ) )
220
+ {
221
+ lastVerifiedAtValue = result ;
222
+ }
223
+ else
224
+ {
225
+ lastVerifiedAtValue = DateTimeOffset . MinValue ;
226
+ }
205
227
}
206
228
207
229
return lastVerifiedAtValue . Value ;
208
230
}
209
231
set
210
232
{
211
- LastVerifiedAtString = value . ToString ( ) ;
212
- lastVerifiedAtValue = null ;
233
+ LastVerifiedAtString = value . ToString ( Constants . Iso8601Format ) ;
234
+ lastVerifiedAtValue = value ;
213
235
}
214
236
}
215
237
@@ -219,15 +241,23 @@ public DateTimeOffset InitializedAt
219
241
{
220
242
if ( ! initializedAtValue . HasValue )
221
243
{
222
- initializedAtValue = DateTimeOffset . Parse ( InitializedAtString ) ;
244
+ DateTimeOffset result ;
245
+ if ( DateTimeOffset . TryParseExact ( InitializedAtString , Constants . Iso8601Format , CultureInfo . InvariantCulture , DateTimeStyles . None , out result ) )
246
+ {
247
+ initializedAtValue = result ;
248
+ }
249
+ else
250
+ {
251
+ initializedAtValue = DateTimeOffset . MinValue ;
252
+ }
223
253
}
224
254
225
255
return initializedAtValue . Value ;
226
256
}
227
257
set
228
258
{
229
- InitializedAtString = value . ToString ( ) ;
230
- initializedAtValue = null ;
259
+ InitializedAtString = value . ToString ( Constants . Iso8601Format ) ;
260
+ initializedAtValue = value ;
231
261
}
232
262
}
233
263
@@ -348,106 +378,6 @@ public void OnAfterDeserialize()
348
378
Add ( remote , branchesDictionary ) ;
349
379
}
350
380
}
351
-
352
- IEnumerator < KeyValuePair < string , IDictionary < string , ConfigBranch > > > IEnumerable < KeyValuePair < string , IDictionary < string , ConfigBranch > > > . GetEnumerator ( )
353
- {
354
- throw new NotImplementedException ( ) ;
355
- //return AsDictionary
356
- // .Select(pair => new KeyValuePair<string, IDictionary<string, ConfigBranch>>(pair.Key, pair.Value.AsDictionary))
357
- // .GetEnumerator();
358
- }
359
-
360
- void ICollection < KeyValuePair < string , IDictionary < string , ConfigBranch > > > . Add ( KeyValuePair < string , IDictionary < string , ConfigBranch > > item )
361
- {
362
- throw new NotImplementedException ( ) ;
363
- //Guard.ArgumentNotNull(item, "item");
364
- //Guard.ArgumentNotNull(item.Value, "item.Value");
365
- //
366
- //var serializableDictionary = item.Value as SerializableDictionary<string, ConfigBranch>;
367
- //if (serializableDictionary == null)
368
- //{
369
- // serializableDictionary = new SerializableDictionary<string, ConfigBranch>(item.Value);
370
- //}
371
- //
372
- //Add(item.Key, serializableDictionary);
373
- }
374
-
375
- bool ICollection < KeyValuePair < string , IDictionary < string , ConfigBranch > > > . Contains ( KeyValuePair < string , IDictionary < string , ConfigBranch > > item )
376
- {
377
- throw new NotImplementedException ( ) ;
378
- }
379
-
380
- void ICollection < KeyValuePair < string , IDictionary < string , ConfigBranch > > > . CopyTo ( KeyValuePair < string , IDictionary < string , ConfigBranch > > [ ] array , int arrayIndex )
381
- {
382
- throw new NotImplementedException ( ) ;
383
- }
384
-
385
- bool ICollection < KeyValuePair < string , IDictionary < string , ConfigBranch > > > . Remove ( KeyValuePair < string , IDictionary < string , ConfigBranch > > item )
386
- {
387
- throw new NotImplementedException ( ) ;
388
- }
389
-
390
- bool ICollection < KeyValuePair < string , IDictionary < string , ConfigBranch > > > . IsReadOnly
391
- {
392
- get { throw new NotImplementedException ( ) ; }
393
- }
394
-
395
- void IDictionary < string , IDictionary < string , ConfigBranch > > . Add ( string key , IDictionary < string , ConfigBranch > value )
396
- {
397
- throw new NotImplementedException ( ) ;
398
- }
399
-
400
- bool IDictionary < string , IDictionary < string , ConfigBranch > > . TryGetValue ( string key , out IDictionary < string , ConfigBranch > value )
401
- {
402
- value = null ;
403
-
404
- Dictionary < string , ConfigBranch > branches ;
405
- if ( TryGetValue ( key , out branches ) )
406
- {
407
- value = branches ;
408
- return true ;
409
- }
410
-
411
- return false ;
412
- }
413
-
414
- IDictionary < string , ConfigBranch > IDictionary < string , IDictionary < string , ConfigBranch > > . this [ string key ]
415
- {
416
- get
417
- {
418
- throw new NotImplementedException ( ) ;
419
- //var dictionary = (IDictionary<string, IDictionary<string, ConfigBranch>>)this;
420
- //IDictionary<string, ConfigBranch> value;
421
- //if (!dictionary.TryGetValue(key, out value))
422
- //{
423
- // throw new KeyNotFoundException();
424
- //}
425
- //
426
- //return value;
427
- }
428
- set
429
- {
430
- throw new NotImplementedException ( ) ;
431
- //var dictionary = (IDictionary<string, IDictionary<string, ConfigBranch>>)this;
432
- //dictionary.Add(key, value);
433
- }
434
- }
435
-
436
- ICollection < string > IDictionary < string , IDictionary < string , ConfigBranch > > . Keys
437
- {
438
- get
439
- {
440
- throw new NotImplementedException ( ) ;
441
- }
442
- }
443
-
444
- ICollection < IDictionary < string , ConfigBranch > > IDictionary < string , IDictionary < string , ConfigBranch > > . Values
445
- {
446
- get
447
- {
448
- return Values . Cast < IDictionary < string , ConfigBranch > > ( ) . ToArray ( ) ;
449
- }
450
- }
451
381
}
452
382
453
383
[ Serializable ]
@@ -740,7 +670,7 @@ public void AddLocalBranch(string branch)
740
670
741
671
public void AddRemoteBranch ( string remote , string branch )
742
672
{
743
- IDictionary < string , ConfigBranch > branchList ;
673
+ Dictionary < string , ConfigBranch > branchList ;
744
674
if ( RemoteConfigBranches . TryGetValue ( remote , out branchList ) )
745
675
{
746
676
if ( ! branchList . ContainsKey ( branch ) )
@@ -763,7 +693,7 @@ public void AddRemoteBranch(string remote, string branch)
763
693
764
694
public void RemoveRemoteBranch ( string remote , string branch )
765
695
{
766
- IDictionary < string , ConfigBranch > branchList ;
696
+ Dictionary < string , ConfigBranch > branchList ;
767
697
if ( RemoteConfigBranches . TryGetValue ( remote , out branchList ) )
768
698
{
769
699
if ( branchList . ContainsKey ( branch ) )
0 commit comments