public TServiceInterface CreateServiceProxy()

in src/Microsoft.ServiceFabric.Services.Remoting/Client/ServiceProxyFactory.cs [95:171]


        public TServiceInterface CreateServiceProxy<TServiceInterface>(
            Uri serviceUri,
            ServicePartitionKey partitionKey = null,
            TargetReplicaSelector targetReplicaSelector = TargetReplicaSelector.Default,
            string listenerName = null)
            where TServiceInterface : IService
        {
            var serviceInterfaceType = typeof(TServiceInterface);

#if !DotNetCoreClr
            // Use provider to find the stack
            if (this.proxyFactoryV1 == null && this.proxyFactoryV2 == null)
            {
                lock (this.thisLock)
                {
                    if (this.proxyFactoryV1 == null && this.proxyFactoryV2 == null)
                    {
                        var provider = this.GetProviderAttribute(serviceInterfaceType);
                        if (Helper.IsEitherRemotingV2(provider.RemotingClientVersion))
                        {
                            // We are overriding listenerName since using provider we can have multiple listener configured.
                            this.overrideListenerName = true;
                            this.defaultListenerName = this.GetDefaultListenerName(
                                listenerName,
                                provider.RemotingClientVersion);
                            this.proxyFactoryV2 =
                                new V2.Client.ServiceProxyFactory(provider.CreateServiceRemotingClientFactoryV2, this.retrySettings);
                        }
                        else
                        {
                            this.proxyFactoryV1 = new V1.Client.ServiceProxyFactory(provider.CreateServiceRemotingClientFactory, this.retrySettings);
                        }
                    }
                }
            }

            if (this.proxyFactoryV1 != null)
            {
                return this.proxyFactoryV1.CreateServiceProxy<TServiceInterface>(
                    serviceUri,
                    partitionKey,
                    targetReplicaSelector,
                    listenerName);
            }

            return this.proxyFactoryV2.CreateServiceProxy<TServiceInterface>(
                serviceUri,
                partitionKey,
                targetReplicaSelector,
                this.OverrideListenerNameIfConditionMet(listenerName));
#else
            if (this.proxyFactoryV2 == null)
            {
                lock (this.thisLock)
                {
                  if (this.proxyFactoryV2 == null)
                    {
                        var provider = this.GetProviderAttribute(serviceInterfaceType);

                        // We are overriding listenerName since using provider we can have multiple listener configured.
                        this.overrideListenerName = true;
                        this.defaultListenerName = this.GetDefaultListenerName(
                            listenerName,
                            provider.RemotingClientVersion);
                        this.proxyFactoryV2 =
                            new V2.Client.ServiceProxyFactory(provider.CreateServiceRemotingClientFactoryV2, this.retrySettings);
                    }
                }
            }

            return this.proxyFactoryV2.CreateServiceProxy<TServiceInterface>(
              serviceUri,
              partitionKey,
              targetReplicaSelector,
              this.OverrideListenerNameIfConditionMet(listenerName));
#endif
        }