@@ -70,24 +70,23 @@ private DataReader(Stream stream, IValue textEncoding, ByteOrderEnum? byteOrder,
7070 [ ScriptConstructor ( Name = "На основании двоичных данных или имени файла" ) ]
7171 public static DataReader Constructor ( IValue dataSource , IValue textEncoding = null , ByteOrderEnum ? byteOrder = null , string lineSplitter = "\n " , string convertibleSplitterOfLines = null )
7272 {
73+ Stream stream ;
7374 if ( dataSource . SystemType == BasicTypes . String )
7475 {
75- var stream = new FileStream ( dataSource . AsString ( ) , FileMode . Open , FileAccess . Read , FileShare . Read ) ;
76- return new DataReader ( stream , textEncoding , byteOrder , lineSplitter , convertibleSplitterOfLines ) ;
76+ stream = new FileStream ( dataSource . AsString ( ) , FileMode . Open , FileAccess . Read , FileShare . Read ) ;
7777 }
7878 else
7979 {
80- var obj = dataSource . AsObject ( ) ;
81- Stream stream ;
82- if ( obj is BinaryDataContext )
83- stream = ( ( BinaryDataContext ) obj ) . GetStream ( ) ;
84- else if ( obj is IStreamWrapper )
85- stream = ( ( IStreamWrapper ) obj ) . GetUnderlyingStream ( ) ;
86- else
87- throw RuntimeException . InvalidArgumentType ( "dataSource" ) ;
80+ stream = dataSource . AsObject ( ) switch
81+ {
82+ BinaryDataContext binaryData => binaryData . GetStream ( ) ,
83+ IStreamWrapper wrapper => wrapper . GetUnderlyingStream ( ) ,
8884
89- return new DataReader ( stream , textEncoding , byteOrder , lineSplitter , convertibleSplitterOfLines ) ;
85+ _ => throw RuntimeException . InvalidArgumentType ( "dataSource" )
86+ } ;
9087 }
88+
89+ return new DataReader ( stream , textEncoding , byteOrder , lineSplitter , convertibleSplitterOfLines ) ;
9190 }
9291
9392 /// <summary>
0 commit comments