Ejemplo n.º 1
0
        public static TServiceInterface CreateService <TServiceInterface>(Uri serviceUri) where TServiceInterface : IService
        {
            CustomContextDataDto dto     = CustomServiceContext.GetContext();
            ServiceProxyFactory  factory = new ServiceProxyFactory(CreateServiceRemotingClientFactory);
            ServicePartitionKey  key     = new ServicePartitionKey(GetLongHashCode(dto == null ? string.Empty : dto.ID));
            var serviceProxy             = factory.CreateServiceProxy <TServiceInterface>(serviceUri, key);

            return(serviceProxy);
        }
Ejemplo n.º 2
0
        public static void InvokeService <TServiceInterface>(Uri serviceUri, Action <TServiceInterface> action, CustomContextDataDto context = null) where TServiceInterface : IService
        {
            if (CustomServiceContext.GetContext() == null && context != null)
            {
                CustomServiceContext.SetContext(context);
            }
            CustomContextDataDto dto     = CustomServiceContext.GetContext();
            ServiceProxyFactory  factory = new ServiceProxyFactory(CreateServiceRemotingClientFactory);
            ServicePartitionKey  key     = new ServicePartitionKey(GetLongHashCode(dto == null ? string.Empty : dto.ID));

            ServiceRequestContext.RunInRequestContext(() => {
                var serviceProxy = factory.CreateServiceProxy <TServiceInterface>(serviceUri, key);
                return(Task.Run(() => { action(serviceProxy); }));
            }, dto);
        }