本文整理汇总了VB.NET中System.Messaging.MessageQueue.MessageReadPropertyFilter属性的典型用法代码示例。如果您正苦于以下问题:VB.NET MessageQueue.MessageReadPropertyFilter属性的具体用法?VB.NET MessageQueue.MessageReadPropertyFilter怎么用?VB.NET MessageQueue.MessageReadPropertyFilter使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Messaging.MessageQueue
的用法示例。
在下文中一共展示了MessageQueue.MessageReadPropertyFilter属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: MyNewQueue
' 导入命名空间
Imports System.Messaging
Public Class MyNewQueue
' Provides an entry point into the application.
'
' This example retrieves specific groups of Message
' properties.
Public Shared Sub Main()
' Create a new instance of the class.
Dim myNewQueue As New MyNewQueue()
' Retrieve specific sets of Message properties.
myNewQueue.RetrieveDefaultProperties()
myNewQueue.RetrieveAllProperties()
myNewQueue.RetrieveSelectedProperties()
Return
End Sub
' Retrieves the default properties for a Message.
Public Sub RetrieveDefaultProperties()
' Connect to a message queue.
Dim myQueue As New MessageQueue(".\myQueue")
' Specify to retrieve the default properties only.
myQueue.MessageReadPropertyFilter.SetDefaults()
' Set the formatter for the Message.
myQueue.Formatter = New XmlMessageFormatter(New Type() _
{GetType([String])})
' Receive the first message in the queue.
Dim myMessage As Message = myQueue.Receive()
' Display selected properties.
Console.WriteLine(("Label: " + myMessage.Label))
Console.WriteLine(("Body: " + CType(myMessage.Body, _
[String])))
Return
End Sub
' Retrieves all properties for a Message.
Public Sub RetrieveAllProperties()
' Connect to a message queue.
Dim myQueue As New MessageQueue(".\myQueue")
' Specify to retrieve all properties.
myQueue.MessageReadPropertyFilter.SetAll()
' Set the formatter for the Message.
myQueue.Formatter = New XmlMessageFormatter(New Type() _
{GetType([String])})
' Receive the first message in the queue.
Dim myMessage As Message = myQueue.Receive()
' Display selected properties.
Console.WriteLine(("Encryption algorithm: " + _
myMessage.EncryptionAlgorithm.ToString()))
Console.WriteLine(("Body: " + CType(myMessage.Body, _
[String])))
Return
End Sub
' Retrieves application-specific properties for a
' Message.
Public Sub RetrieveSelectedProperties()
' Connect to a message queue.
Dim myQueue As New MessageQueue(".\myQueue")
' Specify to retrieve selected properties.
Dim myFilter As New MessagePropertyFilter()
myFilter.ClearAll()
' The following list is a random subset of properties.
myFilter.Body = True
myFilter.Label = True
myFilter.MessageType = True
myFilter.Priority = True
myQueue.MessageReadPropertyFilter = myFilter
' Set the formatter for the Message.
myQueue.Formatter = New XmlMessageFormatter(New Type() _
{GetType([String])})
' Receive the first message in the queue.
Dim myMessage As Message = myQueue.Receive()
' Display selected properties.
Console.WriteLine(("Message type: " + _
myMessage.MessageType.ToString()))
Console.WriteLine(("Priority: " + _
myMessage.Priority.ToString()))
Return
End Sub
End Class