本文整理汇总了C#中System.ServiceModel.Channels.RequestContext.Close方法的典型用法代码示例。如果您正苦于以下问题:C# RequestContext.Close方法的具体用法?C# RequestContext.Close怎么用?C# RequestContext.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ServiceModel.Channels.RequestContext
的用法示例。
在下文中一共展示了RequestContext.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: lock
void IDisposable.Dispose()
{
RequestContext context;
bool flag = false;
lock (this.thisLock)
{
if (this.context == null)
{
return;
}
context = this.context;
this.context = null;
}
try
{
context.Close();
flag = true;
}
catch (CommunicationException exception)
{
if (DiagnosticUtility.ShouldTraceInformation)
{
DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information);
}
}
catch (TimeoutException exception2)
{
if (DiagnosticUtility.ShouldTraceInformation)
{
DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Information);
}
}
finally
{
if (!flag)
{
context.Abort();
}
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:40,代码来源:RequestContextMessageProperty.cs
示例2: DisposeRequestContext
void DisposeRequestContext(RequestContext context)
{
try
{
context.Close();
ReceiveContextRPCFacet receiveContext = this.ReceiveContext;
if (receiveContext != null)
{
this.ReceiveContext = null;
IAsyncResult result = receiveContext.BeginComplete(
TimeSpan.MaxValue,
null,
this.channelHandler,
handleEndComplete,
new CallbackState
{
ChannelHandler = this.channelHandler,
ReceiveContext = receiveContext
});
if (result.CompletedSynchronously)
{
receiveContext.EndComplete(result);
}
}
}
catch (Exception e)
{
if (Fx.IsFatal(e))
{
throw;
}
this.AbortRequestContext(context);
this.channelHandler.HandleError(e);
}
}
示例3: ReplyWithMetaData
private void ReplyWithMetaData(RequestContext context)
{
var action = context.RequestMessage.Headers.Action;
var contractInfo = ContractInfo.FromAction(action);
var contractType = TypeFinder.FindServiceContract(contractInfo.ServiceContractName);
var paramTypes = TypeFinder.GetContractParamTypes(contractType, contractInfo.OperationContractName, contractInfo.Action);
var modelProvider = ObjectBuilder.GetModelProvider();
var typeMetaDatas = new Dictionary<string, string>();
var serializer = ObjectBuilder.GetSerializer();
foreach (var paramType in paramTypes)
{
if (typeMetaDatas.ContainsKey(paramType.Name))
continue;
var modelInfo = modelProvider.CreateModelInfo(paramType.Type);
var metaData = modelInfo.MetaData;
var result = serializer.Serialize(metaData);
var val = BinaryConverter.ToString(result.Data);
typeMetaDatas.Add(paramType.Name, val);
}
var replyMessage = Message.CreateMessage(MessageVersion.Soap12WSAddressing10, context.RequestMessage.Headers.Action);
foreach (var typeMetaData in typeMetaDatas)
{
replyMessage.Headers.Add(MessageHeader.CreateHeader(Constants.MetaDataHeaderKeySuffix + typeMetaData.Key,
Constants.DefaultCustomHeaderNamespace, typeMetaData.Value));
}
context.Reply(replyMessage);
context.Close();
}
示例4: HandleErrorContinuation
bool HandleErrorContinuation(Exception e, RequestContext request, ServiceChannel channel, ref ErrorHandlerFaultInfo faultInfo, bool replied)
{
if (replied)
{
try
{
request.Close();
}
catch (Exception e1)
{
if (Fx.IsFatal(e1))
{
throw;
}
this.HandleError(e1);
}
}
else
{
request.Abort();
}
if (!this.HandleError(e, ref faultInfo) && this.hasSession)
{
if (channel != null)
{
if (replied)
{
TimeoutHelper timeoutHelper = new TimeoutHelper(CloseAfterFaultTimeout);
try
{
channel.Close(timeoutHelper.RemainingTime());
}
catch (Exception e2)
{
if (Fx.IsFatal(e2))
{
throw;
}
this.HandleError(e2);
}
try
{
this.binder.CloseAfterFault(timeoutHelper.RemainingTime());
}
catch (Exception e3)
{
if (Fx.IsFatal(e3))
{
throw;
}
this.HandleError(e3);
}
}
else
{
channel.Abort();
this.binder.Abort();
}
}
else
{
if (replied)
{
try
{
this.binder.CloseAfterFault(CloseAfterFaultTimeout);
}
catch (Exception e4)
{
if (Fx.IsFatal(e4))
{
throw;
}
this.HandleError(e4);
}
}
else
{
this.binder.Abort();
}
}
}
return true;
}
示例5: EnsureChannelAndEndpoint
void EnsureChannelAndEndpoint(RequestContext request)
{
this.requestInfo.Channel = this.channel;
if (this.requestInfo.Channel == null)
{
bool addressMatched;
if (this.hasSession)
{
this.requestInfo.Channel = this.GetSessionChannel(request.RequestMessage, out this.requestInfo.Endpoint, out addressMatched);
}
else
{
this.requestInfo.Channel = this.GetDatagramChannel(request.RequestMessage, out this.requestInfo.Endpoint, out addressMatched);
}
if (this.requestInfo.Channel == null)
{
this.host.RaiseUnknownMessageReceived(request.RequestMessage);
if (addressMatched)
{
this.ReplyContractFilterDidNotMatch(request);
}
else
{
this.ReplyAddressFilterDidNotMatch(request);
}
}
}
else
{
this.requestInfo.Endpoint = this.requestInfo.Channel.EndpointDispatcher;
//For sessionful contracts, the InstanceContext throttle is not copied over to the channel
//as we create the channel before acquiring the lock
if (this.InstanceContextServiceThrottle != null && this.requestInfo.Channel.InstanceContextServiceThrottle == null)
{
this.requestInfo.Channel.InstanceContextServiceThrottle = this.InstanceContextServiceThrottle;
}
}
this.requestInfo.EndpointLookupDone = true;
if (this.requestInfo.Channel == null)
{
// SFx drops a message here
TraceUtility.TraceDroppedMessage(request.RequestMessage, this.requestInfo.Endpoint);
request.Close();
return;
}
if (this.requestInfo.Channel.HasSession || this.isCallback)
{
this.requestInfo.DispatchRuntime = this.requestInfo.Channel.DispatchRuntime;
}
else
{
this.requestInfo.DispatchRuntime = this.requestInfo.Endpoint.DispatchRuntime;
}
}
示例6: TryRetrievingInstanceContextCore
//Return: False denotes failure, Caller should discard the request.
// : True denotes operation is sucessful.
bool TryRetrievingInstanceContextCore(RequestContext request)
{
bool releasePump = true;
try
{
if (!this.requestInfo.EndpointLookupDone)
{
this.EnsureChannelAndEndpoint(request);
}
if (this.requestInfo.Channel == null)
{
return false;
}
if (this.requestInfo.DispatchRuntime != null)
{
IContextChannel transparentProxy = this.requestInfo.Channel.Proxy as IContextChannel;
try
{
this.requestInfo.ExistingInstanceContext = this.requestInfo.DispatchRuntime.InstanceContextProvider.GetExistingInstanceContext(request.RequestMessage, transparentProxy);
releasePump = false;
}
catch (Exception e)
{
if (Fx.IsFatal(e))
{
throw;
}
this.requestInfo.Channel = null;
this.HandleError(e, request, channel);
return false;
}
}
else
{
// This can happen if we are pumping for an async client,
// and we receive a bogus reply. In that case, there is no
// DispatchRuntime, because we are only expecting replies.
//
// One possible fix for this would be in DuplexChannelBinder
// to drop all messages with a RelatesTo that do not match a
// pending request.
//
// However, that would not fix:
// (a) we could get a valid request message with a
// RelatesTo that we should try to process.
// (b) we could get a reply message that does not have
// a RelatesTo.
//
// So we do the null check here.
//
// SFx drops a message here
TraceUtility.TraceDroppedMessage(request.RequestMessage, this.requestInfo.Endpoint);
request.Close();
return false;
}
}
catch (Exception e)
{
if (Fx.IsFatal(e))
{
throw;
}
this.HandleError(e, request, channel);
return false;
}
finally
{
if (releasePump)
{
this.ReleasePump();
}
}
return true;
}
示例7: TryRetrievingInstanceContext
bool TryRetrievingInstanceContext(RequestContext request)
{
try
{
return TryRetrievingInstanceContextCore(request);
}
catch (Exception ex)
{
if (Fx.IsFatal(ex))
{
throw;
}
DiagnosticUtility.TraceHandledException(ex, TraceEventType.Error);
try
{
request.Close();
}
catch (Exception e)
{
if (Fx.IsFatal(e))
{
throw;
}
request.Abort();
}
return false;
}
}
示例8: ProcessInfo
public bool ProcessInfo(WsrmMessageInfo info, RequestContext context, bool throwException)
{
Exception e;
if (info.ParsingException != null)
{
WsrmFault fault;
if (this.SequenceID != null)
{
string reason = SR.GetString(SR.CouldNotParseWithAction, info.Action);
fault = SequenceTerminatedFault.CreateProtocolFault(this.SequenceID, reason, null);
}
else
{
fault = null;
}
e = new ProtocolException(SR.GetString(SR.MessageExceptionOccurred), info.ParsingException);
this.OnLocalFault(throwException ? null : e, fault, context);
}
else if (info.FaultReply != null)
{
e = info.FaultException;
this.OnLocalFault(throwException ? null : e, info.FaultReply, context);
}
else if ((info.WsrmHeaderFault != null) && (info.WsrmHeaderFault.SequenceID != this.InputID)
&& (info.WsrmHeaderFault.SequenceID != this.OutputID))
{
e = new ProtocolException(SR.GetString(SR.WrongIdentifierFault, FaultException.GetSafeReasonText(info.WsrmHeaderFault.Reason)));
this.OnLocalFault(throwException ? null : e, (Message)null, context);
}
else if (info.FaultInfo != null)
{
if (this.isSessionClosed)
{
UnknownSequenceFault unknownSequenceFault = info.FaultInfo as UnknownSequenceFault;
if (unknownSequenceFault != null)
{
UniqueId sequenceId = unknownSequenceFault.SequenceID;
if (((this.OutputID != null) && (this.OutputID == sequenceId))
|| ((this.InputID != null) && (this.InputID == sequenceId)))
{
if (this.settings.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005)
{
info.Message.Close();
return false;
}
else if (this.settings.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
{
return true;
}
else
{
throw Fx.AssertAndThrow("Unknown version.");
}
}
}
}
e = info.FaultException;
if (context != null)
context.Close();
this.OnRemoteFault(throwException ? null : e);
}
else
{
return true;
}
info.Message.Close();
if (throwException)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(e);
else
return false;
}
示例9: DisposeRequestContext
private void DisposeRequestContext(RequestContext context)
{
try
{
context.Close();
}
catch (Exception e)
{
if (Fx.IsFatal(e))
{
throw;
}
this.AbortRequestContext(context);
this.channelHandler.HandleError(e);
}
}
示例10: ProcessRequest
private void ProcessRequest(RequestContext context, WsrmMessageInfo info)
{
bool flag = true;
bool flag2 = true;
try
{
EndpointAddress address;
bool flag3;
if (!base.ReliableSession.ProcessInfo(info, context))
{
flag = false;
flag2 = false;
return;
}
if (!base.ReliableSession.VerifySimplexProtocolElements(info, context))
{
flag = false;
flag2 = false;
return;
}
base.ReliableSession.OnRemoteActivity(false);
if (info.CreateSequenceInfo == null)
{
goto Label_0104;
}
if (WsrmUtilities.ValidateCreateSequence<IInputSessionChannel>(info, base.Listener, base.Binder.Channel, out address))
{
Message response = WsrmUtilities.CreateCreateSequenceResponse(base.Listener.MessageVersion, base.Listener.ReliableMessagingVersion, false, info.CreateSequenceInfo, base.Listener.Ordered, base.ReliableSession.InputID, address);
using (context)
{
using (response)
{
if (base.Binder.AddressResponse(info.Message, response))
{
context.Reply(response, base.DefaultSendTimeout);
}
}
goto Label_00FB;
}
}
base.ReliableSession.OnLocalFault(info.FaultException, info.FaultReply, context);
Label_00FB:
flag = false;
flag2 = false;
return;
Label_0104:
flag3 = false;
bool allAdded = false;
bool flag5 = false;
WsrmFault fault = null;
Message message2 = null;
Exception e = null;
bool flag6 = base.Listener.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005;
bool flag7 = base.Listener.ReliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11;
bool flag8 = info.AckRequestedInfo != null;
if (info.SequencedMessageInfo != null)
{
lock (base.ThisLock)
{
if (base.Aborted || (base.State == CommunicationState.Faulted))
{
return;
}
long sequenceNumber = info.SequencedMessageInfo.SequenceNumber;
bool isLast = flag6 && info.SequencedMessageInfo.LastMessage;
if (!base.Connection.IsValid(sequenceNumber, isLast))
{
if (flag6)
{
fault = new LastMessageNumberExceededFault(base.ReliableSession.InputID);
}
else
{
message2 = new SequenceClosedFault(base.ReliableSession.InputID).CreateMessage(base.Listener.MessageVersion, base.Listener.ReliableMessagingVersion);
if (PerformanceCounters.PerformanceCountersEnabled)
{
PerformanceCounters.MessageDropped(base.perfCounterId);
}
}
}
else if (base.Connection.Ranges.Contains(sequenceNumber))
{
if (PerformanceCounters.PerformanceCountersEnabled)
{
PerformanceCounters.MessageDropped(base.perfCounterId);
}
}
else if (flag6 && (info.Action == "http://schemas.xmlsoap.org/ws/2005/02/rm/LastMessage"))
{
base.Connection.Merge(sequenceNumber, isLast);
allAdded = base.Connection.AllAdded;
}
else if (base.State == CommunicationState.Closing)
{
if (flag6)
{
fault = SequenceTerminatedFault.CreateProtocolFault(base.ReliableSession.InputID, System.ServiceModel.SR.GetString("SequenceTerminatedSessionClosedBeforeDone"), System.ServiceModel.SR.GetString("SessionClosedBeforeDone"));
}
else
{
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:ReliableInputSessionChannelOverReply.cs
示例11: EnsureChannelAndEndpoint
private void EnsureChannelAndEndpoint(RequestContext request)
{
_requestInfo.Channel = _channel;
if (_requestInfo.Channel == null)
{
bool addressMatched;
if (_hasSession)
{
_requestInfo.Channel = this.GetSessionChannel(request.RequestMessage, out _requestInfo.Endpoint, out addressMatched);
}
else
{
_requestInfo.Channel = this.GetDatagramChannel(request.RequestMessage, out _requestInfo.Endpoint, out addressMatched);
}
if (_requestInfo.Channel == null)
{
if (addressMatched)
{
this.ReplyContractFilterDidNotMatch(request);
}
else
{
this.ReplyAddressFilterDidNotMatch(request);
}
}
}
else
{
_requestInfo.Endpoint = _requestInfo.Channel.EndpointDispatcher;
}
_requestInfo.EndpointLookupDone = true;
if (_requestInfo.Channel == null)
{
// SFx drops a message here
TraceUtility.TraceDroppedMessage(request.RequestMessage, _requestInfo.Endpoint);
request.Close();
return;
}
if (_requestInfo.Channel.HasSession || _isCallback)
{
_requestInfo.DispatchRuntime = _requestInfo.Channel.DispatchRuntime;
}
else
{
_requestInfo.DispatchRuntime = _requestInfo.Endpoint.DispatchRuntime;
}
}
示例12: HandleRequest
bool HandleRequest(IReplyChannel channel, RequestContext context)
{
if (context == null)
{
channel.Close();
return false;
}
try
{
serviceManager.HandleRequest(context);
}
catch (CommunicationException)
{
context.Abort();
}
finally
{
context.Close();
}
return true;
}
示例13: HandleError
private bool HandleError(Exception e, RequestContext request, ServiceChannel channel)
{
bool flag;
ErrorHandlerFaultInfo faultInfo = new ErrorHandlerFaultInfo(this.messageVersion.Addressing.DefaultFaultAction);
this.ProvideFaultAndReplyFailure(request, e, ref faultInfo, out flag);
if (flag)
{
try
{
request.Close();
}
catch (Exception exception)
{
if (Fx.IsFatal(exception))
{
throw;
}
this.HandleError(exception);
}
}
else
{
request.Abort();
}
if (!this.HandleError(e, ref faultInfo) && this.hasSession)
{
if (channel != null)
{
if (flag)
{
TimeoutHelper helper = new TimeoutHelper(CloseAfterFaultTimeout);
try
{
channel.Close(helper.RemainingTime());
}
catch (Exception exception2)
{
if (Fx.IsFatal(exception2))
{
throw;
}
this.HandleError(exception2);
}
try
{
this.binder.CloseAfterFault(helper.RemainingTime());
goto Label_0117;
}
catch (Exception exception3)
{
if (Fx.IsFatal(exception3))
{
throw;
}
this.HandleError(exception3);
goto Label_0117;
}
}
channel.Abort();
this.binder.Abort();
}
else
{
if (flag)
{
try
{
this.binder.CloseAfterFault(CloseAfterFaultTimeout);
goto Label_0117;
}
catch (Exception exception4)
{
if (Fx.IsFatal(exception4))
{
throw;
}
this.HandleError(exception4);
goto Label_0117;
}
}
this.binder.Abort();
}
}
Label_0117:
return true;
}
示例14: EnsureChannelAndEndpoint
private void EnsureChannelAndEndpoint(RequestContext request)
{
this.requestInfo.Channel = this.channel;
if (this.requestInfo.Channel == null)
{
bool flag;
if (this.hasSession)
{
this.requestInfo.Channel = this.GetSessionChannel(request.RequestMessage, out this.requestInfo.Endpoint, out flag);
}
else
{
this.requestInfo.Channel = this.GetDatagramChannel(request.RequestMessage, out this.requestInfo.Endpoint, out flag);
}
if (this.requestInfo.Channel == null)
{
this.host.RaiseUnknownMessageReceived(request.RequestMessage);
if (flag)
{
this.ReplyContractFilterDidNotMatch(request);
}
else
{
this.ReplyAddressFilterDidNotMatch(request);
}
}
}
else
{
this.requestInfo.Endpoint = this.requestInfo.Channel.EndpointDispatcher;
if ((this.InstanceContextServiceThrottle != null) && (this.requestInfo.Channel.InstanceContextServiceThrottle == null))
{
this.requestInfo.Channel.InstanceContextServiceThrottle = this.InstanceContextServiceThrottle;
}
}
this.requestInfo.EndpointLookupDone = true;
if (this.requestInfo.Channel == null)
{
TraceUtility.TraceDroppedMessage(request.RequestMessage, this.requestInfo.Endpoint);
request.Close();
}
else if (this.requestInfo.Channel.HasSession || this.isCallback)
{
this.requestInfo.DispatchRuntime = this.requestInfo.Channel.DispatchRuntime;
}
else
{
this.requestInfo.DispatchRuntime = this.requestInfo.Endpoint.DispatchRuntime;
}
}
示例15: TryRetrievingInstanceContext
private bool TryRetrievingInstanceContext(RequestContext request)
{
bool flag = true;
try
{
if (!this.requestInfo.EndpointLookupDone)
{
this.EnsureChannelAndEndpoint(request);
}
if (this.requestInfo.Channel != null)
{
if (this.requestInfo.DispatchRuntime != null)
{
IContextChannel proxy = this.requestInfo.Channel.Proxy as IContextChannel;
try
{
this.requestInfo.ExistingInstanceContext = this.requestInfo.DispatchRuntime.InstanceContextProvider.GetExistingInstanceContext(request.RequestMessage, proxy);
flag = false;
goto Label_00F2;
}
catch (Exception exception)
{
if (Fx.IsFatal(exception))
{
throw;
}
this.requestInfo.Channel = null;
this.HandleError(exception, request, this.channel);
return false;
}
}
TraceUtility.TraceDroppedMessage(request.RequestMessage, this.requestInfo.Endpoint);
request.Close();
}
return false;
}
catch (Exception exception2)
{
if (Fx.IsFatal(exception2))
{
throw;
}
this.HandleError(exception2, request, this.channel);
return false;
}
finally
{
if (flag)
{
this.ReleasePump();
}
}
Label_00F2:
return true;
}