本文整理匯總了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