Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 745eda7

Browse files
committed
Fix whtespace
1 parent 5a32c0a commit 745eda7

19 files changed

+674
-671
lines changed

src/ServiceStack.Text/Common/DateTimeSerializer.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static class DateTimeSerializer
4949
/// </summary>
5050
/// <param name="dateTime"></param>
5151
/// <returns></returns>
52-
public static DateTime Prepare(this DateTime dateTime, bool parsedAsUtc=false)
52+
public static DateTime Prepare(this DateTime dateTime, bool parsedAsUtc = false)
5353
{
5454
if (JsConfig.AlwaysUseUtc)
5555
{
@@ -134,7 +134,7 @@ public static DateTime ParseShortestXsdDateTime(string dateTimeStr)
134134
if (manualDate != null)
135135
return manualDate.Value;
136136
}
137-
catch {}
137+
catch { }
138138
}
139139

140140
try
@@ -169,7 +169,7 @@ public static DateTime ParseShortestXsdDateTime(string dateTimeStr)
169169
/// <returns>The repaired string. If no repairs were made, the original string is returned.</returns>
170170
private static string RepairXsdTimeSeparator(string dateTimeStr)
171171
{
172-
if( (dateTimeStr.Length > XsdTimeSeparatorIndex) && (dateTimeStr[XsdTimeSeparatorIndex] == ' ') && dateTimeStr.EndsWith(XsdUtcSuffix) )
172+
if ((dateTimeStr.Length > XsdTimeSeparatorIndex) && (dateTimeStr[XsdTimeSeparatorIndex] == ' ') && dateTimeStr.EndsWith(XsdUtcSuffix))
173173
{
174174
dateTimeStr = dateTimeStr.Substring(0, XsdTimeSeparatorIndex) + XsdTimeSeparator +
175175
dateTimeStr.Substring(XsdTimeSeparatorIndex + 1);
@@ -180,7 +180,7 @@ private static string RepairXsdTimeSeparator(string dateTimeStr)
180180

181181
public static DateTime? ParseManual(string dateTimeStr)
182182
{
183-
var dateKind = JsConfig.AssumeUtc || JsConfig.AlwaysUseUtc
183+
var dateKind = JsConfig.AssumeUtc || JsConfig.AlwaysUseUtc
184184
? DateTimeKind.Utc
185185
: DateTimeKind.Local;
186186

@@ -254,7 +254,7 @@ private static string RepairXsdTimeSeparator(string dateTimeStr)
254254
if (msStr.Length > 3)
255255
{
256256
var subMsStr = msStr.Substring(3);
257-
subMs = double.Parse(subMsStr)/Math.Pow(10, subMsStr.Length);
257+
subMs = double.Parse(subMsStr) / Math.Pow(10, subMsStr.Length);
258258
}
259259
}
260260
}
@@ -280,8 +280,8 @@ private static string RepairXsdTimeSeparator(string dateTimeStr)
280280
min = int.Parse(timeOffset.Substring(2));
281281
}
282282

283-
dateTime = dateTime.AddHours(offsetMultiplier*hh);
284-
dateTime = dateTime.AddMinutes(offsetMultiplier*min);
283+
dateTime = dateTime.AddHours(offsetMultiplier * hh);
284+
dateTime = dateTime.AddMinutes(offsetMultiplier * min);
285285
}
286286

287287
return dateTime;
@@ -320,7 +320,7 @@ public static DateTimeOffset ParseDateTimeOffset(string dateTimeOffsetStr)
320320
if (Env.IsMono)
321321
{
322322
// Without that Mono uses a Local timezone))
323-
dateTimeOffsetStr = dateTimeOffsetStr.Substring(0, dateTimeOffsetStr.Length - 1) + "+00:00";
323+
dateTimeOffsetStr = dateTimeOffsetStr.Substring(0, dateTimeOffsetStr.Length - 1) + "+00:00";
324324
}
325325
}
326326

@@ -364,7 +364,7 @@ public static TimeSpan ParseTimeSpan(string dateTimeStr)
364364
{
365365
return dateTimeStr.StartsWith("P", StringComparison.Ordinal) || dateTimeStr.StartsWith("-P", StringComparison.Ordinal)
366366
? ParseXsdTimeSpan(dateTimeStr)
367-
: dateTimeStr.Contains(":")
367+
: dateTimeStr.Contains(":")
368368
? TimeSpan.Parse(dateTimeStr)
369369
: ParseNSTimeInterval(dateTimeStr);
370370
}
@@ -402,8 +402,8 @@ public static string ToShortestXsdDateTimeString(DateTime dateTime)
402402
if (isStartOfDay)
403403
return dateTime.ToString(ShortDateTimeFormat);
404404

