mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-05 19:46:07 +00:00
aaaand format the code
This commit is contained in:
+25
-28
@@ -1,5 +1,4 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="SimpleJson.cs" company="The Outercurve Foundation">
|
||||
// Copyright (c) 2011, The Outercurve Foundation.
|
||||
//
|
||||
// Licensed under the MIT License (the "License");
|
||||
@@ -524,7 +523,7 @@ namespace Octokit
|
||||
static SimpleJson()
|
||||
{
|
||||
EscapeTable = new char[93];
|
||||
EscapeTable['"'] = '"';
|
||||
EscapeTable['"'] = '"';
|
||||
EscapeTable['\\'] = '\\';
|
||||
EscapeTable['\b'] = 'b';
|
||||
EscapeTable['\f'] = 'f';
|
||||
@@ -558,7 +557,7 @@ namespace Octokit
|
||||
/// <returns>
|
||||
/// Returns true if successfull otherwise false.
|
||||
/// </returns>
|
||||
[SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification="Need to support .NET 2")]
|
||||
[SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification = "Need to support .NET 2")]
|
||||
public static bool TryDeserializeObject(string json, out object obj)
|
||||
{
|
||||
bool success = true;
|
||||
@@ -623,7 +622,7 @@ namespace Octokit
|
||||
StringBuilder sb = new StringBuilder();
|
||||
char c;
|
||||
|
||||
for (int i = 0; i < jsonString.Length; )
|
||||
for (int i = 0; i < jsonString.Length;)
|
||||
{
|
||||
c = jsonString[i++];
|
||||
|
||||
@@ -1224,7 +1223,7 @@ namespace Octokit
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
[GeneratedCode("simple-json", "1.0.0")]
|
||||
#if SIMPLE_JSON_INTERNAL
|
||||
internal
|
||||
@@ -1233,7 +1232,7 @@ namespace Octokit
|
||||
#endif
|
||||
interface IJsonSerializerStrategy
|
||||
{
|
||||
[SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification="Need to support .NET 2")]
|
||||
[SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification = "Need to support .NET 2")]
|
||||
bool TrySerializeNonPrimitiveObject(object input, out object output);
|
||||
object DeserializeObject(object value, Type type);
|
||||
}
|
||||
@@ -1337,12 +1336,12 @@ namespace Octokit
|
||||
if (type == null) throw new ArgumentNullException("type");
|
||||
string str = value as string;
|
||||
|
||||
if (type == typeof (Guid) && string.IsNullOrEmpty(str))
|
||||
if (type == typeof(Guid) && string.IsNullOrEmpty(str))
|
||||
return default(Guid);
|
||||
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
|
||||
object obj = null;
|
||||
|
||||
if (str != null)
|
||||
@@ -1357,7 +1356,7 @@ namespace Octokit
|
||||
return new Guid(str);
|
||||
if (type == typeof(Uri))
|
||||
{
|
||||
bool isValid = Uri.IsWellFormedUriString(str, UriKind.RelativeOrAbsolute);
|
||||
bool isValid = Uri.IsWellFormedUriString(str, UriKind.RelativeOrAbsolute);
|
||||
|
||||
Uri result;
|
||||
if (isValid && Uri.TryCreate(str, UriKind.RelativeOrAbsolute, out result))
|
||||
@@ -1365,8 +1364,8 @@ namespace Octokit
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (type == typeof(string))
|
||||
|
||||
if (type == typeof(string))
|
||||
return str;
|
||||
|
||||
return Convert.ChangeType(str, type, CultureInfo.InvariantCulture);
|
||||
@@ -1386,7 +1385,7 @@ namespace Octokit
|
||||
}
|
||||
else if (value is bool)
|
||||
return value;
|
||||
|
||||
|
||||
bool valueIsLong = value is long;
|
||||
bool valueIsDouble = value is double;
|
||||
if ((valueIsLong && type == typeof(long)) || (valueIsDouble && type == typeof(double)))
|
||||
@@ -1490,7 +1489,7 @@ namespace Octokit
|
||||
return Convert.ToDouble(p, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification="Need to support .NET 2")]
|
||||
[SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification = "Need to support .NET 2")]
|
||||
protected virtual bool TrySerializeKnownTypes(object input, out object output)
|
||||
{
|
||||
bool returnValue = true;
|
||||
@@ -1515,7 +1514,7 @@ namespace Octokit
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
[SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification="Need to support .NET 2")]
|
||||
[SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification = "Need to support .NET 2")]
|
||||
protected virtual bool TrySerializeUnknownTypes(object input, out object output)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException("input");
|
||||
@@ -1617,7 +1616,7 @@ namespace Octokit
|
||||
namespace Reflection
|
||||
{
|
||||
// This class is meant to be copied into other libraries. So we want to exclude it from Code Analysis rules
|
||||
// that might be in place in the target project.
|
||||
// that might be in place in the target project.
|
||||
[GeneratedCode("reflection-utils", "1.0.0")]
|
||||
#if SIMPLE_JSON_REFLECTION_UTILS_PUBLIC
|
||||
public
|
||||
@@ -1670,7 +1669,7 @@ namespace Octokit
|
||||
foreach (Type implementedInterface in interfaces)
|
||||
{
|
||||
if (IsTypeGeneric(implementedInterface) &&
|
||||
implementedInterface.GetGenericTypeDefinition() == typeof (IList<>))
|
||||
implementedInterface.GetGenericTypeDefinition() == typeof(IList<>))
|
||||
{
|
||||
return GetGenericTypeArguments(implementedInterface)[0];
|
||||
}
|
||||
@@ -1680,7 +1679,6 @@ namespace Octokit
|
||||
|
||||
public static Attribute GetAttribute(Type objectType, Type attributeType)
|
||||
{
|
||||
|
||||
#if SIMPLE_JSON_TYPEINFO
|
||||
if (objectType == null || attributeType == null || !objectType.GetTypeInfo().IsDefined(attributeType))
|
||||
return null;
|
||||
@@ -1857,7 +1855,7 @@ namespace Octokit
|
||||
|
||||
public static ConstructorDelegate GetConstructorByReflection(ConstructorInfo constructorInfo)
|
||||
{
|
||||
return delegate(object[] args) { return constructorInfo.Invoke(args); };
|
||||
return delegate (object[] args) { return constructorInfo.Invoke(args); };
|
||||
}
|
||||
|
||||
public static ConstructorDelegate GetConstructorByReflection(Type type, params Type[] argsType)
|
||||
@@ -1884,7 +1882,7 @@ namespace Octokit
|
||||
NewExpression newExp = Expression.New(constructorInfo, argsExp);
|
||||
Expression<Func<object[], object>> lambda = Expression.Lambda<Func<object[], object>>(newExp, param);
|
||||
Func<object[], object> compiledLambda = lambda.Compile();
|
||||
return delegate(object[] args) { return compiledLambda(args); };
|
||||
return delegate (object[] args) { return compiledLambda(args); };
|
||||
}
|
||||
|
||||
public static ConstructorDelegate GetConstructorByExpression(Type type, params Type[] argsType)
|
||||
@@ -1916,12 +1914,12 @@ namespace Octokit
|
||||
public static GetDelegate GetGetMethodByReflection(PropertyInfo propertyInfo)
|
||||
{
|
||||
MethodInfo methodInfo = GetGetterMethodInfo(propertyInfo);
|
||||
return delegate(object source) { return methodInfo.Invoke(source, EmptyObjects); };
|
||||
return delegate (object source) { return methodInfo.Invoke(source, EmptyObjects); };
|
||||
}
|
||||
|
||||
public static GetDelegate GetGetMethodByReflection(FieldInfo fieldInfo)
|
||||
{
|
||||
return delegate(object source) { return fieldInfo.GetValue(source); };
|
||||
return delegate (object source) { return fieldInfo.GetValue(source); };
|
||||
}
|
||||
|
||||
#if !SIMPLE_JSON_NO_LINQ_EXPRESSION
|
||||
@@ -1932,7 +1930,7 @@ namespace Octokit
|
||||
ParameterExpression instance = Expression.Parameter(typeof(object), "instance");
|
||||
UnaryExpression instanceCast = (!IsValueType(propertyInfo.DeclaringType)) ? Expression.TypeAs(instance, propertyInfo.DeclaringType) : Expression.Convert(instance, propertyInfo.DeclaringType);
|
||||
Func<object, object> compiled = Expression.Lambda<Func<object, object>>(Expression.TypeAs(Expression.Call(instanceCast, getMethodInfo), typeof(object)), instance).Compile();
|
||||
return delegate(object source) { return compiled(source); };
|
||||
return delegate (object source) { return compiled(source); };
|
||||
}
|
||||
|
||||
public static GetDelegate GetGetMethodByExpression(FieldInfo fieldInfo)
|
||||
@@ -1940,7 +1938,7 @@ namespace Octokit
|
||||
ParameterExpression instance = Expression.Parameter(typeof(object), "instance");
|
||||
MemberExpression member = Expression.Field(Expression.Convert(instance, fieldInfo.DeclaringType), fieldInfo);
|
||||
GetDelegate compiled = Expression.Lambda<GetDelegate>(Expression.Convert(member, typeof(object)), instance).Compile();
|
||||
return delegate(object source) { return compiled(source); };
|
||||
return delegate (object source) { return compiled(source); };
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1966,12 +1964,12 @@ namespace Octokit
|
||||
public static SetDelegate GetSetMethodByReflection(PropertyInfo propertyInfo)
|
||||
{
|
||||
MethodInfo methodInfo = GetSetterMethodInfo(propertyInfo);
|
||||
return delegate(object source, object value) { methodInfo.Invoke(source, new object[] { value }); };
|
||||
return delegate (object source, object value) { methodInfo.Invoke(source, new object[] { value }); };
|
||||
}
|
||||
|
||||
public static SetDelegate GetSetMethodByReflection(FieldInfo fieldInfo)
|
||||
{
|
||||
return delegate(object source, object value) { fieldInfo.SetValue(source, value); };
|
||||
return delegate (object source, object value) { fieldInfo.SetValue(source, value); };
|
||||
}
|
||||
|
||||
#if !SIMPLE_JSON_NO_LINQ_EXPRESSION
|
||||
@@ -1984,7 +1982,7 @@ namespace Octokit
|
||||
UnaryExpression instanceCast = (!IsValueType(propertyInfo.DeclaringType)) ? Expression.TypeAs(instance, propertyInfo.DeclaringType) : Expression.Convert(instance, propertyInfo.DeclaringType);
|
||||
UnaryExpression valueCast = (!IsValueType(propertyInfo.PropertyType)) ? Expression.TypeAs(value, propertyInfo.PropertyType) : Expression.Convert(value, propertyInfo.PropertyType);
|
||||
Action<object, object> compiled = Expression.Lambda<Action<object, object>>(Expression.Call(instanceCast, setMethodInfo, valueCast), new ParameterExpression[] { instance, value }).Compile();
|
||||
return delegate(object source, object val) { compiled(source, val); };
|
||||
return delegate (object source, object val) { compiled(source, val); };
|
||||
}
|
||||
|
||||
public static SetDelegate GetSetMethodByExpression(FieldInfo fieldInfo)
|
||||
@@ -1993,7 +1991,7 @@ namespace Octokit
|
||||
ParameterExpression value = Expression.Parameter(typeof(object), "value");
|
||||
Action<object, object> compiled = Expression.Lambda<Action<object, object>>(
|
||||
Assign(Expression.Field(Expression.Convert(instance, fieldInfo.DeclaringType), fieldInfo), Expression.Convert(value, fieldInfo.FieldType)), instance, value).Compile();
|
||||
return delegate(object source, object val) { compiled(source, val); };
|
||||
return delegate (object source, object val) { compiled(source, val); };
|
||||
}
|
||||
|
||||
public static BinaryExpression Assign(Expression left, Expression right)
|
||||
@@ -2143,7 +2141,6 @@ namespace Octokit
|
||||
return _dictionary.GetEnumerator();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user