Beispiel #1
0
        protected override MethodDispatcherBuildResult BuildMethodDispatcher(Type interfaceType)
        {
            var servicenterfaceDescription = ServiceInterfaceDescription.CreateUsingCRCId(interfaceType, true);
            var res = this.BuildMethodDispatcherResult(servicenterfaceDescription);

            return(res);
        }
Beispiel #2
0
        private MethodDispatcherBuildResult BuildMethodDispatcherResult(ServiceInterfaceDescription servicenterfaceDescription)
        {
            var res = this.methodDispatcherBuilder.Build(servicenterfaceDescription);

            InterfaceDetailsStore.UpdateKnownTypeDetail(servicenterfaceDescription);
            return(res);
        }
Beispiel #3
0
        private void InitializeServiceMethodInfo()
        {
            this.serviceMethodCounterInstanceData = new Dictionary <long, CounterInstanceData>();
            var methodInfoList = new List <KeyValuePair <long, MethodInfo> >();

            foreach (var serviceInterfaceType in this.serviceTypeInformation.InterfaceTypes)
            {
                var interfaceDescription = ServiceInterfaceDescription.Create(serviceInterfaceType
                                                                              );
                foreach (var methodDescription in interfaceDescription.Methods)
                {
                    var kvp = new KeyValuePair <long, MethodInfo>(
                        GetInterfaceMethodKey(interfaceDescription.Id, methodDescription.Id),
                        methodDescription.MethodInfo);
                    methodInfoList.Add(kvp);
                }
            }

            // Compute the counter instance names for all the actor methods
            var percCounterInstanceNameBuilder = new PerformanceCounterInstanceNameBuilder(this.partitionId,
                                                                                           this.counterInstanceDifferentiator);
            var counterInstanceNames = percCounterInstanceNameBuilder.GetMethodCounterInstanceNames(methodInfoList);

            foreach (var kvp in counterInstanceNames)
            {
                this.serviceMethodCounterInstanceData[kvp.Key] = new CounterInstanceData {
                    InstanceName = kvp.Value
                };
                this.serviceMethodCounterInstanceData[kvp.Key].CounterWriters =
                    this.InitializeMethodCounterInstanceData(kvp.Value);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Instantiates the ServiceRemotingDispatcher that uses the given service context and
        /// dispatches messages to the given service implementation.
        /// </summary>
        /// <param name="serviceContext">Service context</param>
        /// <param name="service">Service implementation that implements interfaces of type <see cref="IService"/></param>
        public ServiceRemotingDispatcher(ServiceContext serviceContext, IService service)
        {
            Requires.ThrowIfNull(serviceContext, "serviceContext");

            this.cancellationHelper = new ServiceRemotingCancellationHelper(serviceContext.TraceId);

            this.methodDispatcherMap = new Dictionary <int, ServiceMethodDispatcherBase>();
            this.service             = service;

            if (service != null)
            {
                var serviceTypeInformation = ServiceTypeInformation.Get(service.GetType());
                List <ServiceInterfaceDescription> interfaceDescriptions = new List <ServiceInterfaceDescription>();

                foreach (var interfaceType in serviceTypeInformation.InterfaceTypes)
                {
                    var methodDispatcher = ServiceCodeBuilder.GetOrCreateMethodDispatcher(interfaceType);
                    this.methodDispatcherMap.Add(methodDispatcher.InterfaceId, methodDispatcher);
                    interfaceDescriptions.Add(ServiceInterfaceDescription.Create(interfaceType));
                }

                this.servicePerformanceCounterProvider =
                    new ServicePerformanceCounterProvider(serviceContext.PartitionId,
                                                          serviceContext.ReplicaOrInstanceId,
                                                          interfaceDescriptions);
            }
        }
Beispiel #5
0
        protected override ProxyGeneratorBuildResult BuildProxyGenerator(Type interfaceType)
        {
            // create all service interfaces that this interface derives from
            var serviceInterfaces = new List <Type>()
            {
                interfaceType
            };

            serviceInterfaces.AddRange(interfaceType.GetServiceInterfaces());

            // create interface descriptions for all interfaces
            var servicenterfaceDescriptions = serviceInterfaces.Select <Type, InterfaceDescription>(
                (t) => ServiceInterfaceDescription.Create(t));

            return(this.proxyGeneratorBuilder.Build(interfaceType, servicenterfaceDescriptions));
        }
Beispiel #6
0
        internal ProxyGeneratorBuildResult BuildProxyGeneratorForNonMarkerInterface(Type interfaceType)
        {
            // create all base interfaces that this interface derives from
            var serviceInterfaces = new List <Type>()
            {
            };

            serviceInterfaces.AddRange(interfaceType.GetAllBaseInterfaces());

            // create interface descriptions for all interfaces
            var servicenterfaceDescriptions = serviceInterfaces.Select <Type, InterfaceDescription>(
                (t) => ServiceInterfaceDescription.CreateUsingCRCId(t, false));

            var res = this.CreateProxyGeneratorBuildResult(interfaceType, servicenterfaceDescriptions);

            return(res);
        }
        private void Initialize(ServiceContext serviceContext, object serviceImplementation,
                                IEnumerable <Type> remotedInterfaces, bool nonServiceInterface,
                                IServiceRemotingMessageBodyFactory serviceRemotingMessageBodyFactory)
        {
            this.serviceRemotingMessageBodyFactory = serviceRemotingMessageBodyFactory ?? new DataContractRemotingMessageFactory();

            this.cancellationHelper = new ServiceRemotingCancellationHelper(serviceContext.TraceId);

            this.methodDispatcherMap   = new Dictionary <int, MethodDispatcherBase>();
            this.serviceImplementation = serviceImplementation;

            if (serviceImplementation != null)
            {
                var interfaceDescriptions = new List <ServiceInterfaceDescription>();
                foreach (var interfaceType in remotedInterfaces)
                {
                    MethodDispatcherBase methodDispatcher;
                    if (nonServiceInterface)
                    {
                        methodDispatcher = ServiceCodeBuilder.GetOrCreateMethodDispatcherForNonMarkerInterface(interfaceType);
                        interfaceDescriptions.Add(ServiceInterfaceDescription.CreateUsingCRCId(interfaceType, false));
                    }
                    else
                    {
                        methodDispatcher = ServiceCodeBuilder.GetOrCreateMethodDispatcher(interfaceType);
                        interfaceDescriptions.Add(ServiceInterfaceDescription.CreateUsingCRCId(interfaceType, true));
                    }
                    this.methodDispatcherMap.Add(methodDispatcher.InterfaceId, methodDispatcher);
                }

                this.servicePerformanceCounterProvider =
                    new ServicePerformanceCounterProvider(serviceContext.PartitionId,
                                                          serviceContext.ReplicaOrInstanceId,
                                                          interfaceDescriptions,
                                                          false);
            }
        }
Beispiel #8
0
 protected override MethodBodyTypesBuildResult BuildMethodBodyTypes(Type interfaceType)
 {
     return(this.methodBodyTypesBuilder.Build(ServiceInterfaceDescription.Create(interfaceType)));
 }
Beispiel #9
0
        private MethodDispatcherBuildResult BuildMethodDispatcherForNonServiceInterface(Type interfaceType)
        {
            var servicenterfaceDescription = ServiceInterfaceDescription.CreateUsingCRCId(interfaceType, false);

            return(this.BuildMethodDispatcherResult(servicenterfaceDescription));
        }