Skip to content

Commit 46202ce

Browse files
committed
Revert "remove"
This reverts commit 8ec880a.
1 parent 8ec880a commit 46202ce

30 files changed

Lines changed: 6348 additions & 0 deletions

‎CSharp.lua/CSharp.lua.csproj‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,35 @@
8989
</ItemGroup>
9090
<ItemGroup>
9191
<None Include="App.config" />
92+
<None Include="CoreSystem.Lua\All.lua" />
93+
<None Include="CoreSystem.Lua\CoreSystem\Array.lua" />
94+
<None Include="CoreSystem.Lua\CoreSystem\Boolean.lua" />
95+
<None Include="CoreSystem.Lua\CoreSystem\Char.lua" />
96+
<None Include="CoreSystem.Lua\CoreSystem\Collection.lua" />
97+
<None Include="CoreSystem.Lua\CoreSystem\Collections\Dictionary.lua" />
98+
<None Include="CoreSystem.Lua\CoreSystem\Collections\EqualityComparer.lua" />
99+
<None Include="CoreSystem.Lua\CoreSystem\Collections\HashSet.lua" />
100+
<None Include="CoreSystem.Lua\CoreSystem\Collections\LinkedList.lua" />
101+
<None Include="CoreSystem.Lua\CoreSystem\Collections\Linq.lua" />
102+
<None Include="CoreSystem.Lua\CoreSystem\Collections\List.lua" />
103+
<None Include="CoreSystem.Lua\CoreSystem\Collections\Queue.lua" />
104+
<None Include="CoreSystem.Lua\CoreSystem\Collections\Stack.lua" />
105+
<None Include="CoreSystem.Lua\CoreSystem\Console.lua" />
106+
<None Include="CoreSystem.Lua\CoreSystem\Core.lua" />
107+
<None Include="CoreSystem.Lua\CoreSystem\DateTime.lua" />
108+
<None Include="CoreSystem.Lua\CoreSystem\Delegate.lua" />
109+
<None Include="CoreSystem.Lua\CoreSystem\Double.lua" />
110+
<None Include="CoreSystem.Lua\CoreSystem\Enum.lua" />
111+
<None Include="CoreSystem.Lua\CoreSystem\Exception.lua" />
112+
<None Include="CoreSystem.Lua\CoreSystem\Int.lua" />
113+
<None Include="CoreSystem.Lua\CoreSystem\Interfaces.lua" />
114+
<None Include="CoreSystem.Lua\CoreSystem\IO\File.lua" />
115+
<None Include="CoreSystem.Lua\CoreSystem\Math.lua" />
116+
<None Include="CoreSystem.Lua\CoreSystem\String.lua" />
117+
<None Include="CoreSystem.Lua\CoreSystem\Text\StringBuilder.lua" />
118+
<None Include="CoreSystem.Lua\CoreSystem\TimeSpan.lua" />
119+
<None Include="CoreSystem.Lua\CoreSystem\Type.lua" />
120+
<None Include="CoreSystem.Lua\Sample\test.lua" />
92121
<None Include="packages.config" />
93122
</ItemGroup>
94123
<ItemGroup>

