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


C# Conventions.IsMessageType方法代码示例

本文整理汇总了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);
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:18,代码来源:MessageConventionSpecs.cs

示例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;
        }
开发者ID:ogdenmd,项目名称:NServiceBus,代码行数:22,代码来源:WcfManager.cs

示例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)));
 }
开发者ID:Particular,项目名称:NServiceBus,代码行数:5,代码来源:ConventionsTests.cs

示例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)));
 }
开发者ID:Particular,项目名称:NServiceBus,代码行数:8,代码来源:ConventionsTests.cs

示例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)));
 }
开发者ID:Particular,项目名称:NServiceBus,代码行数:6,代码来源:ConventionsTests.cs

示例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)));
 }
开发者ID:Particular,项目名称:NServiceBus,代码行数:5,代码来源:ConventionsTests.cs

示例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)));
 }
开发者ID:Particular,项目名称:NServiceBus,代码行数:9,代码来源:ConventionsTests.cs

示例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);
         }
     }
 }
开发者ID:ogdenmd,项目名称:NServiceBus,代码行数:22,代码来源:Sagas.cs

示例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;
            }
        }
开发者ID:ogdenmd,项目名称:NServiceBus,代码行数:56,代码来源:Sagas.cs

示例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;
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:27,代码来源:MessageEndpointMappingCollection.cs

示例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());
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:24,代码来源:MessageEndpointMappingCollection.cs


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