IXmlJsonReaderInitializer.SetInput 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將啟用 JavaScript 物件標記法 (JSON) 的讀取器重新初始化為含有 JSON 編碼資料的指定資料流或緩衝區。
多載
SetInput(Stream, Encoding, XmlDictionaryReaderQuotas, OnXmlDictionaryReaderClose) |
將啟用 JavaScript 物件標記法 (JSON) 的讀取器重新初始化為含有 JSON 編碼資料的指定資料流。 |
SetInput(Byte[], Int32, Int32, Encoding, XmlDictionaryReaderQuotas, OnXmlDictionaryReaderClose) |
將啟用 JavaScript 物件標記法 (JSON) 的讀取器重新初始化為含有 JSON 編碼資料的指定緩衝區。 |
備註
其中一個 XmlDictionaryReader 方法建立的 CreateJsonReader 物件會實作此介面,並且隨時可以讀取 JSON 編碼的資料。 不過,若使用者要重複使用相同的 XmlDictionaryReader 物件來讀取其他的 JSON 編碼資料,則必須將讀取器初始化為要使用其中一個 SetInput 方法讀取的第二個資料集。
設定為 MaxBytesPerRead 參數部分的 quotas
值只會限制使用 SetInput(Stream, Encoding, XmlDictionaryReaderQuotas, OnXmlDictionaryReaderClose) 方法從資料流讀取輸入時,讀入記憶體的資訊量;使用 SetInput(Byte[], Int32, Int32, Encoding, XmlDictionaryReaderQuotas, OnXmlDictionaryReaderClose) 方法從緩衝區讀取資訊時並不會採用這個值。 可以載入之屬性數目的限制與 JSON 內容無關。
SetInput(Stream, Encoding, XmlDictionaryReaderQuotas, OnXmlDictionaryReaderClose)
將啟用 JavaScript 物件標記法 (JSON) 的讀取器重新初始化為含有 JSON 編碼資料的指定資料流。
public:
void SetInput(System::IO::Stream ^ stream, System::Text::Encoding ^ encoding, System::Xml::XmlDictionaryReaderQuotas ^ quotas, System::Xml::OnXmlDictionaryReaderClose ^ onClose);
public void SetInput (System.IO.Stream stream, System.Text.Encoding? encoding, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.OnXmlDictionaryReaderClose? onClose);
public void SetInput (System.IO.Stream stream, System.Text.Encoding encoding, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.OnXmlDictionaryReaderClose onClose);
abstract member SetInput : System.IO.Stream * System.Text.Encoding * System.Xml.XmlDictionaryReaderQuotas * System.Xml.OnXmlDictionaryReaderClose -> unit
Public Sub SetInput (stream As Stream, encoding As Encoding, quotas As XmlDictionaryReaderQuotas, onClose As OnXmlDictionaryReaderClose)
參數
- quotas
- XmlDictionaryReaderQuotas
- onClose
- OnXmlDictionaryReaderClose
關閉讀取器時要呼叫的委派。
備註
讀取 JSON 編碼資料流的 XmlDictionaryReader 物件可以藉由呼叫 SetInput(Stream, Encoding, XmlDictionaryReaderQuotas, OnXmlDictionaryReaderClose) 方法來重新初始化,以重複使用此物件。
此讀取器可以解譯 UTF-8 和 UTF-16 (位元組由大到小或由小到大) 編碼。 如果有傳遞編碼集則讀取器會在初始化階段使用編碼集,如果傳遞的是 null
則會自動偵測編碼。
設定為 MaxBytesPerRead 參數部分的 quotas
值只會限制使用 SetInput(Stream, Encoding, XmlDictionaryReaderQuotas, OnXmlDictionaryReaderClose) 方法從資料流讀取輸入時,讀入記憶體的資訊量;使用 SetInput(Byte[], Int32, Int32, Encoding, XmlDictionaryReaderQuotas, OnXmlDictionaryReaderClose) 方法從緩衝區讀取資訊時並不會採用這個值。 可以載入之屬性數目的限制與 JSON 內容無關。
適用於
SetInput(Byte[], Int32, Int32, Encoding, XmlDictionaryReaderQuotas, OnXmlDictionaryReaderClose)
將啟用 JavaScript 物件標記法 (JSON) 的讀取器重新初始化為含有 JSON 編碼資料的指定緩衝區。
public:
void SetInput(cli::array <System::Byte> ^ buffer, int offset, int count, System::Text::Encoding ^ encoding, System::Xml::XmlDictionaryReaderQuotas ^ quotas, System::Xml::OnXmlDictionaryReaderClose ^ onClose);
public void SetInput (byte[] buffer, int offset, int count, System.Text.Encoding? encoding, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.OnXmlDictionaryReaderClose? onClose);
public void SetInput (byte[] buffer, int offset, int count, System.Text.Encoding encoding, System.Xml.XmlDictionaryReaderQuotas quotas, System.Xml.OnXmlDictionaryReaderClose onClose);
abstract member SetInput : byte[] * int * int * System.Text.Encoding * System.Xml.XmlDictionaryReaderQuotas * System.Xml.OnXmlDictionaryReaderClose -> unit
Public Sub SetInput (buffer As Byte(), offset As Integer, count As Integer, encoding As Encoding, quotas As XmlDictionaryReaderQuotas, onClose As OnXmlDictionaryReaderClose)
參數
- offset
- Int32
要在 buffer
中進行讀取的起始位置。
- count
- Int32
可以從 buffer
中讀取的位元組數目。
- quotas
- XmlDictionaryReaderQuotas
- onClose
- OnXmlDictionaryReaderClose
關閉讀取器時要呼叫的 OnXmlDictionaryReaderClose 委派 (Delegate)。
備註
讀取 JSON 編碼緩衝之 XmlDictionaryReader 的 Byte 物件可以藉由呼叫 SetInput(Byte[], Int32, Int32, Encoding, XmlDictionaryReaderQuotas, OnXmlDictionaryReaderClose) 方法來重新初始化,以重複使用此物件。
此讀取器可以解譯 UTF-8 和 UTF-16 (位元組由大到小或由小到大) 編碼。 如果有傳遞編碼集則讀取器會在初始化階段使用編碼集,如果傳遞的是 null
則會自動偵測編碼。
設定為 MaxBytesPerRead 參數部分的 quotas
值只會限制使用 SetInput(Stream, Encoding, XmlDictionaryReaderQuotas, OnXmlDictionaryReaderClose) 方法從資料流讀取輸入時,讀入記憶體的資訊量;使用 SetInput(Byte[], Int32, Int32, Encoding, XmlDictionaryReaderQuotas, OnXmlDictionaryReaderClose) 方法從緩衝區讀取資訊時並不會採用這個值。 可以載入之屬性數目的限制與 JSON 內容無關。