本文整理汇总了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;
}
示例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;
}