@@ -19,7 +19,7 @@ This Source Code Form is subject to the terms of the
1919namespace OneScript . StandardLibrary . Hash
2020{
2121 [ ContextClass ( "ХешированиеДанных" , "DataHashing" ) ]
22- public class HashImpl : AutoContext < HashImpl >
22+ public class HashImpl : AutoContext < HashImpl > , IDisposable
2323 {
2424 private const int BUFFER_SIZE = ( 1024 * 32 ) ;
2525
@@ -131,7 +131,7 @@ public void Append(BslValue toAdd, int count = 0)
131131 if ( count <= 0 )
132132 AppendStream ( stream ) ;
133133 else
134- AppendStream ( stream , count ) ;
134+ AppendStream ( stream , count ) ;
135135 break ;
136136 case BinaryDataContext binaryData :
137137 AppendStream ( binaryData . GetStream ( ) ) ;
@@ -147,11 +147,8 @@ public void AppendFile(string path)
147147 if ( ! File . Exists ( path ) )
148148 throw RuntimeException . InvalidArgumentType ( ) ;
149149
150- using ( var stream = new FileStream ( path , FileMode . Open , FileAccess . Read , FileShare . ReadWrite ) )
151- {
152- AppendStream ( stream ) ;
153- stream . Close ( ) ;
154- }
150+ using var stream = new FileStream ( path , FileMode . Open , FileAccess . Read , FileShare . ReadWrite ) ;
151+ AppendStream ( stream ) ;
155152 }
156153
157154 [ ScriptConstructor ( Name = "По указанной хеш-функции" ) ]
@@ -175,7 +172,11 @@ private static HashAlgorithmName GetAlgorithmName(HashFunctionEnum algo)
175172 HashFunctionEnum . SHA512 => HashAlgorithmName . SHA512 ,
176173 _ => throw RuntimeException . InvalidArgumentValue ( )
177174 } ;
175+ }
176+
177+ public void Dispose ( )
178+ {
179+ _provider ? . Dispose ( ) ;
178180 }
179-
180181 }
181182}
0 commit comments