Message.BodyType 属性
定义
获取或设置消息正文所包含数据的类型。Gets or sets the type of data that the message body contains.
public:
property int BodyType { int get(); void set(int value); };
[System.Messaging.MessagingDescription("MsgBodyType")]
public int BodyType { get; set; }
[<System.Messaging.MessagingDescription("MsgBodyType")>]
member this.BodyType : int with get, set
Public Property BodyType As Integer
属性值
消息体的真实类型,如字符串、日期、货币或数字。The message body's true type, such as a string, a date, a currency, or a number.
- 属性
例外
示例
下面的代码示例显示消息的属性的值 BodyType 。The following code example displays the value of a message's BodyType property.
注解
消息队列将正文内容识别为对象或序列化流。Message Queuing recognizes the body contents as an object or as a serialized stream. BodyType属性指示消息的属性中的对象的类型 Body 。The BodyType property indicates the type of the object within the Body property of the message.
在 XmlMessageFormatter 本机类型与消息体中的对象之间执行绑定。The XmlMessageFormatter performs binding between native types and the object in a message body. 如果使用,则 XmlMessageFormatter 格式化程序将 BodyType 为您设置属性。If you use the XmlMessageFormatter, the formatter sets the BodyType property for you.
其他格式化程序还可以提供绑定功能,如下面的 c # 代码中所示。Other formatters can provide binding functionality also, as shown in the following C# code.
message.Formatter = new ActiveXMessageFormatter();
object myObject message.Body;
if (myObject is string) {
}
if (myObject is int) {
}
if (myObject is float) {
}