FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ClearScript/ClearScript/StringDocument.cs at master · ddunkin/ClearScript · GitHub
ddunkin
/
ClearScript
Public
forked from
ClearFoundry/ClearScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ClearScript
/
ClearScript
/
StringDocument.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
53 lines (45 loc) · 1.75 KB
Breadcrumbs
ClearScript
/
ClearScript
/
StringDocument.cs
Copy path
File metadata and controls
53 lines (45 loc) · 1.75 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using
System
.
IO
;
using
System
.
Text
;
namespace
Microsoft
.
ClearScript
{
/// <summary>
/// Provides an in-memory <see cref="Document"/> implementation for a text document.
/// </summary>
public
class
StringDocument
:
Document
{
private
readonly
byte
[
]
contents
;
/// <summary>
/// Initializes a new <see cref="StringDocument"/> instance.
/// </summary>
/// <param name="info">A structure containing meta-information for the document.</param>
/// <param name="contents">A string containing the document's contents.</param>
public
StringDocument
(
DocumentInfo
info
,
string
contents
)
{
Info
=
info
;
this
.
contents
=
Encoding
.
UTF8
.
GetBytes
(
contents
)
;
}
#region Document overrides
/// <summary>
/// Gets a structure containing meta-information for the document.
/// </summary>
public
override
DocumentInfo
Info
{
get
;
}
/// <summary>
/// Gets a stream that provides read access to the document.
/// </summary>
/// <remarks>
/// The <see cref="StringDocument"/> implementation of this property returns a
/// <see cref="MemoryStream"/> instance.
/// </remarks>
public
override
Stream
Contents
=>
new
MemoryStream
(
contents
,
false
)
;
/// <summary>
/// Gets the document's character encoding.
/// </summary>
/// <remarks>
/// <see cref="StringDocument"/> instances return <see cref="System.Text.Encoding.UTF8"/> for this property.
/// </remarks>
public
override
Encoding
Encoding
=>
Encoding
.
UTF8
;
#endregion
}
}
Back
|
FazBrowse Home
|
New Git URL