public MasterDataClient(string serviceName, BootstrapContext token = null)
        {
            Tracer = TracerFactory.StartTracer(this, "ctor");
            var runtime = RuntimeFactory.CreateRuntime();

            Container = runtime.CreateServiceProxy <IMasterDataManagementService>(serviceName);
            if (token.IsInstance())
            {
                Container.Initialize(token);
            }
        }
        private void CreateClient(EndpointAddress endpointAdress)
        {
            var rest = ClientFactory.Endpoint.Behaviors.Find <RestTokenHandler>();

            if (rest != null)
            {
                var tokenManager = FindTokenManager();
                RuntimeFactory.Current.GetStateStorageContainer().TryAddStorageItem(tokenManager);
                Client = ClientFactory.CreateChannel(endpointAdress);
            }
            else
            {
                if (ConfigurationManagerHelper.GetValueOnKey("stardust.RelayToken") == "true")
                {
                    if (BootstrapContext != null)
                    {
                        Client = ClientFactory.CreateChannelWithIssuedToken(BootstrapContext.SecurityToken);
                        return;
                    }
                }
                if (!(ClientFactory.Endpoint.Binding is WS2007FederationHttpBinding))
                {
                    Client = ClientFactory.CreateChannel(endpointAdress);
                    return;
                }
                if (BootstrapContext.IsInstance())
                {
                    Client = ClientFactory.CreateChannelWithIssuedToken(GetTokenOnBehalfOf(), endpointAdress);
                }
                else if (UseSecureChannel)
                {
                    Client = ClientFactory.CreateChannelWithIssuedToken(GetToken(), endpointAdress);
                }
                else
                {
                    Client = ClientFactory.CreateChannel(endpointAdress);
                }
            }
        }
 private TokenManager FindTokenManager()
 {
     return(BootstrapContext.IsInstance() ? GetOnBehalfOfManager() : GetTokenManager());
 }