Ejemplo n.º 1
0
        private static I ForService <I>(Uri serviceAddress, ServicePartitionKey partitionKey = null) where I : class, IService
        {
            Debug.Assert(typeof(I).IsInterface);
            I proxy = defaultProxyFactory.CreateNonIServiceProxy <I>(serviceAddress, partitionKey: partitionKey, listenerName: Naming.Listener <I>());

            return(proxy);
        }
Ejemplo n.º 2
0
        private IProductCatalogService GetProductCatalogService()
        {
            var proxyFactory = new ServiceProxyFactory(c => new FabricTransportServiceRemotingClientFactory());

            return(proxyFactory.CreateNonIServiceProxy <IProductCatalogService>(
                       new Uri("fabric:/ECommerce/ECommerce.ProductCatalog"),
                       new ServicePartitionKey(0)));
        }
Ejemplo n.º 3
0
 internal static I ForService <I>(ServiceProxyFactory serviceProxyFactory, Uri serviceAddress, ServicePartitionKey partitionKey = null) where I : class, IService
 {
     if (serviceProxyFactory == null)
     {
         throw new ArgumentNullException(nameof(serviceProxyFactory), "Invalid node call. Must supply service proxy factory.");
     }
     Debug.Assert(typeof(I).IsInterface);
     return(serviceProxyFactory.CreateNonIServiceProxy <I>(serviceAddress, partitionKey: partitionKey, listenerName: Naming.Listener <I>()));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// This is the main entry point for your service instance.
        /// </summary>
        /// <param name="cancellationToken">Canceled when Service Fabric needs to shut down this service instance.</param>
        protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            ServiceProxyFactory factory = new ServiceProxyFactory(handler =>
                                                                  new FabricTransportServiceRemotingClientFactory(new FabricTransportRemotingSettings
            {
                UseWrappedMessage = true
            }));

            ISampleService sampleService = factory.CreateNonIServiceProxy <ISampleService>(
                new Uri("fabric:/SFRemotingSerializationIssue/SampleService"));

            while (true)
            {
                cancellationToken.ThrowIfCancellationRequested();

                try
                {
                    int simpleValue = await sampleService.SimpleTypeShouldWorkV1V2Async(100);

                    Console.WriteLine($"SimpleType works: '{simpleValue}'.");

                    int wrappedValue = await sampleService.GenericStructShouldWorkV1V2Async(100);

                    Console.WriteLine($"GenericType works: '{wrappedValue}'.");

                    // commented out as V2 cannot generate data contract if there are two methods with different
                    // types that resolve to same contract name
                    //List<int> collectionValue = await sampleService.SpecificCollectionTypeShouldWorkV1V2Async(new[] { 1, 2, 3 });
                    //Console.WriteLine($"CollectionType works: '{string.Join(", ", collectionValue)}'.");

                    IEnumerable <int> enumerableValue =
                        await sampleService.KnownCollectionInterfaceShouldWorkV21(new[] { 1, 2, 3 });

                    Console.WriteLine($"CollectionInterface works: '{string.Join(", ", enumerableValue)}'.");
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine($"Caught exception: {ex}");
                }

                await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
            }
        }
Ejemplo n.º 5
0
        public IUserDataAppService CreateUserDataAppService(ItemId itemId)
        {
            var buidler = new ServiceUriBuilder(Constants.ServiceName_ProfileStateService);

            return(proxyFactory.CreateNonIServiceProxy <IUserDataAppService>(buidler.ToUri(), itemId.GetPartitionKey(), listenerName: Constants.ListenerName_UserDataAppService));
        }