@@ -87,7 +87,7 @@ internal void SetInstance(TContract realInstance)
87
87
/// <param name="methodInvoker">对接实现。</param>
88
88
protected void MatchMethod ( ulong memberId , Action methodInvoker )
89
89
{
90
- _methods . Add ( memberId , ( Array . Empty < Type > ( ) , _ =>
90
+ _methods . Add ( memberId , ( EmptyTypeArray , _ =>
91
91
{
92
92
methodInvoker ( ) ;
93
93
return DefaultGarm ;
@@ -102,7 +102,7 @@ protected void MatchMethod(ulong memberId, Action methodInvoker)
102
102
/// <param name="methodInvoker">对接实现。</param>
103
103
protected void MatchMethod < TReturn > ( ulong memberId , Func < Garm < TReturn > > methodInvoker )
104
104
{
105
- _methods . Add ( memberId , ( Array . Empty < Type > ( ) , _ => methodInvoker ( ) ) ) ;
105
+ _methods . Add ( memberId , ( EmptyTypeArray , _ => methodInvoker ( ) ) ) ;
106
106
}
107
107
108
108
/// <summary>
@@ -112,7 +112,7 @@ protected void MatchMethod<TReturn>(ulong memberId, Func<Garm<TReturn>> methodIn
112
112
/// <param name="methodInvoker">对接实现。</param>
113
113
protected void MatchMethod ( ulong memberId , Func < Task > methodInvoker )
114
114
{
115
- _asyncMethods . Add ( memberId , ( Array . Empty < Type > ( ) , async _ =>
115
+ _asyncMethods . Add ( memberId , ( EmptyTypeArray , async _ =>
116
116
{
117
117
await methodInvoker ( ) . ConfigureAwait ( false ) ;
118
118
return DefaultGarm ;
@@ -127,7 +127,7 @@ protected void MatchMethod(ulong memberId, Func<Task> methodInvoker)
127
127
/// <param name="methodInvoker">对接实现。</param>
128
128
protected void MatchMethod < TReturn > ( ulong memberId , Func < Task < Garm < TReturn > > > methodInvoker )
129
129
{
130
- _asyncMethods . Add ( memberId , ( Array . Empty < Type > ( ) , async _ => await methodInvoker ( ) . ConfigureAwait ( false ) ) ) ;
130
+ _asyncMethods . Add ( memberId , ( EmptyTypeArray , async _ => await methodInvoker ( ) . ConfigureAwait ( false ) ) ) ;
131
131
}
132
132
133
133
/// <summary>
@@ -145,6 +145,15 @@ protected void MatchMethod<T>(ulong memberId, Action<T> methodInvoker)
145
145
) ) ;
146
146
}
147
147
148
+ private static Type [ ] EmptyTypeArray
149
+
150
+ #if NET461_OR_GREATER || NETCOREAPP3_0_OR_GREATER
151
+ => Array . Empty < Type > ( ) ;
152
+ #else
153
+ => new Type [ 0 ] ;
154
+ #endif
155
+
156
+
148
157
/// <summary>
149
158
/// 匹配一个 IPC 目标对象上的某个方法,使其他 IPC 节点访问此 IPC 对象时能执行 <paramref name="methodInvoker"/> 所指向的具体实现。
150
159
/// </summary>
@@ -187,7 +196,7 @@ protected void MatchMethod<T, TReturn>(ulong memberId, Func<T, Task<Garm<TReturn
187
196
/// <param name="getter">get 的对接实现。</param>
188
197
protected void MatchProperty < T > ( ulong getPropertyId , Func < Garm < T > > getter )
189
198
{
190
- _propertyGetters . Add ( getPropertyId , ( Array . Empty < Type > ( ) , ( ) => getter ( ) ) ) ;
199
+ _propertyGetters . Add ( getPropertyId , ( EmptyTypeArray , ( ) => getter ( ) ) ) ;
191
200
}
192
201
193
202
/// <summary>
@@ -199,7 +208,7 @@ protected void MatchProperty<T>(ulong getPropertyId, Func<Garm<T>> getter)
199
208
/// <param name="setter">set 的对接实现。</param>
200
209
protected void MatchProperty < T > ( ulong getPropertyId , ulong setPropertyId , Func < Garm < T > > getter , Action < T > setter )
201
210
{
202
- _propertyGetters . Add ( getPropertyId , ( Array . Empty < Type > ( ) , ( ) => getter ( ) ) ) ;
211
+ _propertyGetters . Add ( getPropertyId , ( EmptyTypeArray , ( ) => getter ( ) ) ) ;
203
212
_propertySetters . Add ( setPropertyId , ( new [ ] { typeof ( T ) } , value => setter ( CastArg < T > ( value ) ! ) ) ) ;
204
213
}
205
214
0 commit comments