本文整理汇总了C#中Conventions.IsMessageType方法的典型用法代码示例。如果您正苦于以下问题:C# Conventions.IsMessageType方法的具体用法?C# Conventions.IsMessageType怎么用?C# Conventions.IsMessageType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Conventions
的用法示例。
在下文中一共展示了Conventions.IsMessageType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_cache_the_message_convention
public void Should_cache_the_message_convention()
{
var timesCalled = 0;
conventions = new Conventions
{
IsMessageTypeAction = t =>
{
timesCalled++;
return false;
}
};
conventions.IsMessageType(GetType());
Assert.AreEqual(1, timesCalled);
conventions.IsMessageType(GetType());
Assert.AreEqual(1, timesCalled);
}
示例2: IsWcfService
static bool IsWcfService(Type t, Conventions conventions)
{
var args = t.GetGenericArguments();
if (args.Length == 2)
{
if (conventions.IsMessageType(args[0]))
{
var wcfType = typeof(WcfService<,>).MakeGenericType(args[0], args[1]);
if (wcfType.IsAssignableFrom(t))
{
return true;
}
}
}
if (t.BaseType != null)
{
return IsWcfService(t.BaseType, conventions) && !t.IsAbstract;
}
return false;
}
示例3: IsMessageType_should_return_false_for_unknown_type
public void IsMessageType_should_return_false_for_unknown_type()
{
var conventions = new Conventions();
Assert.IsFalse(conventions.IsMessageType(typeof(NoAMessage)));
}
示例4: IsMessageType_should_return_false_for_NServiceBus_types
public void IsMessageType_should_return_false_for_NServiceBus_types()
{
var conventions = new Conventions
{
IsMessageTypeAction = t => t.Assembly == typeof(Conventions).Assembly
};
Assert.IsFalse(conventions.IsMessageType(typeof(Conventions)));
}
示例5: IsMessageType_should_return_true_for_systemMessage
public void IsMessageType_should_return_true_for_systemMessage()
{
var conventions = new Conventions();
conventions.AddSystemMessagesConventions(type => type == typeof(MySystemMessage));
Assert.IsTrue(conventions.IsMessageType(typeof(MySystemMessage)));
}
示例6: IsMessageType_should_return_true_for_IEvent
public void IsMessageType_should_return_true_for_IEvent()
{
var conventions = new Conventions();
Assert.IsTrue(conventions.IsMessageType(typeof(MyEvent)));
}
示例7: IsMessageType_should_return_true_for_matching_type
public void IsMessageType_should_return_true_for_matching_type()
{
var conventions = new Conventions
{
IsMessageTypeAction = t => t.Assembly == typeof(Conventions).Assembly ||
t == typeof(MyConventionMessage)
};
Assert.IsTrue(conventions.IsMessageType(typeof(MyConventionMessage)));
}
示例8: GetMessagesCorrespondingToFilterOnSaga
static IEnumerable<Type> GetMessagesCorrespondingToFilterOnSaga(Type sagaType, Type filter, Conventions conventions)
{
foreach (var interfaceType in sagaType.GetInterfaces())
{
foreach (var argument in interfaceType.GetGenericArguments())
{
var genericType = filter.MakeGenericType(argument);
var isOfFilterType = genericType == interfaceType;
if (!isOfFilterType)
{
continue;
}
if (conventions.IsMessageType(argument))
{
yield return argument;
continue;
}
var message = string.Format("The saga '{0}' implements '{1}' but the message type '{2}' is not classified as a message. You should either use 'Unobtrusive Mode Messages' or the message should implement either 'IMessage', 'IEvent' or 'ICommand'.", sagaType.FullName, genericType.Name, argument.FullName);
throw new Exception(message);
}
}
}
示例9: ConfigureFinder
// Made internal for testing purposes
internal void ConfigureFinder(Type t, Conventions conventions)
{
foreach (var interfaceType in t.GetInterfaces())
{
var args = interfaceType.GetGenericArguments();
if (args.Length != 2)
{
continue;
}
Type sagaEntityType = null;
Type messageType = null;
foreach (var type in args)
{
if (typeof(IContainSagaData).IsAssignableFrom(type))
{
sagaEntityType = type;
}
if (conventions.IsMessageType(type) || type == typeof(object))
{
messageType = type;
}
}
if (sagaEntityType == null || messageType == null)
{
continue;
}
var finderType = typeof(IFindSagas<>.Using<>).MakeGenericType(sagaEntityType, messageType);
if (!finderType.IsAssignableFrom(t))
{
continue;
}
finderTypeToSagaEntityTypeLookup[t] = sagaEntityType;
var method = t.GetMethod("FindBy", new[]
{
messageType
});
Dictionary<Type, MethodInfo> methods;
sagaConfigurationCache.FinderTypeToMessageToMethodInfoLookup.TryGetValue(t, out methods);
if (methods == null)
{
methods = new Dictionary<Type, MethodInfo>();
sagaConfigurationCache.FinderTypeToMessageToMethodInfoLookup[t] = methods;
}
methods[messageType] = method;
}
}
示例10: GetBaseTypes
static List<Type> GetBaseTypes(Type messageType, Conventions conventions)
{
var result = new List<Type>();
var baseType = messageType.BaseType;
while (baseType != typeof(object) && baseType != null)
{
if (conventions.IsMessageType(baseType))
{
if (!result.Contains(baseType))
{
result.Add(baseType);
}
}
baseType = baseType.BaseType;
}
foreach (var i in messageType.GetInterfaces())
{
if (conventions.IsMessageType(i) && !result.Contains(i))
{
result.Add(i);
}
}
return result;
}
示例11: Apply
internal void Apply(Publishers publishers, UnicastRoutingTable unicastRoutingTable, Func<string, string> makeCanonicalAddress, Conventions conventions)
{
var routeTableEntries = new Dictionary<Type, RouteTableEntry>();
var publisherTableEntries = new List<PublisherTableEntry>();
foreach (var m in this.Cast<MessageEndpointMapping>().OrderByDescending(m => m))
{
m.Configure((type, endpointAddress) =>
{
if (!conventions.IsMessageType(type))
{
return;
}
var canonicalForm = makeCanonicalAddress(endpointAddress);
var baseTypes = GetBaseTypes(type, conventions);
RegisterMessageRoute(type, canonicalForm, routeTableEntries, baseTypes);
RegisterEventRoute(type, canonicalForm, publisherTableEntries, baseTypes);
});
}
publishers.AddOrReplacePublishers("MessageEndpointMappings", publisherTableEntries);
unicastRoutingTable.AddOrReplaceRoutes("MessageEndpointMappings", routeTableEntries.Values.ToList());
}