XmlMessageFormatter.CanRead(Message) 方法

定義

決定格式子是否能夠還原序列化訊息。Determines whether the formatter can deserialize the message.

public:
 virtual bool CanRead(System::Messaging::Message ^ message);
public bool CanRead (System.Messaging.Message message);
abstract member CanRead : System.Messaging.Message -> bool
override this.CanRead : System.Messaging.Message -> bool
Public Function CanRead (message As Message) As Boolean

參數

message
Message

要檢查的 MessageThe Message to inspect.

傳回

Boolean

如果 XML 格式子能夠還原序列化訊息,則為 true,否則為 falsetrue if the XML formatter can deserialize the message; otherwise, false.

實作

例外狀況

TargetTypeNamesTargetTypes 屬性都沒有設定。Neither the TargetTypeNames nor TargetTypes property has been set.

message 參數為 nullThe message parameter is null.

備註

CanRead 呼叫時,格式器會嘗試判斷訊息的內容是否為它可以還原序列化的東西。When CanRead is called, the formatter attempts to determine if the contents of the message are something it can deserialize. 如果訊息本文中的型別具有與和屬性所表示之陣列中的其中一個類型相同的架構,則格式器只能還原序列化訊息 TargetTypeNames TargetTypesThe formatter can only deserialize the message if the type in the message body has the same schema as one of the types in the array represented by the TargetTypeNames and TargetTypes properties. CanReadfalse 在下列兩種情況下傳回:CanRead returns false under the following two circumstances:

TargetTypeNamesTargetTypes 屬性會告知格式器必須能夠還原序列化的物件類型。The TargetTypeNames and TargetTypes properties tell the formatter what types of objects it must be able to deserialize. 如果清單中遺漏任何類型,但在訊息中找到,則會傳回 CanRead falseIf any type is missing from the list, yet is found within the message, CanRead returns false.

適用於

另請參閱