@@ -23,7 +23,7 @@ namespace ScriptEngine.Machine
2323{
2424 public class NotBslValueWrapper : ContextIValueImpl , IObjectWrapper
2525 {
26- private readonly object _initLocker = new object ( ) ;
26+ private static readonly object InitLocker = new object ( ) ;
2727 private readonly Type _underlyingType ;
2828
2929 private static readonly Dictionary < Type , IndexedNamesCollection > PropertiesIndexers =
@@ -51,7 +51,7 @@ private void InitMethodsProperties()
5151 {
5252 var objType = UnderlyingObject . GetType ( ) ;
5353
54- lock ( _initLocker )
54+ lock ( InitLocker )
5555 {
5656 // Свойства и методы уже были закешированы
5757 if ( PropertiesIndexers . ContainsKey ( objType ) )
@@ -71,7 +71,7 @@ private void InitMethodsProperties()
7171 foreach ( var property in props )
7272 {
7373 var info = new ContextPropertyInfo ( property ) ;
74- var id = propertiesIndex . RegisterName ( info . Name , info . Alias ) ;
74+ var id = propertiesIndex . RegisterName ( info . Name , string . IsNullOrEmpty ( info . Alias ) ? null : info . Alias ) ;
7575
7676 propertiesCache . Add ( id , info ) ;
7777 }
@@ -83,7 +83,7 @@ private void InitMethodsProperties()
8383 foreach ( var method in methods )
8484 {
8585 var info = new ContextMethodInfo ( method ) ;
86- var id = methodsIndex . RegisterName ( info . Name , info . Alias ) ;
86+ var id = methodsIndex . RegisterName ( info . Name , string . IsNullOrEmpty ( info . Alias ) ? null : info . Alias ) ;
8787
8888 methodsCache . Add ( id , info ) ;
8989 }
@@ -170,16 +170,24 @@ public override void CallAsProcedure(int methodNumber, IValue[] arguments, IBslP
170170 {
171171 var method = GetMethodsCache ( ) [ methodNumber ] ;
172172
173- var args = arguments . Select ( ContextValuesMarshaller . ConvertToClrObject ) . ToArray ( ) ;
174- method . Invoke ( UnderlyingObject , args ) ;
173+ var args = arguments . Select ( ContextValuesMarshaller . ConvertToClrObject ) . ToList ( ) ;
174+
175+ if ( method . InjectsProcess )
176+ args . Insert ( 0 , process ) ;
177+
178+ method . Invoke ( UnderlyingObject , args . ToArray ( ) ) ;
175179 }
176180
177181 public override void CallAsFunction ( int methodNumber , IValue [ ] arguments , out IValue retValue , IBslProcess process )
178182 {
179183 var method = GetMethodsCache ( ) [ methodNumber ] ;
180184
181- var args = arguments . Select ( c => ContextValuesMarshaller . ConvertParam ( c , method . ReturnType , process ) ) . ToArray ( ) ;
182- var result = method . Invoke ( UnderlyingObject , args ) ;
185+ var args = arguments . Select ( c => ContextValuesMarshaller . ConvertParam ( c , method . ReturnType , process ) ) . ToList ( ) ;
186+
187+ if ( method . InjectsProcess )
188+ args . Insert ( 0 , process ) ;
189+
190+ var result = method . Invoke ( UnderlyingObject , args . ToArray ( ) ) ;
183191
184192 if ( method . TryGetConverter ( out var converter ) )
185193 {
0 commit comments