@@ -28,7 +28,7 @@ namespace OneScript.StandardLibrary
2828 /// Как правило, рефлексия используется для проверки наличия у объекта определенных свойств/методов.
2929 /// В OneScript рефлексию можно применять для вызова методов объектов по именам методов.
3030 /// </summary>
31- [ ContextClass ( "Рефлектор" , "Reflector" ) ]
31+ [ ContextClass ( "Рефлектор" , "Reflector" ) ]
3232 public class ReflectorContext : AutoContext < ReflectorContext >
3333 {
3434 private readonly ITypeManager _typeManager ;
@@ -55,8 +55,8 @@ public IValue CallMethod(IBslProcess process, IRuntimeContextInstance target, st
5555 if ( target . DynamicMethodSignatures )
5656 argsToPass = arguments ? . ToArray ( ) ?? Array . Empty < IValue > ( ) ;
5757 else
58- argsToPass = GetArgsToPass ( arguments , methInfo . GetBslParameters ( ) ) ;
59-
58+ argsToPass = GetArgsToPass ( arguments , methInfo . GetBslParameters ( ) ) ;
59+
6060 IValue retValue = ValueFactory . Create ( ) ;
6161 if ( methInfo . IsFunction ( ) )
6262 {
@@ -83,9 +83,9 @@ public IValue CallMethod(IBslProcess process, IRuntimeContextInstance target, st
8383
8484 private static IValue [ ] GetArgsToPass ( ArrayImpl arguments , ParameterInfo [ ] parameters )
8585 {
86- var argValues = arguments ? . ToArray ( ) ?? Array . Empty < IValue > ( ) ;
87- // ArrayImpl не может (не должен!) содержать null или NotAValidValue
88-
86+ var argValues = arguments ? . ToArray ( ) ?? Array . Empty < IValue > ( ) ;
87+ // ArrayImpl не может (не должен!) содержать null или NotAValidValue
88+
8989 if ( argValues . Length > parameters . Length )
9090 throw RuntimeException . TooManyArgumentsPassed ( ) ;
9191
@@ -119,7 +119,7 @@ private static IValue[] GetArgsToPass(ArrayImpl arguments, ParameterInfo[] param
119119 [ ContextMethod ( "МетодСуществует" , "MethodExists" ) ]
120120 public bool MethodExists ( BslValue target , string methodName )
121121 {
122- if ( target is BslObjectValue )
122+ if ( target is BslObjectValue )
123123 return MethodExistsForObject ( target . AsObject ( ) , methodName ) ;
124124
125125 if ( target . SystemType == BasicTypes . Type )
@@ -147,8 +147,8 @@ private static bool MethodExistsForObject(IRuntimeContextInstance target, string
147147 private static ValueTable EmptyAnnotationsTable ( )
148148 {
149149 var annotationsTable = new ValueTable ( ) ;
150- annotationsTable . Columns . AddUnchecked ( "Имя" , "Имя" ) ;
151- annotationsTable . Columns . AddUnchecked ( "Параметры" , "Параметры" ) ;
150+ annotationsTable . Columns . AddUnchecked ( "Имя" ) ;
151+ annotationsTable . Columns . AddUnchecked ( "Параметры" ) ;
152152
153153 return annotationsTable ;
154154 }
@@ -199,9 +199,9 @@ private static ValueTable FillAnnotationParameters(IEnumerable<BslAnnotationPara
199199 {
200200 parameterRow . Set ( parameterValueColumn , annotationParameter . Value ) ;
201201 }
202- }
203-
204- return parametersTable ;
202+ }
203+
204+ return parametersTable ;
205205 }
206206
207207 private static bool MethodExistsForType ( BslTypeValue type , string methodName )
@@ -213,7 +213,7 @@ private static bool MethodExistsForType(BslTypeValue type, string methodName)
213213 private static Type GetReflectableClrType ( BslTypeValue type )
214214 {
215215 var clrType = type . TypeValue . ImplementingClass ;
216- if ( clrType != typeof ( AttachedScriptsFactory ) && ! typeof ( IRuntimeContextInstance ) . IsAssignableFrom ( clrType ) )
216+ if ( clrType != typeof ( AttachedScriptsFactory ) && ! typeof ( IRuntimeContextInstance ) . IsAssignableFrom ( clrType ) )
217217 {
218218 throw NonReflectableType ( ) ;
219219 }
@@ -241,7 +241,7 @@ private static RuntimeException NonReflectableType()
241241 public ValueTable GetMethodsTable ( BslValue target )
242242 {
243243 var result = new ValueTable ( ) ;
244- if ( target is BslObjectValue )
244+ if ( target is BslObjectValue )
245245 FillMethodsTableForObject ( target . AsObject ( ) , result ) ;
246246 else if ( target . SystemType == BasicTypes . Type )
247247 FillMethodsTableForType ( target as BslTypeValue , result ) ;
@@ -259,21 +259,21 @@ private static void FillMethodsTableForObject(IRuntimeContextInstance target, Va
259259 private static void FillMethodsTableForType ( BslTypeValue type , ValueTable result )
260260 {
261261 var clrType = GetReflectableClrType ( type ) ;
262- var clrMethods = clrType . GetMethods ( BindingFlags . Instance | BindingFlags . NonPublic | BindingFlags . Public ) ;
262+ var clrMethods = clrType . GetMethods ( BindingFlags . Instance | BindingFlags . NonPublic | BindingFlags . Public ) ;
263263 FillMethodsTable ( result , clrMethods . Cast < BslMethodInfo > ( ) ) ;
264264 }
265265
266266 private void FillPropertiesTableForObject ( ValueTable result , IValue target , bool withPrivate )
267267 {
268268 if ( target is ScriptDrivenObject scriptObject )
269269 {
270- var fieldsQuery = scriptObject . Module . Fields . Cast < BslScriptFieldInfo > ( ) ;
271-
270+ var fieldsQuery = scriptObject . Module . Fields . Cast < BslScriptFieldInfo > ( ) ;
271+
272272 if ( ! withPrivate )
273273 {
274274 fieldsQuery = fieldsQuery . Where ( x => x . IsPublic ) ;
275- }
276-
275+ }
276+
277277 var fields = fieldsQuery . Select ( field => BslPropertyBuilder . Create ( )
278278 . Name ( field . Name )
279279 . IsExported ( field . IsPublic )
@@ -282,29 +282,29 @@ private void FillPropertiesTableForObject(ValueTable result, IValue target, bool
282282 . Build ( )
283283 )
284284 . OrderBy ( p => p . DispatchId )
285- . ToArray ( ) ;
286-
285+ . ToArray ( ) ;
286+
287287 var fieldNames = fields . Select ( x => x . Name )
288- . ToHashSet ( ) ;
289-
288+ . ToHashSet ( ) ;
289+
290290 var properties = scriptObject . GetProperties ( )
291291 . Where ( prop => ! fieldNames . Contains ( prop . Name ) ) ;
292292
293293 if ( ! withPrivate )
294294 {
295295 properties = properties . OfType < BslScriptPropertyInfo > ( )
296296 . Where ( p => p . IsExported ) ;
297- }
298-
297+ }
298+
299299 FillPropertiesTable ( result , properties . Concat ( fields ) ) ;
300300 }
301301 else
302302 {
303303 var objectProperties = target . AsObject ( ) . GetProperties ( ) ;
304304 FillPropertiesTable ( result , objectProperties ) ;
305305 }
306- }
307-
306+ }
307+
308308 private static void FillPropertiesTableForType ( BslTypeValue type , ValueTable result , bool withPrivate )
309309 {
310310 var clrType = GetReflectableClrType ( type ) ;
@@ -314,7 +314,7 @@ private static void FillPropertiesTableForType(BslTypeValue type, ValueTable res
314314 PropDef = x . GetCustomAttribute < ContextPropertyAttribute > ( ) ,
315315 Prop = x
316316 } )
317- . Where ( x=> x . PropDef != null )
317+ . Where ( x => x . PropDef != null )
318318 . Select ( x => new ContextPropertyInfo ( x . Prop ) ) ;
319319
320320 var infos = new List < BslPropertyInfo > ( ) ;
@@ -324,20 +324,20 @@ private static void FillPropertiesTableForType(BslTypeValue type, ValueTable res
324324
325325 if ( typeof ( ScriptDrivenObject ) . IsAssignableFrom ( clrType . BaseType ) )
326326 {
327- var flags = BindingFlags . Instance | BindingFlags . Public ;
327+ var flags = BindingFlags . Instance | BindingFlags . Public ;
328328 if ( withPrivate )
329329 flags |= BindingFlags . NonPublic ;
330330
331331 var nativeFields = clrType . GetFields ( flags ) ;
332- foreach ( var field in nativeFields )
332+ foreach ( var field in nativeFields )
333333 {
334334 var prop = BslPropertyBuilder . Create ( )
335335 . Name ( field . Name )
336336 . IsExported ( field . IsPublic )
337337 . SetDispatchingIndex ( indices ++ )
338338 . SetAnnotations ( field . GetAnnotations ( ) )
339- . Build ( ) ;
340-
339+ . Build ( ) ;
340+
341341 infos . Add ( prop ) ;
342342 }
343343 }
@@ -348,18 +348,18 @@ private static void FillPropertiesTableForType(BslTypeValue type, ValueTable res
348348
349349 private static void FillMethodsTable ( ValueTable result , IEnumerable < BslMethodInfo > methods )
350350 {
351- var nameColumn = result . Columns . AddUnchecked ( "Имя" , "Имя" , TypeDescription . StringType ( ) ) ;
352- var countColumn = result . Columns . AddUnchecked ( "КоличествоПараметров" , "Количество параметров" , TypeDescription . IntegerType ( ) ) ;
353- var isFunctionColumn = result . Columns . AddUnchecked ( "ЭтоФункция" , "Это функция" , TypeDescription . BooleanType ( ) ) ;
354- var annotationsColumn = result . Columns . AddUnchecked ( "Аннотации" , "Аннотации" ) ;
355- var paramsColumn = result . Columns . AddUnchecked ( "Параметры" , "Параметры" ) ;
356- var isExportlColumn = result . Columns . AddUnchecked ( "Экспорт" , "Экспорт" , TypeDescription . BooleanType ( ) ) ;
351+ var nameColumn = result . Columns . AddUnchecked ( "Имя" ) ;
352+ var countColumn = result . Columns . AddUnchecked ( "КоличествоПараметров" , "Количество параметров" ) ;
353+ var isFunctionColumn = result . Columns . AddUnchecked ( "ЭтоФункция" , "Это функция" ) ;
354+ var annotationsColumn = result . Columns . AddUnchecked ( "Аннотации" ) ;
355+ var paramsColumn = result . Columns . AddUnchecked ( "Параметры" ) ;
356+ var isExportlColumn = result . Columns . AddUnchecked ( "Экспорт" ) ;
357357
358358 foreach ( var methInfo in methods )
359359 {
360360 var annotations = methInfo . GetAnnotations ( ) ;
361- var parameters = methInfo . GetBslParameters ( ) ;
362-
361+ var parameters = methInfo . GetBslParameters ( ) ;
362+
363363 ValueTableRow new_row = result . Add ( ) ;
364364 new_row . Set ( nameColumn , ValueFactory . Create ( methInfo . Name ) ) ;
365365 new_row . Set ( countColumn , ValueFactory . Create ( parameters . Length ) ) ;
@@ -369,11 +369,11 @@ private static void FillMethodsTable(ValueTable result, IEnumerable<BslMethodInf
369369 new_row . Set ( annotationsColumn , CreateAnnotationTable ( annotations ) ) ;
370370
371371 var paramTable = new ValueTable ( ) ;
372- var paramNameColumn = paramTable . Columns . AddUnchecked ( "Имя" , "Имя" , TypeDescription . StringType ( ) ) ;
373- var paramByValue = paramTable . Columns . AddUnchecked ( "ПоЗначению" , "По значению" , TypeDescription . BooleanType ( ) ) ;
374- var paramHasDefaultValue = paramTable . Columns . AddUnchecked ( "ЕстьЗначениеПоУмолчанию" , "Есть значение по-умолчанию" , TypeDescription . BooleanType ( ) ) ;
372+ var paramNameColumn = paramTable . Columns . AddUnchecked ( "Имя" ) ;
373+ var paramByValue = paramTable . Columns . AddUnchecked ( "ПоЗначению" , "По значению" ) ;
374+ var paramHasDefaultValue = paramTable . Columns . AddUnchecked ( "ЕстьЗначениеПоУмолчанию" , "Есть значение по-умолчанию" ) ;
375375 var paramDefaultValue = paramTable . Columns . AddUnchecked ( "ЗначениеПоУмолчанию" , "Значение по умолчанию" ) ;
376- var paramAnnotationsColumn = paramTable . Columns . AddUnchecked ( "Аннотации" , "Аннотации" ) ;
376+ var paramAnnotationsColumn = paramTable . Columns . AddUnchecked ( "Аннотации" ) ;
377377 new_row . Set ( paramsColumn , paramTable ) ;
378378
379379 if ( parameters . Length != 0 )
@@ -404,7 +404,7 @@ public ValueTable GetPropertiesTable(BslValue target, bool withPrivate = false)
404404 {
405405 var result = new ValueTable ( ) ;
406406
407- if ( target is BslObjectValue )
407+ if ( target is BslObjectValue )
408408 FillPropertiesTableForObject ( result , target , withPrivate ) ;
409409 else if ( target . SystemType == BasicTypes . Type )
410410 {
@@ -457,10 +457,10 @@ public void SetProperty(IRuntimeContextInstance target, string prop, IValue valu
457457
458458 private static void FillPropertiesTable ( ValueTable result , IEnumerable < BslPropertyInfo > properties )
459459 {
460- var nameColumn = result . Columns . AddUnchecked ( "Имя" , "Имя" , TypeDescription . StringType ( ) ) ;
461- var annotationsColumn = result . Columns . AddUnchecked ( "Аннотации" , "Аннотации" ) ;
462- var isExportedColumn = result . Columns . AddUnchecked ( "Экспорт" , "Экспорт" , TypeDescription . BooleanType ( ) ) ;
463-
460+ var nameColumn = result . Columns . AddUnchecked ( "Имя" ) ;
461+ var annotationsColumn = result . Columns . AddUnchecked ( "Аннотации" ) ;
462+ var isExportedColumn = result . Columns . AddUnchecked ( "Экспорт" ) ;
463+
464464 var systemVarNames = new string [ ] { "этотобъект" , "thisobject" } ;
465465
466466 foreach ( var propInfo in properties )
@@ -533,18 +533,18 @@ public static Type ReflectContext(Type clrType)
533533 [ ContextMethod ( "ИзвестныеТипы" , "KnownTypes" ) ]
534534 public ValueTable KnownTypes ( StructureImpl filter = default )
535535 {
536- var result = new ValueTable ( ) ;
537-
538- var nameColumn = result . Columns . AddUnchecked ( "Имя" , "Имя" , TypeDescription . StringType ( ) ) ;
539- var valueColumn = result . Columns . AddUnchecked ( "Значение" , "Значение" , new TypeDescription ( new [ ] { new BslTypeValue ( BasicTypes . Type ) } ) ) ;
540- var primitiveColumn = result . Columns . AddUnchecked ( "Примитивный" , "Примитивный" , TypeDescription . BooleanType ( ) ) ;
541- var userColumn = result . Columns . AddUnchecked ( "Пользовательский" , "Пользовательский" , TypeDescription . BooleanType ( ) ) ;
542- var collectionColumn = result . Columns . AddUnchecked ( "Коллекция" , "Коллекция" , TypeDescription . BooleanType ( ) ) ;
543-
536+ var result = new ValueTable ( ) ;
537+
538+ var nameColumn = result . Columns . AddUnchecked ( "Имя" ) ;
539+ var valueColumn = result . Columns . AddUnchecked ( "Значение" ) ;
540+ var primitiveColumn = result . Columns . AddUnchecked ( "Примитивный" ) ;
541+ var userColumn = result . Columns . AddUnchecked ( "Пользовательский" ) ;
542+ var collectionColumn = result . Columns . AddUnchecked ( "Коллекция" ) ;
543+
544544 _typeManager . RegisteredTypes ( ) . ForEach ( descriptor =>
545545 {
546- var row = result . Add ( ) ;
547-
546+ var row = result . Add ( ) ;
547+
548548 row . Set ( nameColumn , ValueFactory . Create ( descriptor . ToString ( ) ) ) ;
549549 row . Set ( valueColumn , new BslTypeValue ( descriptor ) ) ;
550550 row . Set ( primitiveColumn , ValueFactory . Create ( descriptor . ImplementingClass . IsSubclassOf ( typeof ( BslPrimitiveValue ) ) ) ) ;
@@ -557,8 +557,8 @@ public ValueTable KnownTypes(StructureImpl filter = default)
557557 if ( filter != default )
558558 {
559559 result = result . Copy ( filter ) ;
560- }
561-
560+ }
561+
562562 return result ;
563563 }
564564
0 commit comments