@@ -5,7 +5,6 @@ This Source Code Form is subject to the terms of the
55at http://mozilla.org/MPL/2.0/.
66----------------------------------------------------------*/
77
8- using System ;
98using System . Collections . Generic ;
109using OneScript . Commons ;
1110using OneScript . Contexts ;
@@ -29,11 +28,10 @@ public StructureImpl()
2928
3029 public StructureImpl ( string strProperties , params IValue [ ] values )
3130 {
32- var props = strProperties . Split ( ',' ) ;
33-
34- for ( int i = 0 , nprop = 0 ; i < props . Length ; i ++ )
31+ var nprop = 0 ;
32+ foreach ( var item in strProperties . Split ( ',' ) )
3533 {
36- var prop = props [ i ] . Trim ( ) ;
34+ var prop = item . Trim ( ) ;
3735 if ( prop . Equals ( string . Empty ) )
3836 continue ;
3937
@@ -49,7 +47,7 @@ public StructureImpl(FixedStructureImpl structure)
4947 Insert ( keyValue . Key . AsString ( ) , keyValue . Value ) ;
5048 }
5149 }
52-
50+
5351 [ ContextMethod ( "Вставить" ) ]
5452 public void Insert ( string name , IValue val = null )
5553 {
@@ -66,7 +64,7 @@ public void Insert(string name, IValue val = null)
6664 {
6765 val = ValueFactory . Create ( ) ;
6866 }
69-
67+
7068 SetPropValue ( num , val ) ;
7169 }
7270
@@ -255,20 +253,14 @@ private static StructureImpl Constructor(FixedStructureImpl fixedStruct)
255253 [ ScriptConstructor ( Name = "По ключам и значениям" ) ]
256254 public static StructureImpl Constructor ( IValue param1 , IValue [ ] args )
257255 {
258- var rawArgument = param1 ? . GetRawValue ( ) ;
259- if ( rawArgument == null )
260- return new StructureImpl ( ) ;
261-
262- if ( rawArgument is BslStringValue s )
256+ return param1 ? . GetRawValue ( ) switch
263257 {
264- return new StructureImpl ( ( string ) s , args ) ;
265- }
266- else if ( rawArgument is FixedStructureImpl )
267- {
268- return new StructureImpl ( rawArgument as FixedStructureImpl ) ;
269- }
270-
271- throw new RuntimeException ( "В качестве параметра для конструктора можно передавать только ФиксированнаяСтруктура или Ключи и Значения" ) ;
258+ null => new StructureImpl ( ) ,
259+ BslStringValue s => new StructureImpl ( ( string ) s , args ) ,
260+ FixedStructureImpl fixedstr => new StructureImpl ( fixedstr ) ,
261+
262+ _ => throw new RuntimeException ( "В качестве параметра для конструктора можно передавать только ФиксированнаяСтруктура или Ключи и Значения" )
263+ } ;
272264 }
273265
274266
0 commit comments