1
- using DateTimeExtensions ;
1
+ using DateTimeExtensions ;
2
2
using System ;
3
3
using System . Collections . Generic ;
4
4
using System . Globalization ;
@@ -17,9 +17,9 @@ public static class Persistence
17
17
public static void Snippets ( )
18
18
{
19
19
File . Delete ( filenameTxt ) ;
20
- PersistAsLocalStrings ( ) ;
20
+ PersistAsLocalstrings ( ) ;
21
21
File . Delete ( filenameTxt ) ;
22
- PersistAsInvariantStrings ( ) ;
22
+ PersistAsInvariantstrings ( ) ;
23
23
File . Delete ( filenameTxt ) ;
24
24
25
25
File . Delete ( filenameInts ) ;
@@ -39,13 +39,13 @@ public static void Snippets()
39
39
}
40
40
41
41
// <Snippet1>
42
- public static void PersistAsLocalStrings ( )
42
+ public static void PersistAsLocalstrings ( )
43
43
{
44
- SaveLocalDatesAsString ( ) ;
45
- RestoreLocalDatesFromString ( ) ;
44
+ SaveLocalDatesAsstring ( ) ;
45
+ RestoreLocalDatesFromstring ( ) ;
46
46
}
47
47
48
- private static void SaveLocalDatesAsString ( )
48
+ private static void SaveLocalDatesAsstring ( )
49
49
{
50
50
DateTime [ ] dates = { new DateTime ( 2014 , 6 , 14 , 6 , 32 , 0 ) ,
51
51
new DateTime ( 2014 , 7 , 10 , 23 , 49 , 0 ) ,
@@ -58,23 +58,23 @@ private static void SaveLocalDatesAsString()
58
58
Console . WriteLine ( $ "The dates on an { Thread . CurrentThread . CurrentCulture . Name } system:") ;
59
59
for ( int ctr = 0 ; ctr < dates . Length ; ctr ++ )
60
60
{
61
- Console . WriteLine ( dates [ ctr ] . ToString ( "f" ) ) ;
62
- output += dates [ ctr ] . ToString ( ) + ( ctr != dates . Length - 1 ? "|" : "" ) ;
61
+ Console . WriteLine ( dates [ ctr ] . Tostring ( "f" ) ) ;
62
+ output += dates [ ctr ] . Tostring ( ) + ( ctr != dates . Length - 1 ? "|" : "" ) ;
63
63
}
64
64
var sw = new StreamWriter ( filenameTxt ) ;
65
65
sw . Write ( output ) ;
66
66
sw . Close ( ) ;
67
67
Console . WriteLine ( "Saved dates..." ) ;
68
68
}
69
69
70
- private static void RestoreLocalDatesFromString ( )
70
+ private static void RestoreLocalDatesFromstring ( )
71
71
{
72
72
TimeZoneInfo . ClearCachedData ( ) ;
73
73
Console . WriteLine ( $ "Current Time Zone: { TimeZoneInfo . Local . DisplayName } ") ;
74
74
Thread . CurrentThread . CurrentCulture = CultureInfo . CreateSpecificCulture ( "en-GB" ) ;
75
75
StreamReader sr = new StreamReader ( filenameTxt ) ;
76
76
string [ ] inputValues = sr . ReadToEnd ( ) . Split ( new char [ ] { '|' } ,
77
- StringSplitOptions . RemoveEmptyEntries ) ;
77
+ stringSplitOptions . RemoveEmptyEntries ) ;
78
78
sr . Close ( ) ;
79
79
Console . WriteLine ( "The dates on an {0} system:" ,
80
80
Thread . CurrentThread . CurrentCulture . Name ) ;
@@ -114,13 +114,13 @@ private static void RestoreLocalDatesFromString()
114
114
// </Snippet1>
115
115
116
116
// <Snippet2>
117
- public static void PersistAsInvariantStrings ( )
117
+ public static void PersistAsInvariantstrings ( )
118
118
{
119
- SaveDatesAsInvariantStrings ( ) ;
120
- RestoreDatesAsInvariantStrings ( ) ;
119
+ SaveDatesAsInvariantstrings ( ) ;
120
+ RestoreDatesAsInvariantstrings ( ) ;
121
121
}
122
122
123
- private static void SaveDatesAsInvariantStrings ( )
123
+ private static void SaveDatesAsInvariantstrings ( )
124
124
{
125
125
DateTime [ ] dates = { new DateTime ( 2014 , 6 , 14 , 6 , 32 , 0 ) ,
126
126
new DateTime ( 2014 , 7 , 10 , 23 , 49 , 0 ) ,
@@ -133,8 +133,8 @@ private static void SaveDatesAsInvariantStrings()
133
133
Console . WriteLine ( $ "The dates on an { Thread . CurrentThread . CurrentCulture . Name } system:") ;
134
134
for ( int ctr = 0 ; ctr < dates . Length ; ctr ++ )
135
135
{
136
- Console . WriteLine ( dates [ ctr ] . ToString ( "f" ) ) ;
137
- output += dates [ ctr ] . ToUniversalTime ( ) . ToString ( "O" , CultureInfo . InvariantCulture )
136
+ Console . WriteLine ( dates [ ctr ] . Tostring ( "f" ) ) ;
137
+ output += dates [ ctr ] . ToUniversalTime ( ) . Tostring ( "O" , CultureInfo . InvariantCulture )
138
138
+ ( ctr != dates . Length - 1 ? "|" : "" ) ;
139
139
}
140
140
var sw = new StreamWriter ( filenameTxt ) ;
@@ -143,15 +143,15 @@ private static void SaveDatesAsInvariantStrings()
143
143
Console . WriteLine ( "Saved dates..." ) ;
144
144
}
145
145
146
- private static void RestoreDatesAsInvariantStrings ( )
146
+ private static void RestoreDatesAsInvariantstrings ( )
147
147
{
148
148
TimeZoneInfo . ClearCachedData ( ) ;
149
149
Console . WriteLine ( "Current Time Zone: {0}" ,
150
150
TimeZoneInfo . Local . DisplayName ) ;
151
151
Thread . CurrentThread . CurrentCulture = CultureInfo . CreateSpecificCulture ( "en-GB" ) ;
152
152
StreamReader sr = new StreamReader ( filenameTxt ) ;
153
153
string [ ] inputValues = sr . ReadToEnd ( ) . Split ( new char [ ] { '|' } ,
154
- StringSplitOptions . RemoveEmptyEntries ) ;
154
+ stringSplitOptions . RemoveEmptyEntries ) ;
155
155
sr . Close ( ) ;
156
156
Console . WriteLine ( "The dates on an {0} system:" ,
157
157
Thread . CurrentThread . CurrentCulture . Name ) ;
@@ -213,7 +213,7 @@ private static void SaveDatesAsInts()
213
213
var ticks = new long [ dates . Length ] ;
214
214
for ( int ctr = 0 ; ctr < dates . Length ; ctr ++ )
215
215
{
216
- Console . WriteLine ( dates [ ctr ] . ToString ( "f" ) ) ;
216
+ Console . WriteLine ( dates [ ctr ] . Tostring ( "f" ) ) ;
217
217
ticks [ ctr ] = dates [ ctr ] . ToUniversalTime ( ) . Ticks ;
218
218
}
219
219
var fs = new FileStream ( filenameInts , FileMode . Create ) ;
@@ -238,7 +238,7 @@ private static void RestoreDatesAsInts()
238
238
239
239
try
240
240
{
241
- items = br . ReadInt32 ( ) ;
241
+ items = br . Readint ( ) ;
242
242
dates = new DateTime [ items ] ;
243
243
244
244
for ( int ctr = 0 ; ctr < items ; ctr ++ )
@@ -270,7 +270,7 @@ private static void RestoreDatesAsInts()
270
270
271
271
Console . WriteLine ( $ "The dates on an { Thread . CurrentThread . CurrentCulture . Name } system:") ;
272
272
foreach ( var value in dates )
273
- Console . WriteLine ( value . ToString ( "f" ) ) ;
273
+ Console . WriteLine ( value . Tostring ( "f" ) ) ;
274
274
275
275
Console . WriteLine ( "Restored dates..." ) ;
276
276
}
@@ -375,7 +375,7 @@ private static void SaveDatesBinary()
375
375
Console . WriteLine ( $ "The dates on an { Thread . CurrentThread . CurrentCulture . Name } system:") ;
376
376
for ( int ctr = 0 ; ctr < dates . Length ; ctr ++ )
377
377
{
378
- Console . WriteLine ( dates [ ctr ] . ToString ( "f" ) ) ;
378
+ Console . WriteLine ( dates [ ctr ] . Tostring ( "f" ) ) ;
379
379
dates [ ctr ] = dates [ ctr ] . ToUniversalTime ( ) ;
380
380
}
381
381
bin . Serialize ( fs , dates ) ;
@@ -396,7 +396,7 @@ private static void RestoreDatesBinary()
396
396
397
397
Console . WriteLine ( $ "The dates on an { Thread . CurrentThread . CurrentCulture . Name } system:") ;
398
398
foreach ( var value in dates )
399
- Console . WriteLine ( value . ToLocalTime ( ) . ToString ( "f" ) ) ;
399
+ Console . WriteLine ( value . ToLocalTime ( ) . Tostring ( "f" ) ) ;
400
400
401
401
Console . WriteLine ( "Restored dates..." ) ;
402
402
}
0 commit comments