405-
var hasFractionalSecs = (timeOfDay.Milliseconds != 0)
406-
|| ((timeOfDay.Ticks%TimeSpan.TicksPerMillisecond) != 0);
405+
var hasFractionalSecs = (timeOfDay.Milliseconds != 0)
406+
|| ((timeOfDay.Ticks % TimeSpan.TicksPerMillisecond) != 0);
407407
if (!hasFractionalSecs)
408408
return dateTime.Kind != DateTimeKind.Utc
409409
? dateTime.ToString(DateTimeFormatSecondsUtcOffset)

src/ServiceStack.Text/Common/DeserializeBuiltin.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ private static ParseStringDelegate GetParseFn()
3838
{
3939
case TypeCode.Boolean:
4040
//Lots of kids like to use '1', HTML checkboxes use 'on' as a soft convention
41-
return value =>
42-
value.Length == 1 ?
43-
value == "1"
44-
: value.Length == 2 ?
45-
value == "on" :
41+
return value =>
42+
value.Length == 1 ?
43+
value == "1"
44+
: value.Length == 2 ?
45+
value == "on" :
4646
bool.Parse(value);
4747

4848
case TypeCode.Byte:
@@ -70,7 +70,8 @@ private static ParseStringDelegate GetParseFn()
7070
case TypeCode.DateTime:
7171
return value => DateTimeSerializer.ParseShortestXsdDateTime(value);
7272
case TypeCode.Char:
73-
return value => {
73+
return value =>
74+
{
7475
char cValue;
7576
return char.TryParse(value, out cValue) ? cValue : '\0';
7677
};
@@ -89,8 +90,8 @@ private static ParseStringDelegate GetParseFn()
8990
switch (typeCode)
9091
{
9192
case TypeCode.Boolean:
92-
return value => string.IsNullOrEmpty(value) ?
93-
(bool?)null
93+
return value => string.IsNullOrEmpty(value) ?
94+
(bool?)null
9495
: value.Length == 1 ?
9596
value == "1"
9697
: value.Length == 2 ?
@@ -122,7 +123,8 @@ private static ParseStringDelegate GetParseFn()
122123
case TypeCode.DateTime:
123124
return value => DateTimeSerializer.ParseShortestNullableXsdDateTime(value);
124125
case TypeCode.Char:
125-
return value => {
126+
return value =>
127+
{
126128
char cValue;
127129
return string.IsNullOrEmpty(value) ? (char?)null : char.TryParse(value, out cValue) ? cValue : '\0';
128130
};

src/ServiceStack.Text/Common/DeserializeCustomGenericType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static object ParseTuple(Type tupleType, string value)
2121
{
2222
var index = 0;
2323
Serializer.EatMapStartChar(value, ref index);
24-
if (JsonTypeSerializer.IsEmptyMap(value, index))
24+
if (JsonTypeSerializer.IsEmptyMap(value, index))
2525
return tupleType.CreateInstance();
2626

2727
var genericArgs = tupleType.GetGenericArguments();

src/ServiceStack.Text/Common/DeserializeDictionary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public static JsonObject ParseJsonObject(string value)
102102

103103
public static Dictionary<string, string> ParseStringDictionary(string value)
104104
{
105-
if (value == null)
105+
if (value == null)
106106
return null;
107107

108108
var index = VerifyAndGetStartIndex(value, typeof(Dictionary<string, string>));

src/ServiceStack.Text/Common/DeserializeSpecializedCollections.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static ParseStringDelegate GetParseFn()
4747
if (fn != null)
4848
return fn;
4949

50-
if (typeof (T) == typeof (IEnumerable) || typeof(T) == typeof(ICollection))
50+
if (typeof(T) == typeof(IEnumerable) || typeof(T) == typeof(ICollection))
5151
{
5252
return GetEnumerableParseFn();
5353
}
@@ -95,7 +95,7 @@ public static Stack<int> ParseIntStack(string value)
9595
internal static ParseStringDelegate GetGenericStackParseFn()
9696
{
9797
var enumerableInterface = typeof(T).GetTypeWithGenericInterfaceOf(typeof(IEnumerable<>));
98-
98+
9999
var elementType = enumerableInterface.GenericTypeArguments()[0];
100100
var genericType = typeof(SpecializedQueueElements<>).MakeGenericType(elementType);
101101
var mi = genericType.GetStaticMethod("ConvertToStack");
@@ -114,7 +114,7 @@ public static ParseStringDelegate GetEnumerableParseFn()
114114
public static ParseStringDelegate GetGenericEnumerableParseFn()
115115
{
116116
var enumerableInterface = typeof(T).GetTypeWithGenericInterfaceOf(typeof(IEnumerable<>));
117-
if (enumerableInterface == null) return null;
117+
if (enumerableInterface == null) return null;
118118
var elementType = enumerableInterface.GenericTypeArguments()[0];
119119
var genericType = typeof(SpecializedEnumerableElements<,>).MakeGenericType(typeof(T), elementType);
120120
var fi = genericType.GetPublicStaticField("ConvertFn");

src/ServiceStack.Text/Common/DeserializeType.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public static object ParseQuotedPrimitive(string value)
128128
return result;
129129
}
130130

131-
if (string.IsNullOrEmpty(value))
131+
if (string.IsNullOrEmpty(value))
132132
return null;
133133

134134
Guid guidValue;
@@ -177,11 +177,11 @@ public static object ParsePrimitive(string value)
177177
return result;
178178
}
179179

180-
if (string.IsNullOrEmpty(value))
180+
if (string.IsNullOrEmpty(value))
181181
return null;
182182

183183
bool boolValue;
184-
if (bool.TryParse(value, out boolValue))
184+
if (bool.TryParse(value, out boolValue))
185185
return boolValue;
186186

187187
// Parse as decimal

src/ServiceStack.Text/Common/JsReader.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ private ParseStringDelegate GetCoreParseFn<T>()
7777
return customFn;
7878
}
7979

80-
var pclParseFn = PclExport.Instance.GetJsReaderParseMethod<TSerializer>(typeof(T));
81-
if (pclParseFn != null)
82-
return pclParseFn;
80+
var pclParseFn = PclExport.Instance.GetJsReaderParseMethod<TSerializer>(typeof(T));
81+
if (pclParseFn != null)
82+
return pclParseFn;
8383

8484
var isDictionary = typeof(T) != typeof(IEnumerable) && typeof(T) != typeof(ICollection)
8585
&& (typeof(T).AssignableFrom(typeof(IDictionary)) || typeof(T).HasInterface(typeof(IDictionary)));

src/ServiceStack.Text/Common/JsWriter.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ public class JsWriter<TSerializer>
162162
public JsWriter()
163163
{
164164
this.SpecialTypes = new Dictionary<Type, WriteObjectDelegate>
165-
{
166-
{ typeof(Uri), Serializer.WriteObjectString },
167-
{ typeof(Type), WriteType },
168-
{ typeof(Exception), Serializer.WriteException },
169-
};
165+
{
166+
{ typeof(Uri), Serializer.WriteObjectString },
167+
{ typeof(Type), WriteType },
168+
{ typeof(Exception), Serializer.WriteException },
169+
};
170170
}
171171

172172
public WriteObjectDelegate GetValueTypeToStringMethod(Type type)
@@ -375,7 +375,7 @@ private WriteObjectDelegate GetCoreWriteFn<T>()
375375
return WriteListsOfElements<TSerializer>.WriteIEnumerable;
376376
}
377377

378-
if (typeof(T).HasInterface(typeof (IValueWriter)))
378+
if (typeof(T).HasInterface(typeof(IValueWriter)))
379379
return WriteValue;
380380

381381
if (typeof(T).IsClass() || typeof(T).IsInterface() || JsConfig.TreatAsRefType(typeof(T)))

src/ServiceStack.Text/Common/StaticParseMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static ParseStringDelegate GetParseFn<T>(string parseMethod)
2525
{
2626
// Get the static Parse(string) method on the type supplied
2727
var parseMethodInfo = typeof(T).GetStaticMethod(parseMethod, new[] { typeof(string) });
28-
if (parseMethodInfo == null)
28+
if (parseMethodInfo == null)
2929
return null;
3030

3131
ParseDelegate parseDelegate = null;

src/ServiceStack.Text/Common/WriteType.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ private static WriteObjectDelegate GetWriteFn()
105105
static Func<T, bool> GetShouldSerializeMethod(MemberInfo member)
106106
{
107107
var method = member.DeclaringType.GetInstanceMethod("ShouldSerialize" + member.Name);
108-
return method == null || method.ReturnType != typeof(bool)
109-
? null
108+
return method == null || method.ReturnType != typeof(bool)
109+
? null
110110
: (Func<T, bool>)method.CreateDelegate(typeof(Func<T, bool>));
111111
}
112112

113113
static Func<T, string, bool?> ShouldSerialize(Type type)
114114
{
115115
var method = type.GetMethodInfo("ShouldSerialize");
116-
return method == null || method.ReturnType != typeof(bool?)
116+
return method == null || method.ReturnType != typeof(bool?)
117117
? null
118118
: (Func<T, string, bool?>)method.CreateDelegate(typeof(Func<T, string, bool?>));
119119
}
@@ -147,10 +147,10 @@ private static bool Init()
147147
int propertyOrder = -1;
148148
var propertyType = propertyInfo.PropertyType;
149149
var defaultValue = propertyType.GetDefaultValue();
150-
bool propertySuppressDefaultConfig = defaultValue != null
151-
&& propertyType.IsValueType()
152-
&& !propertyType.IsEnum()
153-
&& JsConfig.HasSerializeFn.Contains(propertyType)
150+
bool propertySuppressDefaultConfig = defaultValue != null
151+
&& propertyType.IsValueType()
152+
&& !propertyType.IsEnum()
153+
&& JsConfig.HasSerializeFn.Contains(propertyType)
154154
&& !JsConfig.HasIncludeDefaultValue.Contains(propertyType);
155155
bool propertySuppressDefaultAttribute = false;
156156

@@ -202,9 +202,9 @@ private static bool Init()
202202
int propertyOrder = -1;
203203
var propertyType = fieldInfo.FieldType;
204204
var defaultValue = propertyType.GetDefaultValue();
205-
bool propertySuppressDefaultConfig = defaultValue != null
206-
&& propertyType.IsValueType() && !propertyType.IsEnum()
207-
&& JsConfig.HasSerializeFn.Contains(propertyType)
205+
bool propertySuppressDefaultConfig = defaultValue != null
206+
&& propertyType.IsValueType() && !propertyType.IsEnum()
207+
&& JsConfig.HasSerializeFn.Contains(propertyType)
208208
&& !JsConfig.HasIncludeDefaultValue.Contains(propertyType);
209209
bool propertySuppressDefaultAttribute = false;
210210
#if (NETFX_CORE)
@@ -281,11 +281,11 @@ internal string PropertyName
281281
internal readonly Func<T, string, bool?> shouldSerializeDynamic;
282282
internal readonly bool isEnum;
283283

284-
public TypePropertyWriter(string propertyName, string propertyDeclaredTypeName, string propertyNameCLSFriendly,
285-
string propertyNameLowercaseUnderscore, int propertyOrder, bool propertySuppressDefaultConfig,bool propertySuppressDefaultAttribute,
286-
Func<T, object> getterFn, WriteObjectDelegate writeFn, object defaultValue,
287-
Func<T, bool> shouldSerialize,
288-
Func<T,string, bool?> shouldSerializeDynamic,
284+
public TypePropertyWriter(string propertyName, string propertyDeclaredTypeName, string propertyNameCLSFriendly,
285+
string propertyNameLowercaseUnderscore, int propertyOrder, bool propertySuppressDefaultConfig, bool propertySuppressDefaultAttribute,
286+
Func<T, object> getterFn, WriteObjectDelegate writeFn, object defaultValue,
287+
Func<T, bool> shouldSerialize,
288+
Func<T, string, bool?> shouldSerializeDynamic,
289289
bool isEnum)
290290
{
291291
this.propertyName = propertyName;
@@ -394,7 +394,7 @@ public static void WriteProperties(TextWriter writer, object value)
394394
{
395395
var propertyWriter = PropertyWriters[index];
396396

397-
if (propertyWriter.shouldSerialize != null && !propertyWriter.shouldSerialize((T)value))
397+
if (propertyWriter.shouldSerialize != null && !propertyWriter.shouldSerialize((T)value))
398398
continue;
399399

400400
var dontSkipDefault = false;
@@ -442,7 +442,7 @@ public static void WriteProperties(TextWriter writer, object value)
442442
finally
443443
{
444444
if (typeof(TSerializer) == typeof(JsonTypeSerializer)) JsState.IsWritingValue = false;
445-
}
445+
}
446446
}
447447
}
448448

@@ -526,7 +526,7 @@ public static void WriteQueryString(TextWriter writer, object value)
526526
var isEnumerable = strValue == null
527527
&& !(propertyType.IsValueType())
528528
&& propertyType.HasInterface(typeof(IEnumerable));
529-
529+
530530
if (QueryStringSerializer.ComplexTypeStrategy != null
531531
&& !isEnumerable && (propertyType.IsUserType() || propertyType.IsInterface()))
532532
{
@@ -546,12 +546,12 @@ public static void WriteQueryString(TextWriter writer, object value)
546546
propertyWriter.WriteFn(writer, propertyValue);
547547
}
548548
else
549-
{
549+
{
550550
//Trim brackets in top-level lists in QueryStrings, e.g: ?a=[1,2,3] => ?a=1,2,3
551551
using (var ms = MemoryStreamFactory.GetStream())
552552
{
553553
var enumerableWriter = new StreamWriter(ms); //ms disposed in using
554-
propertyWriter.WriteFn(enumerableWriter, propertyValue);
554+
propertyWriter.WriteFn(enumerableWriter, propertyValue);
555555
enumerableWriter.Flush();
556556
var output = ms.ToArray().FromUtf8Bytes();
557557
output = output.Trim(ArrayBrackets);

0 commit comments

Comments
 (0)