Beispiel #1
0
        protected virtual string GenerateServiceName(string originalServiceName, MethodInfo method, Type attributeType)
        {
            var name = MessagingAttributeUtils.EndpointIdValue(method);

            if (string.IsNullOrEmpty(name))
            {
                name = originalServiceName + "." + method.Name + "." + attributeType.Name + "." + Guid.NewGuid().ToString();
            }

            return(name);
        }
Beispiel #2
0
        protected virtual string GenerateHandlerServiceName(string originalServiceName, MethodInfo method)
        {
            var name = MessagingAttributeUtils.EndpointIdValue(method);

            if (string.IsNullOrEmpty(name))
            {
                if (originalServiceName == null)
                {
                    originalServiceName = method.DeclaringType.Name;
                }

                var baseName = originalServiceName + "." + method.Name + "." + AnnotationType.Name;
                name = baseName;
                var count = 1;
                while (ApplicationContext.ContainsService(name))
                {
                    name = baseName + "#" + (++count);
                }
            }

            return(name + ".handler");
        }
Beispiel #3
0
        public object PostProcess(object service, string serviceName, MethodInfo method, List <Attribute> attributes)
        {
            GetSourceHandlerFromContext(method, out var sourceHandler, out var skipEndpointCreation);

            if (skipEndpointCreation)
            {
                return(null);
            }

            var handler = GetHandler(service, method, attributes);

            if (handler != sourceHandler)
            {
                var handlerServiceName = GenerateHandlerServiceName(serviceName, method);
                if (handler is ReplyProducingMessageHandlerWrapper && !string.IsNullOrEmpty(MessagingAttributeUtils.EndpointIdValue(method)))
                {
                    handlerServiceName += ".wrapper";
                }

                ApplicationContext.Register(handlerServiceName, handler);
                handler = (IMessageHandler)ApplicationContext.GetService(handlerServiceName);
            }

            var endpoint = CreateEndpoint(handler, method, attributes);

            if (endpoint != null)
            {
                return(endpoint);
            }
            else
            {
                return(handler);
            }
        }