本文整理汇总了C#中System.Messaging.Message.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Message.GetType方法的具体用法?C# Message.GetType怎么用?C# Message.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Messaging.Message
的用法示例。
在下文中一共展示了Message.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckInvalidOperation
private static void CheckInvalidOperation (Message m, String property)
{
PropertyInfo pi = m.GetType ().GetProperty (property);
try {
Assert.IsNotNull (pi, "Property not defined: " + property);
object o = pi.GetValue (m, null);
Assert.Fail (property + ": " + o);
} catch (InvalidOperationException) {
} catch (TargetInvocationException e) {
Assert.AreEqual (typeof (InvalidOperationException),
e.InnerException.GetType ());
}
}
示例2: CheckArgumentInvalid
private static void CheckArgumentInvalid(Message m, String property, Type exceptionType)
{
PropertyInfo pi = m.GetType().GetProperty(property);
try {
Assert.IsNotNull(pi, "Property not defined: " + property);
pi.SetValue(m, null, null);
Assert.Fail(property);
} catch (InvalidOperationException) {
} catch (TargetInvocationException e) {
Assert.AreEqual(exceptionType,
e.InnerException.GetType(),
property);
}
}
示例3: ProcessContextProperties
private static void ProcessContextProperties(Context context, XmlNodeList props, Message msg)
{
foreach( XmlNode prop in props )
{
// <ContextProperty MSMQProp="CorrelationId" CtxPropName="MSMQ_CorrelationId" />
string ctxPropName = prop.SelectSingleNode("@CtxPropName").Value;
string msmqPropName = prop.SelectSingleNode("@MSMQProp").Value;
PropertyInfo pi = msg.GetType().GetProperty(msmqPropName);
object val;
try
{
val = pi.GetValue(msg, null);
}
catch(Exception)
{
context.LogInfo("The property: \"{0}\" did not have a value set", msmqPropName );
continue;
}
context.LogInfo("Property: \"{0}\", Value: \"{1}\" written to context", msmqPropName, val );
context.Add( ctxPropName, val );
}
}