当前位置: 首页>>代码示例>>C#>>正文


C# Message.CopyTo方法代码示例

本文整理汇总了C#中System.Messaging.Message.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# Message.CopyTo方法的具体用法?C# Message.CopyTo怎么用?C# Message.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Messaging.Message的用法示例。


在下文中一共展示了Message.CopyTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PeekMessages

		private Message[] PeekMessages(MessageQueue activeQueue, bool blnDynamicConnection, MessageFormat eMessageFormat, System.Type CustomType)
		{
			Message objMessage;
			Message[] arrCurrentMessages = new Message[0];
			Message[] arrCopyOfMessages = null;
			IMessageFormatter objFormatter = null ;
			MessagePropertyFilter objMessagePropertyFilter = new MessagePropertyFilter();
			int intArrayIndex;

			// Message Formatter
			switch (eMessageFormat)
			{
				case MessageFormat.XMLSerialize:
					if (CustomType == null)
					{
						objFormatter = new XmlMessageFormatter();
					}
					else
					{
					// objFormatter = new XmlMessageFormatter(new Type() [CustomType]);
					}

					break;
				case MessageFormat.ActiveXSerialize:
					objFormatter = new ActiveXMessageFormatter();
					break;
				case MessageFormat.BinarySerialize:
					objFormatter = new BinaryMessageFormatter();
					break;
			}

			// Messages in Private Queue
			// Ensure these properties are received (CorrelationID defaults to False)
			objMessagePropertyFilter.SetDefaults();
			objMessagePropertyFilter.CorrelationId = true;
			objMessagePropertyFilter.AppSpecific = true;
			objMessagePropertyFilter.ArrivedTime = true;
			activeQueue.MessageReadPropertyFilter = objMessagePropertyFilter;

			// Message Formatter
			activeQueue.Formatter = objFormatter;

			// Dynamic Connection whilst gathering messages
			if (blnDynamicConnection == true)
			{
				IEnumerator objMessageEnumerator = activeQueue.GetEnumerator();
				intArrayIndex = 0;
				while (objMessageEnumerator.MoveNext())
				{
					objMessage = (Message) objMessageEnumerator.Current;
					if (intArrayIndex > 0)
					{
						arrCopyOfMessages = new Message[intArrayIndex];
						arrCurrentMessages.CopyTo(arrCopyOfMessages,0);
						arrCurrentMessages=arrCopyOfMessages;
					}
					arrCurrentMessages[intArrayIndex] = objMessage;
					intArrayIndex += 1;
				}
			}
			else // Snapshot of messages currently in Queue
			{
				arrCurrentMessages = null ;
				try
				{
					arrCurrentMessages = activeQueue.GetAllMessages();
				}
				catch (System.Messaging.MessageQueueException excM)
				{
					throw excM;
				}
			}

			return arrCurrentMessages;

		}
开发者ID:bedford603067,项目名称:Augment,代码行数:76,代码来源:QueueAgent.cs

示例2: PeekMessages

        public Message[] PeekMessages(MessageQueue activeQueue, bool blnDynamicConnection, eMessageFormat messageFormat, System.Type customType)
        {
            Message objMessage;
            Message[] arrCurrentMessages = new Message[0];
            Message[] arrCopyOfMessages = null;
            MessagePropertyFilter objMessagePropertyFilter = new MessagePropertyFilter();
            int intArrayIndex;

            // Message Formatter
            SetQueueFormatterAndProperties(activeQueue, messageFormat, customType);

            // Dynamic Connection whilst gathering messages
            if (blnDynamicConnection == true)
            {
                IEnumerator objMessageEnumerator = activeQueue.GetMessageEnumerator2();
                intArrayIndex = 0;
                while (objMessageEnumerator.MoveNext())
                {
                    objMessage = (Message)objMessageEnumerator.Current;
                    if (intArrayIndex > 0)
                    {
                        arrCopyOfMessages = new Message[intArrayIndex];
                        arrCurrentMessages.CopyTo(arrCopyOfMessages, 0);
                        arrCurrentMessages = arrCopyOfMessages;
                    }
                    arrCurrentMessages[intArrayIndex] = objMessage;
                    intArrayIndex += 1;
                }
            }
            else // Snapshot of messages currently in Queue
            {
                arrCurrentMessages = null;
                try
                {
                    arrCurrentMessages = activeQueue.GetAllMessages();
                }
                catch (System.Messaging.MessageQueueException excM)
                {
                    throw excM;
                }
            }

            return arrCurrentMessages;

        }
开发者ID:bedford603067,项目名称:Augment,代码行数:45,代码来源:QueueListener.cs


注:本文中的System.Messaging.Message.CopyTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。