‎CSharp.lua/CoreSystem.Lua/All.lua‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
return function(dir)
2+
dir = (dir and #dir > 0) and (dir .. ".CoreSystem.") or "CoreSystem."
3+
local require = require
4+
local load = function(module) return require(dir .. module) end
5+
6+
load("Core");
7+
load("Interfaces")
8+
load("Exception")
9+
load("Double")
10+
load("Int")
11+
load("Char")
12+
load("String")
13+
load("Boolean")
14+
load("Delegate")
15+
load("Enum")
16+
load("TimeSpan")
17+
load("DateTime")
18+
load("Type")
19+
load("Collections.EqualityComparer")
20+
load("Collection")
21+
load("Array")
22+
load("Collections.List")
23+
load("Collections.Dictionary")
24+
load("Collections.Queue")
25+
load("Collections.Stack")
26+
load("Collections.HashSet")
27+
load("Collections.LinkedList")
28+
load("Collections.Linq")
29+
load("Math")
30+
load("Text.StringBuilder")
31+
load("Console")
32+
load("IO.File")
33+
end
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
local System = System
2+
local Collection = System.Collection
3+
local buildArray = Collection.buildArray
4+
local checkIndex = Collection.checkIndex
5+
local arrayEnumerator = Collection.arrayEnumerator
6+
7+
local Array = {}
8+
local emptys = {}
9+
10+
Array.__ctor__ = buildArray
11+
Array.set = Collection.setArray
12+
Array.get = Collection.getArray
13+
Array.GetEnumerator = arrayEnumerator
14+
15+
function Array.getLength(this)
16+
return #this
17+
end
18+
19+
function Array.getCount(this)
20+
return #this
21+
end
22+
23+
function Array.getRank(this)
24+
return 1
25+
end
26+
27+
function Array.Empty(T)
28+
local t = emptys[T]
29+
if t == nil then
30+
t = Array(T)(0)
31+
emptys[T] = t
32+
end
33+
return t
34+
end
35+
36+
Array.Exists = Collection.existsOfArray
37+
Array.Find = Collection.findOfArray
38+
39+
local findAll = Collection.findAllOfArray
40+
function Array.FindAll(t, match)
41+
return findAll(t, match):toArray()
42+
end
43+
44+
Array.FindIndex = Collection.findIndexOfArray
45+
Array.FindLast = Collection.findLastOfArray
46+
Array.FindLastIndex = Collection.findLastIndexOfArray
47+
Array.IndexOf = Collection.indexOfArray
48+
Array.LastIndexOf = Collection.lastIndexOfArray
49+
Array.Reverse = Collection.reverseArray
50+
Array.Sort = Collection.sortArray
51+
Array.TrueForAll = Collection.trueForAllOfArray
52+
Array.Copy = Collection.copyArray
53+
54+
System.define("System.Array", function(T)
55+
local cls = {
56+
__inherits__ = { System.IList_1(T), System.IList },
57+
__genericT__ = T
58+
}
59+
return cls
60+
end, Array)
61+
62+
function System.arrayFromTable(t, T)
63+
return setmetatable(t, System.Array(T))
64+
end
65+
66+
local MultiArray = {}
67+
68+
function MultiArray.__ctor__(this, rank, ...)
69+
this.__rank__ = rank
70+
local length = 1
71+
for _, i in ipairs(rank) do
72+
length = length * i
73+
end
74+
buildArray(this, length, ...)
75+
end
76+
77+
local function getIndex(this, ...)
78+
local rank = this.__rank__
79+
local id = 0
80+
local len = #rank
81+
for i = 1, len do
82+
id = id * rank[i] + select(i, ...)
83+
end
84+
return id, len
85+
end
86+
87+
function MultiArray.set(this, ...)
88+
local index, len = getIndex(this, ...)
89+
setArray(this, index, select(len + 1, ...))
90+
end
91+
92+
function MultiArray.get(this, ...)
93+
local index = getIndex(this, ...)
94+
return getArray(this, index)
95+
end
96+
97+
function MultiArray.getLength(this, dimension)
98+
if dimension == nil then
99+
return #this
100+
end
101+
local rank = this.__rank__
102+
checkIndex(rank, dimension)
103+
return this.__rank__[dimension + 1]
104+
end
105+
106+
function MultiArray.getRank(this)
107+
return #this.__rank__
108+
end
109+
110+
MultiArray.GetEnumerator = arrayEnumerator
111+
112+
System.define("System.MultiArray", function(T)
113+
local cls = {
114+
__inherits__ = { System.IList_1(T), System.IList },
115+
__genericT__ = T
116+
}
117+
return cls
118+
end, MultiArray)
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
local System = System
2+
local throw = System.throw
3+
local ArgumentException = System.ArgumentException
4+
local ArgumentNullException = System.ArgumentNullException
5+
local FormatException = System.FormatException
6+
7+
local type = type
8+
9+
local Boolean = {}
10+
debug.setmetatable(false, Boolean)
11+
12+
local function compare(this, v)
13+
if this == v then
14+
return 0
15+
elseif this == false then
16+
return -1
17+
end
18+
return 1
19+
end
20+
21+
Boolean.CompareTo = compare
22+
23+
function Boolean.CompareToObj(this, v)
24+
if v == null then return 1 end
25+
if type(v) ~= "boolean" then
26+
throw(ArgumentException("Arg_MustBeBoolean"))
27+
end
28+
return compare(this, v)
29+
end
30+
31+
function Boolean.Equals(this, v)
32+
return this == v
33+
end
34+
35+
function Boolean.EqualsObj(this, v)
36+
if type(v) ~= "boolean" then
37+
return false
38+
end
39+
return this == v
40+
end
41+
42+
Boolean.ToString = tostring
43+
44+
local function parse(s)
45+
if s == nil then
46+
return nil, 1
47+
end
48+
s = s:lower()
49+
if s == "true" then
50+
return true
51+
elseif s == "false" then
52+
return false
53+
end
54+
return nil, 2
55+
end
56+
57+
function Boolean.Parse(s)
58+
local v, err = parse(s)
59+
if v == nil then
60+
if err == 1 then
61+
throw(ArgumentNullException())
62+
else
63+
throw(FormatException())
64+
end
65+
end
66+
return v
67+
end
68+
69+
function Boolean.TryParse(s)
70+
local v = parse(s)
71+
if v ~= nil then
72+
return true, v
73+
end
74+
return false, false
75+
end
76+
77+
function Boolean.__default__()
78+
return false
79+
end
80+
81+
function Boolean.__inherits__()
82+
return { System.IComparable, System.IComparable_1(Boolean), System.IEquatable_1(Boolean) }
83+
end
84+
85+
System.defStc("System.Boolean", Boolean)
86+
87+

0 commit comments

Comments
 (0)