Select the product you need help with
How to create a custom message formatter by using Visual C#???? ID: 310683 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??. ?? ????? ????????This step-by-step article shows you how to use Visual C# to create a simple custom message formatter. TheSystem.Messagingnamespace provides classes that allow you to connect to message queues, send messages, and receive or peek messages from queues. When you send a message to the queue, objects are serialized by the message formatter into the body of the message. TheSystem.Messagingnamespace includes the following three formatters:
To create a custom message formatter, you must implement theIMessageFormatterinterface, which is included in theSystem.Messaging??? ????? ??? This interface specifies the following three methods:
Class declarationIn this example, the formatter class is calledMyFormatter, and is declared as follows:Write methodThe????method serializes objects into the body of the message when the message is sent to the queue. In this example, the formatter takes in a string and serializes it by using UTF8 encoding. The????method is implemented as follows:Read methodThe????method deserializes the body of the message when you read or peek the message from the queue. Essentially, the????method reverses the process that is done with the?????????? ???CanRead methodTheCanReadmethod attempts to determine whether the formatter can handle the message that is passed to it. For brevity, this formatter assumes that the message body is a string (all messages in the queue were sent using this formatter) and returns True.Clone methodTheClonemethod returns a new instance of the formatter.Use the formatterAfter the formatter is implemented, you can set theFormatter?? ???MessageQueue???????? ?? formatter ?? ?? ?? ??????? ?? ?? ??? ???:??????? ID: 310683 - ????? ???????: 04 ?????? 2010 - ??????: 2.0 ???? ???? ???? ??:
???? ?????? ???????? ??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??. ?????????? ?? ??????? ????????? ??????? ??:310683
(http://support.microsoft.com/kb/310683/en-us/
)
|




????? ?? ???? ????








