Esempio n. 1
0
        protected override IAsyncResult OnBeginCreateInstance(SingletonDictionaryManager <string, IRequestSessionChannel> .SingletonContext singletonContext, string key, object loadingContext, TimeSpan timeout, AsyncCallback callback, object state)
        {
            Uri             uri             = new Uri(key);
            EndpointAddress endpointAddress = new EndpointAddress(uri, SbmpProtocolDefaults.GetEndpointIdentity(uri), new AddressHeader[0]);
            IChannelFactory <IRequestSessionChannel> channelFactory = this.defaultChannelFactory;

            if (!this.clientMode && loadingContext != null && loadingContext is bool && (bool)loadingContext)
            {
                channelFactory = this.securedChannelFactory;
            }
            IRequestSessionChannel requestSessionChannel = channelFactory.CreateChannel(endpointAddress);

            requestSessionChannel.SafeAddFaulted((object s, EventArgs e) => {
                this.RaiseNotifyCleanup(uri);
                try
                {
                    base.BeginUnloadInstance(key, null, true, TimeSpan.FromSeconds(10), new AsyncCallback(ContainerChannelManager.UnloadCallback), this);
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    if (Fx.IsFatal(exception))
                    {
                        throw;
                    }
                    MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.EventWriteExceptionAsWarning(exception.ToString()));
                }
            });
            return(new CompletedAsyncResult <IRequestSessionChannel>(requestSessionChannel, callback, state));
        }
 internal EndpointAddress CreateEndpointAddress(string entityName)
 {
     return(new EndpointAddress(this.CreateUri(entityName), SbmpProtocolDefaults.GetEndpointIdentity(this.BaseAddress), new AddressHeader[0]));
 }