|
|
|
@ -93,13 +93,10 @@ namespace Exceptron.Client.fastJSON
|
|
|
|
|
string val = "";
|
|
|
|
|
if (_tyname.TryGetValue(t, out val))
|
|
|
|
|
return val;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string s = t.AssemblyQualifiedName;
|
|
|
|
|
_tyname.Add(t, s);
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
readonly SafeDictionary<string, Type> _typecache = new SafeDictionary<string, Type>();
|
|
|
|
|
private Type GetTypeFromCache(string typename)
|
|
|
|
@ -107,13 +104,10 @@ namespace Exceptron.Client.fastJSON
|
|
|
|
|
Type val = null;
|
|
|
|
|
if (_typecache.TryGetValue(typename, out val))
|
|
|
|
|
return val;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Type t = Type.GetType(typename);
|
|
|
|
|
_typecache.Add(typename, t);
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
readonly SafeDictionary<Type, CreateObject> _constrcache = new SafeDictionary<Type, CreateObject>();
|
|
|
|
|
private delegate object CreateObject();
|
|
|
|
@ -126,8 +120,6 @@ namespace Exceptron.Client.fastJSON
|
|
|
|
|
{
|
|
|
|
|
return c();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DynamicMethod dynMethod = new DynamicMethod("_", objtype, null, true);
|
|
|
|
|
ILGenerator ilGen = dynMethod.GetILGenerator();
|
|
|
|
|
|
|
|
|
@ -137,7 +129,6 @@ namespace Exceptron.Client.fastJSON
|
|
|
|
|
_constrcache.Add(objtype, c);
|
|
|
|
|
return c();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exc)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception(string.Format("Failed to fast create instance for type '{0}' from assemebly '{1}'",
|
|
|
|
@ -188,8 +179,6 @@ namespace Exceptron.Client.fastJSON
|
|
|
|
|
{
|
|
|
|
|
return sd;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sd = new SafeDictionary<string, myPropInfo>();
|
|
|
|
|
var pr = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
|
|
|
|
|
foreach (var p in pr)
|
|
|
|
@ -204,7 +193,6 @@ namespace Exceptron.Client.fastJSON
|
|
|
|
|
_propertycache.Add(typename, sd);
|
|
|
|
|
return sd;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private myPropInfo CreateMyProp(Type t, string name)
|
|
|
|
|
{
|
|
|
|
@ -342,16 +330,16 @@ namespace Exceptron.Client.fastJSON
|
|
|
|
|
if (conversionType == typeof(int))
|
|
|
|
|
return (int)CreateLong((string)value);
|
|
|
|
|
|
|
|
|
|
else if (conversionType == typeof(long))
|
|
|
|
|
if (conversionType == typeof(long))
|
|
|
|
|
return CreateLong((string)value);
|
|
|
|
|
|
|
|
|
|
else if (conversionType == typeof(string))
|
|
|
|
|
if (conversionType == typeof(string))
|
|
|
|
|
return value;
|
|
|
|
|
|
|
|
|
|
else if (conversionType == typeof(Guid))
|
|
|
|
|
if (conversionType == typeof(Guid))
|
|
|
|
|
return CreateGuid((string)value);
|
|
|
|
|
|
|
|
|
|
else if (conversionType.IsEnum)
|
|
|
|
|
if (conversionType.IsEnum)
|
|
|
|
|
return CreateEnum(conversionType, (string)value);
|
|
|
|
|
|
|
|
|
|
return Convert.ChangeType(value, conversionType, CultureInfo.InvariantCulture);
|
|
|
|
@ -550,7 +538,6 @@ namespace Exceptron.Client.fastJSON
|
|
|
|
|
{
|
|
|
|
|
if (s.Length > 30)
|
|
|
|
|
return new Guid(s);
|
|
|
|
|
else
|
|
|
|
|
return new Guid(Convert.FromBase64String(s));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -571,7 +558,6 @@ namespace Exceptron.Client.fastJSON
|
|
|
|
|
|
|
|
|
|
if (UseUTCDateTime == false && utc == false)
|
|
|
|
|
return new DateTime(year, month, day, hour, min, sec);
|
|
|
|
|
else
|
|
|
|
|
return new DateTime(year, month, day, hour, min, sec, DateTimeKind.Utc).ToLocalTime();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|