PreserializedResourceWriter.AddResource 方法

定義

多載

AddResource(String, Byte[])

將位元組陣列作為具名資源,新增至要寫入檔案的資源清單。Adds a byte array as a named resource to the list of resources to be written to a file.

AddResource(String, Object)

將物件作為具名資源新增至要寫入檔案的資源清單。Adds an object as a named resource to the list of resources to be written to a file.

AddResource(String, String)

將字串作為具名資源新增至要寫入檔案的資源清單。Adds a string as a named resource to the list of resources to be written to a file.

AddResource(String, Stream, Boolean)

Stream 作為具名資源新增至要寫入檔案的資源清單。Adds a Stream as a named resource to the list of resources to be written to a file.

AddResource(String, String, String)

新增指定類型的資源,由字串值表示。Adds a resource of the specified type represented by a string value.

AddResource(String, Byte[])

將位元組陣列作為具名資源,新增至要寫入檔案的資源清單。Adds a byte array as a named resource to the list of resources to be written to a file.

public:
 virtual void AddResource(System::String ^ name, cli::array <System::Byte> ^ value);
public void AddResource (string name, byte[] value);
abstract member AddResource : string * byte[] -> unit
override this.AddResource : string * byte[] -> unit
Public Sub AddResource (name As String, value As Byte())

參數

name
String

資源名稱。The resource name.

value
Byte[]

要新增為資源的位元組陣列。The byte array to add as a resource.

例外狀況

名稱為 nullThe name is null.

資源清單為 nullThe resource list is null.

備註

在呼叫 Generate() 之前,不會寫入資源。The resources are not written until Generate() is called.

AddResource(String, Object)

將物件作為具名資源新增至要寫入檔案的資源清單。Adds an object as a named resource to the list of resources to be written to a file.

public:
 virtual void AddResource(System::String ^ name, System::Object ^ value);
public void AddResource (string name, object value);
abstract member AddResource : string * obj -> unit
override this.AddResource : string * obj -> unit
Public Sub AddResource (name As String, value As Object)

參數

name
String

資源名稱。The resource name.

value
Object

要新增為資源的物件。The object to add as a resource.

例外狀況

名稱為 nullThe name is null.

資源清單為 nullThe resource list is null.

資料流為不可搜尋。The stream is unseekable.

備註

在呼叫 Generate() 之前,不會寫入資源。The resources are not written until Generate() is called.

AddResource(String, String)

將字串作為具名資源新增至要寫入檔案的資源清單。Adds a string as a named resource to the list of resources to be written to a file.

public:
 virtual void AddResource(System::String ^ name, System::String ^ value);
public void AddResource (string name, string value);
abstract member AddResource : string * string -> unit
override this.AddResource : string * string -> unit
Public Sub AddResource (name As String, value As String)

參數

name
String

資源名稱。The resource name.

value
String

要新增為資源的字串。The string to add as a resource.

例外狀況

名稱為 nullThe name is null.

資源清單為 nullThe resource list is null.

備註

在呼叫 Generate() 之前,不會寫入資源。The resources are not written until Generate() is called.

AddResource(String, Stream, Boolean)

Stream 作為具名資源新增至要寫入檔案的資源清單。Adds a Stream as a named resource to the list of resources to be written to a file.

public void AddResource (string name, System.IO.Stream value, bool closeAfterWrite = false);
member this.AddResource : string * System.IO.Stream * bool -> unit
Public Sub AddResource (name As String, value As Stream, Optional closeAfterWrite As Boolean = false)

參數

name
String

資源名稱。The resource name.

value
Stream

要新增為資源的資料流。The stream to add as a resource.

closeAfterWrite
Boolean

選用值,指出資料流在寫入資源之後是否應關閉 (true) 或保持開啟 (false,預設值)。An optional value that indicates whether, after resources have been written, the stream should be closed (true) or left open (false, the default value).

備註

在呼叫 Generate() 之前,不會寫入資源。The resources are not written until Generate() is called.

AddResource(String, String, String)

新增指定類型的資源,由字串值表示。Adds a resource of the specified type represented by a string value.

public:
 void AddResource(System::String ^ name, System::String ^ value, System::String ^ typeName);
public void AddResource (string name, string value, string typeName);
member this.AddResource : string * string * string -> unit
Public Sub AddResource (name As String, value As String, typeName As String)

參數

name
String

資源名稱。The resource name.

value
String

字串形式中的資源值,由類型的 TypeConverter 所了解。The value of the resource in string form understood by the type's TypeConverter.

typeName
String

資源的組件限定類型名稱。The assembly qualified type name of the resource.

備註

如果類型是基本型別,則會使用寫入器 TypeConverter 將值轉換成該基本類型,並以二進位格式儲存在資源中。If the type is a primitive type, the value will be converted using TypeConverter by the writer to that primitive type and stored in the resources in binary format. 如果類型不是基本型別,則字串值將會以字串的形式儲存在資源中,並在讀取資源時以類型的 TypeConverter 進行轉換。If the type is not a primitive type, the string value will be stored in the resources as a string and converted with a TypeConverter for the type when reading the resource. 這種轉換的目的是為了避免在資源寫入期間啟用任意類型。This conversion is done to avoid activating arbitrary types during resource writing.

適用於