當前位置: 首頁>>代碼示例>>C#>>正文


C# XmlMessageFormatter類代碼示例

本文整理匯總了C#中System.Messaging.XmlMessageFormatter的典型用法代碼示例。如果您正苦於以下問題:C# XmlMessageFormatter類的具體用法?C# XmlMessageFormatter怎麽用?C# XmlMessageFormatter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


XmlMessageFormatter類屬於System.Messaging命名空間,在下文中一共展示了XmlMessageFormatter類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main

//引入命名空間
using System;
using System.Messaging;
 
 public class Server{
 
     public static void Main(){
 
         Console.WriteLine("Processing Orders");
 
         string queuePath = ".\\orders";
         EnsureQueueExists(queuePath);
         MessageQueue queue = new MessageQueue(queuePath);
         ((XmlMessageFormatter)queue.Formatter).TargetTypeNames = new string[]{"Order"};
 
         while(true){
             Order newOrder = (Order)queue.Receive().Body;
             newOrder.ShipItems();
         }
     }
 
     // Creates the queue if it does not already exist.
     public static void EnsureQueueExists(string path){
         if(!MessageQueue.Exists(path)){
             MessageQueue.Create(path);
         }
     }
 }
開發者ID:.NET開發者,項目名稱:System.Messaging,代碼行數:28,代碼來源:XmlMessageFormatter

示例2: ShipItems

//引入命名空間
using System;
 
 public class Order{
 
     public int itemId;
     public int quantity;
     public string address;
 
     public void ShipItems(){
 
         Console.WriteLine("Order Placed:");
         Console.WriteLine("\tItem ID  : {0}",itemId);
         Console.WriteLine("\tQuantity : {0}",quantity);
         Console.WriteLine("\tShip To  : {0}",address);
 
         // Add order to the database.
         /* Insert code here. */
     }
 }
開發者ID:.NET開發者,項目名稱:System.Messaging,代碼行數:20,代碼來源:XmlMessageFormatter

示例3: Main

//引入命名空間
using System;
using System.Messaging;
 
 class Client{
 
     public static void Main(){
 
         string queuePath = ".\\orders";
         EnsureQueueExists(queuePath);
         MessageQueue queue = new MessageQueue(queuePath);
 
         Order orderRequest = new Order();
         orderRequest.itemId = 1025;
         orderRequest.quantity = 5;
         orderRequest.address = "One Microsoft Way";
 
         queue.Send(orderRequest);
         // This line uses a new method you define on the Order class:
         // orderRequest.PrintReceipt();
     }
 
     // Creates the queue if it does not already exist.
     public static void EnsureQueueExists(string path){
         if(!MessageQueue.Exists(path)){
             MessageQueue.Create(path);
         }
     }
 }
開發者ID:.NET開發者,項目名稱:System.Messaging,代碼行數:29,代碼來源:XmlMessageFormatter

示例4: new XmlMessageFormatter

//引入命名空間
using System;
using System.Messaging;

class MainClass
{
  [STAThread]
  static void Main(string[] args)
  {
    MessageQueue txq1 = new MessageQueue( @".\Private$\txq1" );
    MessageQueue txq2 = new MessageQueue( @".\Private$\txq2" );

    using ( MessageQueueTransaction mqtx = new MessageQueueTransaction() )
    {
      mqtx.Begin();
      Message msgIn = txq1.Receive( mqtx );
      msgIn.Formatter = new XmlMessageFormatter( new String[] { "System.String, mscorlib", } );
      Message msgOut = new Message();
      msgOut.Body = (string)msgIn.Body;
      txq2.Send( msgOut, mqtx );
      System.Console.WriteLine( "Aborting message: {0}", (string)msgIn.Body );
      //mqtx.Abort();
      mqtx.Commit();
    }
  }
}
開發者ID:C#程序員,項目名稱:System.Messaging,代碼行數:26,代碼來源:XmlMessageFormatter


注:本文中的System.Messaging.XmlMessageFormatter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。