SourceText.From 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
From(String, Encoding, SourceHashAlgorithm)
SourceText從字串中的文字建構 。
public static Microsoft.CodeAnalysis.Text.SourceText From (string text, System.Text.Encoding encoding = default, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1);
public static Microsoft.CodeAnalysis.Text.SourceText From (string text, System.Text.Encoding? encoding = default, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1);
static member From : string * System.Text.Encoding * Microsoft.CodeAnalysis.Text.SourceHashAlgorithm -> Microsoft.CodeAnalysis.Text.SourceText
Public Shared Function From (text As String, Optional encoding As Encoding = Nothing, Optional checksumAlgorithm As SourceHashAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1) As SourceText
參數
- text
- String
Text。
- encoding
- Encoding
讀取或將要儲存之檔案 text
的編碼方式。
null
如果未指定編碼,則為 。
如果未指定編碼方式,則結果 SourceText 無法偵錯。
如果將無 SourceText 編碼寫入檔案, UTF8 則應該使用 做為預設值。
- checksumAlgorithm
- SourceHashAlgorithm
用來計算儲存至 PDB 之文字總和檢查碼的雜湊演算法。
傳回
例外狀況
text
為 null。
不支援 checksumAlgorithm
。
適用於
From(Stream, Encoding, SourceHashAlgorithm, Boolean)
public:
static Microsoft::CodeAnalysis::Text::SourceText ^ From(System::IO::Stream ^ stream, System::Text::Encoding ^ encoding, Microsoft::CodeAnalysis::Text::SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected);
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public static Microsoft.CodeAnalysis.Text.SourceText From (System.IO.Stream stream, System.Text.Encoding encoding, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected);
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public static Microsoft.CodeAnalysis.Text.SourceText From (System.IO.Stream stream, System.Text.Encoding? encoding, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected);
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
static member From : System.IO.Stream * System.Text.Encoding * Microsoft.CodeAnalysis.Text.SourceHashAlgorithm * bool -> Microsoft.CodeAnalysis.Text.SourceText
Public Shared Function From (stream As Stream, encoding As Encoding, checksumAlgorithm As SourceHashAlgorithm, throwIfBinaryDetected As Boolean) As SourceText
參數
- stream
- Stream
- encoding
- Encoding
- checksumAlgorithm
- SourceHashAlgorithm
- throwIfBinaryDetected
- Boolean
傳回
- 屬性
適用於
From(TextReader, Int32, Encoding, SourceHashAlgorithm)
SourceText從字串中的文字建構 。
public static Microsoft.CodeAnalysis.Text.SourceText From (System.IO.TextReader reader, int length, System.Text.Encoding encoding = default, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1);
public static Microsoft.CodeAnalysis.Text.SourceText From (System.IO.TextReader reader, int length, System.Text.Encoding? encoding = default, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1);
static member From : System.IO.TextReader * int * System.Text.Encoding * Microsoft.CodeAnalysis.Text.SourceHashAlgorithm -> Microsoft.CodeAnalysis.Text.SourceText
Public Shared Function From (reader As TextReader, length As Integer, Optional encoding As Encoding = Nothing, Optional checksumAlgorithm As SourceHashAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1) As SourceText
參數
- reader
- TextReader
TextReader
- length
- Int32
內容的長度 reader
- encoding
- Encoding
讀取或將要儲存之檔案 reader
的編碼方式。
null
如果未指定編碼,則為 。
如果未指定編碼方式,則結果 SourceText 無法偵錯。
如果將無 SourceText 編碼寫入檔案, UTF8 則應該使用 做為預設值。
- checksumAlgorithm
- SourceHashAlgorithm
用來計算儲存至 PDB 之文字總和檢查碼的雜湊演算法。
傳回
例外狀況
reader
為 null。
不支援 checksumAlgorithm
。
適用於
From(Byte[], Int32, Encoding, SourceHashAlgorithm, Boolean)
public:
static Microsoft::CodeAnalysis::Text::SourceText ^ From(cli::array <System::Byte> ^ buffer, int length, System::Text::Encoding ^ encoding, Microsoft::CodeAnalysis::Text::SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected);
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public static Microsoft.CodeAnalysis.Text.SourceText From (byte[] buffer, int length, System.Text.Encoding encoding, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected);
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public static Microsoft.CodeAnalysis.Text.SourceText From (byte[] buffer, int length, System.Text.Encoding? encoding, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected);
[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]
static member From : byte[] * int * System.Text.Encoding * Microsoft.CodeAnalysis.Text.SourceHashAlgorithm * bool -> Microsoft.CodeAnalysis.Text.SourceText
Public Shared Function From (buffer As Byte(), length As Integer, encoding As Encoding, checksumAlgorithm As SourceHashAlgorithm, throwIfBinaryDetected As Boolean) As SourceText
參數
- buffer
- Byte[]
- length
- Int32
- encoding
- Encoding
- checksumAlgorithm
- SourceHashAlgorithm
- throwIfBinaryDetected
- Boolean
傳回
- 屬性
適用於
From(Stream, Encoding, SourceHashAlgorithm, Boolean, Boolean)
SourceText從資料流程內容建構 。
public static Microsoft.CodeAnalysis.Text.SourceText From (System.IO.Stream stream, System.Text.Encoding encoding = default, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1, bool throwIfBinaryDetected = false, bool canBeEmbedded = false);
public static Microsoft.CodeAnalysis.Text.SourceText From (System.IO.Stream stream, System.Text.Encoding? encoding = default, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1, bool throwIfBinaryDetected = false, bool canBeEmbedded = false);
static member From : System.IO.Stream * System.Text.Encoding * Microsoft.CodeAnalysis.Text.SourceHashAlgorithm * bool * bool -> Microsoft.CodeAnalysis.Text.SourceText
Public Shared Function From (stream As Stream, Optional encoding As Encoding = Nothing, Optional checksumAlgorithm As SourceHashAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1, Optional throwIfBinaryDetected As Boolean = false, Optional canBeEmbedded As Boolean = false) As SourceText
參數
- stream
- Stream
資料流。 資料流程必須是可搜尋的。
- checksumAlgorithm
- SourceHashAlgorithm
用來計算儲存至 PDB 之文字總和檢查碼的雜湊演算法。
- throwIfBinaryDetected
- Boolean
如果解碼的文字至少包含兩個連續 NUL 字元,則會 InvalidDataException 擲回 。
- canBeEmbedded
- Boolean
True 是表示 如果文字可以傳遞至 FromSource(String, SourceText) PDB 並內嵌在 PDB 中。
傳回
例外狀況
stream
為 null。
stream
不支援讀取或搜尋。
不支援 checksumAlgorithm
。
如果指定的編碼設定為使用擲回解碼器做為後援
在解碼的文字中偵測到兩個連續 NUL 字元,且 throwIfBinaryDetected
為 true。
發生 I/O 錯誤。
備註
從資料流程開頭讀取。 讓資料流程保持開啟狀態。
適用於
From(Byte[], Int32, Encoding, SourceHashAlgorithm, Boolean, Boolean)
SourceText從位元組陣列建構 。
public static Microsoft.CodeAnalysis.Text.SourceText From (byte[] buffer, int length, System.Text.Encoding encoding = default, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1, bool throwIfBinaryDetected = false, bool canBeEmbedded = false);
public static Microsoft.CodeAnalysis.Text.SourceText From (byte[] buffer, int length, System.Text.Encoding? encoding = default, Microsoft.CodeAnalysis.Text.SourceHashAlgorithm checksumAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1, bool throwIfBinaryDetected = false, bool canBeEmbedded = false);
static member From : byte[] * int * System.Text.Encoding * Microsoft.CodeAnalysis.Text.SourceHashAlgorithm * bool * bool -> Microsoft.CodeAnalysis.Text.SourceText
Public Shared Function From (buffer As Byte(), length As Integer, Optional encoding As Encoding = Nothing, Optional checksumAlgorithm As SourceHashAlgorithm = Microsoft.CodeAnalysis.Text.SourceHashAlgorithm.Sha1, Optional throwIfBinaryDetected As Boolean = false, Optional canBeEmbedded As Boolean = false) As SourceText
參數
- buffer
- Byte[]
編碼的來源緩衝區。
- length
- Int32
要從緩衝區讀取的位元組數目。
- checksumAlgorithm
- SourceHashAlgorithm
用來計算儲存至 PDB 之文字總和檢查碼的雜湊演算法。
- throwIfBinaryDetected
- Boolean
如果解碼的文字至少包含兩個連續 NUL 字元,則會 InvalidDataException 擲回 。
- canBeEmbedded
- Boolean
True 是表示 如果文字可以傳遞至 FromSource(String, SourceText) PDB 並內嵌在 PDB 中。
傳回
解碼的文字。
例外狀況
buffer
為 Null。
length
為負數或大於 buffer
。
不支援 checksumAlgorithm
。
如果指定的編碼設定為使用擲回解碼器做為後援
在解碼的文字中偵測到兩個連續 NUL 字元,且 throwIfBinaryDetected
為 true。