Exemple #1
0
 public bool Equals(RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.EntityLinkKey other)
 {
     if (!StringComparer.OrdinalIgnoreCase.Equals(this.entityName, other.entityName))
     {
         return(false);
     }
     return(StringComparer.OrdinalIgnoreCase.Equals(this.linkId, other.linkId));
 }
Exemple #2
0
 public RedirectContainerSessionChannel(RedirectBindingElement.RedirectContainerChannelFactory <IRequestSessionChannel> factory, EndpointAddress address, Uri via) : base(factory)
 {
     this.innerFactory   = factory.innerFactory;
     this.bindingElement = factory.BindingElement;
     this.RemoteAddress  = address;
     this.Via            = via;
     this.entityMap      = new ConcurrentDictionary <RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.EntityLinkKey, RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.EntityLinkValue>();
     this.primaryChannel = this.innerFactory.CreateChannel(address, via);
     RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.OutputSession outputSession = new RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.OutputSession()
     {
         Id = this.primaryChannel.Session.Id
     };
     this.Session = outputSession;
     this.onCorrelatorNotifyCleanup        = new EventHandler(this.OnCorrelatorNotifyCleanup);
     this.correlatorManager                = new ContainerChannelManager(true, this.bindingElement.UseSslStreamSecurity, this.bindingElement.IncludeExceptionDetails, this.bindingElement.EndpointIdentity);
     this.correlatorManager.NotifyCleanup += new EventHandler(this.OnCorrelatorNotifyCleanup);
 }
