src/Misc/EFTools/XmlCore/Base/Util/Utils.cs
/// <summary>
///     Converts a string into a stream using a certain encoding, also includes
///     the Encoding preamble at the start of the steam.
/// </summary>
/// <returns>NOTE: Returned Stream should be disposed when done!</returns>
Converts a string into a stream using a certain encoding, also includes
the Encoding preamble at the start of the steam.
Converts a string into a stream using a certain encoding also includes the Encoding preamble at the start of the steam .
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
        private static Stream StringToStream(string inputContents, Encoding encoding)
        {
            var Preamble = encoding.GetPreamble();
            var Body = encoding.GetBytes(inputContents);
            var stream = new MemoryStream(Preamble.Length + Body.Length);
            stream.Write(Preamble, 0, Preamble.Length);
            stream.Write(Body, 0, Body.Length);
            stream.Position = 0;
            return stream;
        }
[ SuppressMessage ( " " , " " ) ] private static Stream StringToStream ( string inputContents , Encoding encoding ) { var Preamble = encoding . GetPreamble ( ) ; var Body = encoding . GetBytes ( inputContents ) ; var stream = new MemoryStream ( Preamble . Length + Body . Length ) ; stream . Write ( Preamble , 0 , Preamble . Length ) ; stream . Write ( Body , 0 , Body . Length ) ; stream . Position = 0 ; return stream ; }
Converts a string into a stream using a certain encoding, also includes
the Encoding preamble at the start of the steam.
Converts a string into a stream using a certain encoding also includes the Encoding preamble at the start of the steam .
// MDF Serialization requires the preamble
Returned Stream should be disposed when done!
Returned Stream should be disposed when done!
inputContents
string
encoding
Encoding