Skip to content

Commit 90684b0

Browse files
committed
move test method to MyType
1 parent d9def41 commit 90684b0

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

Src/MyHelper/MyType.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public static class MyType
7979

8080
public static void RegisterNumExtension(Type numType, string shortName, bool hasOne = false, bool unSinged = false, bool isIEEE = false, Type extension = null)
8181
{
82+
WholeNumSet.Add(numType);
8283
if (shortName != null) ShortNames[numType] = shortName;
8384
if (hasOne) HasOneSet.Add(numType);
8485
if (unSinged) UnsignedSet.Add(numType);
@@ -100,5 +101,29 @@ public static string AliaName(this Type type)
100101
{
101102
return AliaNames.ContainsKey(type) ? ShortNames[type] : type.Name;
102103
}
104+
105+
public static void TestAllTypes()
106+
{
107+
var mt = typeof(Math<>);
108+
foreach (var t in WholeNumSet)
109+
{
110+
Console.WriteLine(t);
111+
var fs = mt.MakeGenericType(t).GetFields(MyReflection.PublicStatic);
112+
foreach (var f in fs)
113+
{
114+
try
115+
{
116+
var o = f.GetValue(null);
117+
if (o is Delegate d) continue;
118+
Console.WriteLine($"\t{f.Name} = {(o == null ? "...................." : o.ToString())}");
119+
}
120+
catch (Exception ex)
121+
{
122+
Console.WriteLine($"\t{f.Name} = !!!!!!!!!!!!!!!!!!{ex.Message}");
123+
}
124+
}
125+
}
126+
}
127+
103128
}
104129
}

Test/TestApp.cs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,8 @@ public class TestApp
1111
static void Main(string[] args)
1212
{
1313
//MyCode.AutoGenerate();
14-
TestAllTypes();
15-
//Console.WriteLine(Math<bool>.PI);
14+
MyType.TestAllTypes();
1615
Console.ReadKey();
1716
}
18-
19-
static void TestAllTypes()
20-
{
21-
var mt = typeof(Math<>);
22-
foreach (var t in MyType.WholeNumSet)
23-
{
24-
Console.WriteLine(t);
25-
var fs = mt.MakeGenericType(t).GetFields(MyReflection.PublicStatic);
26-
foreach (var f in fs)
27-
{
28-
try
29-
{
30-
var o = f.GetValue(null);
31-
if (o is Delegate d) continue;
32-
Console.WriteLine($"\t{f.Name} = {(o == null ? "...................." : o.ToString())}");
33-
}
34-
catch (Exception ex)
35-
{
36-
Console.WriteLine($"\t{f.Name} = !!!!!!!!!!!!!!!!!!{ex.Message}");
37-
}
38-
}
39-
}
40-
}
4117
}
4218
}
-1 KB
Binary file not shown.

netcoreapp5.0/Shone.Math.dll

-6.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)