Exemple #3
0
                    protected override IEnumerator <IteratorAsyncResult <RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult> .AsyncStep> GetAsyncSteps()
                    {
                        RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.EntityLinkValue entityLinkValue;
                        RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.EntityLinkValue entityLinkValue1;
                        string str;
                        object obj;

                        this.ThrowIfNotSupportedClientSettings();
                        Message message = null;
                        int     num     = this.incomingMessage.Headers.FindHeader("Authorization", "http://schemas.microsoft.com/servicebus/2010/08/protocol/");
                        string  empty   = string.Empty;

                        if (this.incomingMessage.Properties != null && this.incomingMessage.Properties.TryGetValue("ParentLinkId", out obj))
                        {
                            empty = (string)obj;
                        }
                        LinkInfo header = LinkInfo.GetHeader(this.incomingMessage.Headers);
                        bool     flag   = !string.IsNullOrWhiteSpace(empty);

                        str = (flag ? empty : header.LinkId);
                        RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.EntityLinkKey entityLinkKey = new RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.EntityLinkKey(header.EntityName, str);

                        RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.EntityLinkValue entityLinkValue2 = null;
                        IRequestSessionChannel requestSessionChannel = null;

                        if (this.sessionChannel.containerNameResolutionMode != ContainerNameResolutionMode.DisableRedirect && !string.IsNullOrEmpty(entityLinkKey.EntityName) && !this.sessionChannel.entityMap.TryGetValue(entityLinkKey, out entityLinkValue2))
                        {
                            if (!this.sessionChannel.bindingElement.EnableRedirect)
                            {
                                RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult requestAsyncResult = this;
                                IteratorAsyncResult <RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult> .BeginCall beginCall = (RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.sessionChannel.primaryChannel.BeginRequest(thisPtr.incomingMessage, t, c, s);
                                IteratorAsyncResult <RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult> .EndCall   endCall   = (RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, IAsyncResult r) => message = thisPtr.sessionChannel.primaryChannel.EndRequest(r);
                                yield return(requestAsyncResult.CallAsync(beginCall, endCall, (RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, TimeSpan t) => message = thisPtr.sessionChannel.primaryChannel.Request(thisPtr.incomingMessage, t), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
                            }
                            else
                            {
                                RedirectCommand redirectCommand = new RedirectCommand();
                                Message         to = Message.CreateMessage(this.incomingMessage.Version, "http://schemas.microsoft.com/netservices/2011/06/servicebus/SbmpRedirect/Redirect", redirectCommand);
                                to.Headers.To = this.incomingMessage.Headers.To;
                                header.AddTo(to.Headers);
                                if (num >= 0)
                                {
                                    to.Headers.CopyHeaderFrom(this.incomingMessage.Headers, num);
                                }
                                RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult requestAsyncResult1 = this;
                                IteratorAsyncResult <RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult> .BeginCall beginCall1 = (RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.sessionChannel.primaryChannel.BeginRequest(to, t, c, s);
                                yield return(requestAsyncResult1.CallAsync(beginCall1, (RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, IAsyncResult r) => message = thisPtr.sessionChannel.primaryChannel.EndRequest(r), (RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, TimeSpan t) => message = thisPtr.sessionChannel.primaryChannel.Request(to, t), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
                            }
                            if (message == null || !string.Equals(message.Headers.Action, "http://schemas.microsoft.com/netservices/2011/06/servicebus/SbmpRedirect/RedirectResponse", StringComparison.OrdinalIgnoreCase))
                            {
                                if (base.LastAsyncStepException != null)
                                {
                                    goto Label1;
                                }
                                this.ResponseMessage = message;
                                if (!flag && string.Equals(this.incomingMessageAction, "http://schemas.microsoft.com/netservices/2011/06/servicebus/SbmpConnection/CloseLink", StringComparison.OrdinalIgnoreCase))
                                {
                                    this.sessionChannel.entityMap.TryRemove(entityLinkKey, out entityLinkValue);
                                    goto Label0;
                                }
                                else
                                {
                                    goto Label0;
                                }
                            }
                            else
                            {
                                LinkInfo linkInfo            = LinkInfo.GetHeader(message.Headers);
                                RedirectResponseCommand body = message.GetBody <RedirectResponseCommand>();
                                entityLinkValue2 = new RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.EntityLinkValue(body.RedirectTo, linkInfo);

                                this.sessionChannel.containerNameResolutionMode = body.ContainerNameResolutionMode;
                                this.ThrowIfNotSupportedClientSettings();
                                if (body.ContainerNameResolutionMode != ContainerNameResolutionMode.DisableRedirect)
                                {
                                    this.sessionChannel.entityMap.TryAdd(entityLinkKey, entityLinkValue2);
                                }
                            }
                        }
Label1:
                        if (entityLinkValue2 == null || this.sessionChannel.containerNameResolutionMode == ContainerNameResolutionMode.DisableRedirect || !this.sessionChannel.bindingElement.EnableRedirect && this.sessionChannel.containerNameResolutionMode == ContainerNameResolutionMode.AllowRedirect)
                        {
                            requestSessionChannel = this.sessionChannel.primaryChannel;
                        }
                        else
                        {
                            RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult requestAsyncResult2 = this;
                            IteratorAsyncResult <RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult> .BeginCall beginCall2 = (RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.sessionChannel.correlatorManager.BeginGetCorrelator(entityLinkValue2.ContainerLocation, t, c, s);
                            yield return(requestAsyncResult2.CallAsync(beginCall2, (RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, IAsyncResult a) => requestSessionChannel = thisPtr.sessionChannel.correlatorManager.EndGetCorrelator(a), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));

                            this.incomingMessage.Headers.RemoveAll("LinkInfo", "http://schemas.microsoft.com/netservices/2011/06/servicebus");
                            header.TransferDestinationEntityAddress           = entityLinkValue2.UpdatedLinkInfo.TransferDestinationEntityAddress;
                            header.TransferDestinationMessagingInstanceHandle = entityLinkValue2.UpdatedLinkInfo.TransferDestinationMessagingInstanceHandle;
                            header.TransferDestinationResourceResourceId      = entityLinkValue2.UpdatedLinkInfo.TransferDestinationResourceResourceId;
                            header.EntityType = entityLinkValue2.UpdatedLinkInfo.EntityType;
                            header.EntityName = entityLinkValue2.UpdatedLinkInfo.EntityName;
                            header.AddTo(this.incomingMessage.Headers);
                        }
                        if (!flag && string.Equals(this.incomingMessageAction, "http://schemas.microsoft.com/netservices/2011/06/servicebus/SbmpConnection/CloseLink", StringComparison.OrdinalIgnoreCase))
                        {
                            this.sessionChannel.entityMap.TryRemove(entityLinkKey, out entityLinkValue1);
                        }
                        yield return(base.CallAsync((RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => requestSessionChannel.BeginRequest(thisPtr.incomingMessage, t, c, s), (RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, IAsyncResult r) => thisPtr.ResponseMessage = requestSessionChannel.EndRequest(r), (RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, TimeSpan t) => thisPtr.ResponseMessage = requestSessionChannel.Request(thisPtr.incomingMessage, t), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));

Label0:
                        yield break;
                    }
Exemple #4
0
 public RequestAsyncResult(RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel parent, Message incomingMessage, TimeSpan timeout, AsyncCallback callback, object state) : base(timeout, callback, state)
 {
     this.sessionChannel        = parent;
     this.incomingMessage       = incomingMessage;
     this.incomingMessageAction = this.incomingMessage.Headers.Action;
 }