/// <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); } }
/// <summary> /// Instantiates the ActorServiceRemotingDispatcher that can dispatch messages to an actor service and /// to the actors hosted in the service.. /// </summary> /// <param name="actorService">An actor service instance.</param> /// <param name="serviceRemotingRequestMessageBodyFactory"></param> public ActorServiceRemotingDispatcher(ActorService actorService, IServiceRemotingMessageBodyFactory serviceRemotingRequestMessageBodyFactory) : base(GetContext(actorService), actorService, serviceRemotingRequestMessageBodyFactory) { this.actorService = actorService; this.cancellationHelper = new ServiceRemotingCancellationHelper(actorService.Context.TraceId); }
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); } }
/// <summary> /// Instantiates the ActorServiceRemotingDispatcher that can dispatch messages to an actor service and /// to the actors hosted in the service.. /// </summary> /// <param name="actorService">An actor service instance.</param> public ActorServiceRemotingDispatcher(ActorService actorService) : base(GetContext(actorService), actorService) { this.actorService = actorService; this.cancellationHelper = new ServiceRemotingCancellationHelper(actorService.Context.TraceId); }