// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System.IO; using System.Text; namespace Microsoft.ClearScript { ///

/// Provides an in-memory implementation for a text document. /// public class StringDocument : Document { /// /// Initializes a new instance. /// /// A structure containing meta-information for the document. /// A string containing the document's contents. public StringDocument(DocumentInfo info, string contents) { Info = info; StringContents = contents; } /// /// Gets the document's contents as a string. /// public string StringContents { get; } #region Document overrides /// /// Gets a structure containing meta-information for the document. /// public override DocumentInfo Info { get; } /// /// Gets a stream that provides read access to the document. /// /// /// The implementation of this property returns a /// instance. /// public override Stream Contents => new MemoryStream(Encoding.GetBytes(StringContents), false); /// /// Gets the document's character encoding. /// /// /// instances return for this property. /// public override Encoding Encoding => Encoding.UTF8; #endregion } }