-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDotNetUtility.ms
More file actions
81 lines (72 loc) · 2.3 KB
/
DotNetUtility.ms
File metadata and controls
81 lines (72 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*! © 2022 imaoki | MIT License | https://github.com/imaoki */
/*-
.NET用の追加メソッドを提供する。
*/
struct DotNetUtilityStruct (
/*
public fn IsInstanceOf typeName obj = (),
public fn IsSubclassOf typeName obj = (),
public fn TypeOf obj = (),
*/
/*-
オブジェクトが指定した型のインスタンスかどうかを判定する。
@param typeName <String> 型のアセンブリ修飾名。
@param obj <DotNetObject:Any>
@returns <BooleanClass>
*/
public fn IsInstanceOf typeName obj = (
classOf typeName == String \
and classOf obj == DotNetObject \
and (DotNet.GetType typeName).IsInstanceOfType obj
),
/*-
クラス、またはオブジェクトが指定した型から派生しているかどうかを判定する。
@param typeName <String> 型のアセンブリ修飾名。
@param obj <DotNetClass:Any|DotNetObject:Any>
@returns <BooleanClass>
*/
public fn IsSubclassOf typeName obj = (
classOf typeName == String \
and (classOf obj == DotNetClass or classOf obj == DotNetObject) \
and (DotNet.GetType obj).IsSubclassOf (DotNet.GetType typeName)
),
/*-
型の完全修飾名を取得する。
@param obj <DotNetClass:Any|DotNetObject:Any>
@returns <String>
@remarks `DotNetClass`および`DotNetObject`以外の場合は`classOf`の結果を文字列化する。
*/
public fn TypeOf obj = (
if classOf obj == DotNetClass or classOf obj == DotNetObject then (
(DotNet.GetType obj).FullName
)
else (
(classOf obj) as String
)
),
/*- @returns <Name> */
public fn StructName = #DotNetUtilityStruct,
/*-
@param indent: <String>
@param out: <FileStream|StringStream|WindowStream> 出力先。既定値は`listener`。
@returns <OkClass>
*/
public fn Dump indent:"" out:listener = (
format "%DotNetUtilityStruct\n" indent to:out
ok
),
/*-
@param obj <Any>
@returns <BooleanClass>
@remarks 大文字と小文字を区別する。
*/
public fn Equals obj = (
local isEqualStructName = isStruct obj \
and isProperty obj #StructName \
and classOf obj.StructName == MAXScriptFunction \
and obj.StructName() == this.StructName()
local isEqualProperties = true
isEqualStructName and isEqualProperties
),
on Create do ()
)