Skip to content

Commit

Permalink
Fix portable version. Fix few minor bugs. Naming
Browse files Browse the repository at this point in the history
  • Loading branch information
nilproject committed Dec 9, 2015
1 parent bbac97f commit a8b7aaa
Show file tree
Hide file tree
Showing 118 changed files with 1,340 additions and 1,262 deletions.
10 changes: 6 additions & 4 deletions NiL.JS.Portable.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NiL.JS.Portable", "NiL.JS.Portable\NiL.JS.Portable.csproj", "{DEB5F360-2822-4852-95A3-964E37C802AF}"
EndProject
Expand Down Expand Up @@ -45,12 +45,14 @@ Global
{BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Debug|ARM.ActiveCfg = Debug|Any CPU
{BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Debug|x64.ActiveCfg = Debug|Any CPU
{BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Debug|x86.ActiveCfg = Debug|Any CPU
{BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Debug|x86.ActiveCfg = Debug|x86
{BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Debug|x86.Build.0 = Debug|x86
{BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Release|Any CPU.Build.0 = Release|Any CPU
{BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Release|ARM.ActiveCfg = Release|Any CPU
{BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Release|x64.ActiveCfg = Release|Any CPU
{BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Release|x86.ActiveCfg = Release|Any CPU
{BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Release|x86.ActiveCfg = Release|x86
{BF35910B-BE6F-4996-A60F-042FA57C2EE4}.Release|x86.Build.0 = Release|x86
{2D0B76DE-95A0-4263-A35D-5856F04F17BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2D0B76DE-95A0-4263-A35D-5856F04F17BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2D0B76DE-95A0-4263-A35D-5856F04F17BA}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
Expand Down
72 changes: 72 additions & 0 deletions NiL.JS.Portable/Core/Backward.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,33 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;

namespace System
{
[ComVisible(true)]
public enum TypeCode
{
Empty = 0, // Null reference
Object = 1, // Instance that isn't a value
DBNull = 2, // Database null value
Boolean = 3, // Boolean
Char = 4, // Unicode character
SByte = 5, // Signed 8-bit integer
Byte = 6, // Unsigned 8-bit integer
Int16 = 7, // Signed 16-bit integer
UInt16 = 8, // Unsigned 16-bit integer
Int32 = 9, // Signed 32-bit integer
UInt32 = 10, // Unsigned 32-bit integer
Int64 = 11, // Signed 64-bit integer
UInt64 = 12, // Unsigned 64-bit integer
Single = 13, // IEEE 32-bit float
Double = 14, // IEEE 64-bit double
Decimal = 15, // Decimal
DateTime = 16, // DateTime
String = 18, // Unicode character string
}

namespace Reflection
{
public enum MemberTypes
Expand Down Expand Up @@ -96,5 +120,53 @@ public static MethodInfo GetAddMethod(this EventInfo self)
{
return self.AddMethod;
}

private static readonly Type[] _Types =
{
null,
typeof(object),
Type.GetType("System.DBNull"),
typeof(bool),
typeof(char),
typeof(sbyte),
typeof(byte),
typeof(short),
typeof(ushort),
typeof(int),
typeof(uint),
typeof(long),
typeof(ulong),
typeof(float),
typeof(double),
typeof(decimal),
typeof(DateTime),
null,
typeof(string)
};

public static TypeCode GetTypeCode(this Type type)
{
if (type == null)
return TypeCode.Empty;

if (type.GetTypeInfo().IsClass)
{
if (type == _Types[2])
return TypeCode.DBNull;

if (type == typeof(string))
return TypeCode.String;

return TypeCode.Object;
}

for (var i = 3; i < _Types.Length; i++)
{
if (_Types[i] == type)
return (TypeCode)i;
}

return TypeCode.Object;
}
}
}
Loading

0 comments on commit a8b7aaa

Please sign in to comment.