本文整理汇总了C#中IServerResponseChannelSinkStack.GetResponseStream方法的典型用法代码示例。如果您正苦于以下问题:C# IServerResponseChannelSinkStack.GetResponseStream方法的具体用法?C# IServerResponseChannelSinkStack.GetResponseStream怎么用?C# IServerResponseChannelSinkStack.GetResponseStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServerResponseChannelSinkStack
的用法示例。
在下文中一共展示了IServerResponseChannelSinkStack.GetResponseStream方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AsyncProcessResponse
public void AsyncProcessResponse (IServerResponseChannelSinkStack sinkStack, object state,
IMessage message, ITransportHeaders headers, Stream stream)
{
ITransportHeaders responseHeaders = new TransportHeaders();
if (sinkStack != null) stream = sinkStack.GetResponseStream (message, responseHeaders);
if (stream == null) stream = new MemoryStream();
_binaryCore.Serializer.Serialize (stream, message, null);
if (stream is MemoryStream) stream.Position = 0;
sinkStack.AsyncProcessResponse (message, responseHeaders, stream);
}
示例2: SerializeResponse
private void SerializeResponse(IServerResponseChannelSinkStack sinkStack,
IMessage msg, ref ITransportHeaders headers,
out Stream stream)
{
BaseTransportHeaders responseHeaders = new BaseTransportHeaders();
if (headers != null)
{
// copy old headers into new headers
foreach (DictionaryEntry entry in headers)
{
responseHeaders[entry.Key] = entry.Value;
}
}
headers = responseHeaders;
if (_protocol == Protocol.Http)
{
responseHeaders.ContentType = CoreChannel.BinaryMimeType;
}
bool bMemStream = false;
stream = sinkStack.GetResponseStream(msg, headers);
if (stream == null)
{
stream = new ChunkedMemoryStream(CoreChannel.BufferPool);
bMemStream = true;
}
bool bBashUrl = CoreChannel.SetupUrlBashingForIisSslIfNecessary();
try
{
CallContext.SetData("__ClientIsClr", true);
CoreChannel.SerializeBinaryMessage(msg, stream, _includeVersioning);
}
finally
{
CallContext.FreeNamedDataSlot("__ClientIsClr");
CoreChannel.CleanupUrlBashingForIisSslIfNecessary(bBashUrl);
}
if (bMemStream)
stream.Position = 0;
} // SerializeResponse
示例3: AsyncProcessResponse
public void AsyncProcessResponse (IServerResponseChannelSinkStack sinkStack, object state,
IMessage msg, ITransportHeaders headers, Stream stream)
{
ITransportHeaders responseHeaders = new TransportHeaders();
if(sinkStack != null) stream = sinkStack.GetResponseStream(msg, responseHeaders);
if(stream == null) stream = new MemoryStream();
SoapMessageFormatter soapMsgFormatter = (SoapMessageFormatter)state;
SoapMessage soapMessage = (SoapMessage) soapMsgFormatter.BuildSoapMessageFromMethodResponse((IMethodReturnMessage)msg, out responseHeaders);
_soapCore.Serializer.Serialize(stream, soapMessage, null);
if(stream is MemoryStream) stream.Position = 0;
sinkStack.AsyncProcessResponse (msg, responseHeaders, stream);
}
示例4: GenerateSdl
//.........这里部分代码省略.........
(String.Compare(objectUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0))
throw new RemotingException(CoreChannel.GetResourceString("Remoting_RemoteApplicationMetadataNotEnabled"));
// If the host header is present, we will use this in the generated uri's
String hostName = (String)requestHeaders["Host"];
if (hostName != null)
{
// filter out port number if present
int index = hostName.IndexOf(':');
if (index != -1)
hostName = hostName.Substring(0, index);
}
ServiceType[] types = null;
if (String.Compare(objectUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0)
{
// get the service description for all registered service types
ActivatedServiceTypeEntry[] activatedTypes =
RemotingConfiguration.GetRegisteredActivatedServiceTypes();
WellKnownServiceTypeEntry[] wellKnownTypes =
RemotingConfiguration.GetRegisteredWellKnownServiceTypes();
// determine total number of types
int typeCount = 0;
if (activatedTypes != null)
typeCount += activatedTypes.Length;
if (wellKnownTypes != null)
typeCount += wellKnownTypes.Length;
types = new ServiceType[typeCount];
// collect data
int co = 0;
if (activatedTypes != null)
{
foreach (ActivatedServiceTypeEntry entry in activatedTypes)
{
types[co++] = new ServiceType(entry.ObjectType, null);
}
}
if (wellKnownTypes != null)
{
foreach (WellKnownServiceTypeEntry entry in wellKnownTypes)
{
String[] urls = _receiver.GetUrlsForUri(entry.ObjectUri);
String url = urls[0];
if (hostName != null)
url = HttpChannelHelper.ReplaceMachineNameWithThisString(url, hostName);
types[co++] = new ServiceType(entry.ObjectType, url);
}
}
InternalRemotingServices.RemotingAssert(co == typeCount, "Not all types were processed.");
}
else
{
// get the service description for a particular object
Type objectType = RemotingServices.GetServerTypeForUri(objectUri);
if (objectType == null)
{
throw new RemotingException(
String.Format(
CultureInfo.CurrentCulture, "Object with uri '{0}' does not exist at server.",
objectUri));
}
String[] urls = _receiver.GetUrlsForUri(objectUri);
String url = urls[0];
if (hostName != null)
url = HttpChannelHelper.ReplaceMachineNameWithThisString(url, hostName);
types = new ServiceType[1];
types[0] = new ServiceType(objectType, url);
}
responseHeaders["Content-Type"] = "text/xml";
bool bMemStream = false;
outputStream = sinkStack.GetResponseStream(null, responseHeaders);
if (outputStream == null)
{
outputStream = new MemoryStream(1024);
bMemStream = true;
}
MetaData.ConvertTypesToSchemaToStream(types, sdlType, outputStream);
if (bMemStream)
outputStream.Position = 0;
} // GenerateXmlForUri
示例5: SerializeResponse
private void SerializeResponse(IServerResponseChannelSinkStack sinkStack,
IMessage msg, bool bClientIsClr, ref ITransportHeaders headers,
out Stream stream)
{
BaseTransportHeaders responseHeaders = new BaseTransportHeaders();
if (headers != null)
{
// copy old headers into new headers
foreach (DictionaryEntry entry in headers)
{
responseHeaders[entry.Key] = entry.Value;
}
}
headers = responseHeaders;
responseHeaders.ContentType = CoreChannel.SOAPContentType;
if (_protocol == Protocol.Http)
{
// check to see if an exception occurred (requires special status code for HTTP)
IMethodReturnMessage mrm = msg as IMethodReturnMessage;
if ((mrm != null) && (mrm.Exception != null))
{
headers["__HttpStatusCode"] = "500";
headers["__HttpReasonPhrase"] = "Internal Server Error";
}
}
bool bMemStream = false;
stream = sinkStack.GetResponseStream(msg, headers);
if (stream == null)
{
stream = new ChunkedMemoryStream(CoreChannel.BufferPool);
bMemStream = true;
}
bool bBashUrl = CoreChannel.SetupUrlBashingForIisSslIfNecessary();
CallContext.SetData("__ClientIsClr", bClientIsClr);
try
{
CoreChannel.SerializeSoapMessage(msg, stream, _includeVersioning);
}
finally
{
CallContext.FreeNamedDataSlot("__ClientIsClr");
CoreChannel.CleanupUrlBashingForIisSslIfNecessary(bBashUrl);
}
if (bMemStream)
stream.Position = 0;
} // SerializeResponse
示例6:
System.IO.Stream IServerChannelSink.GetResponseStream(IServerResponseChannelSinkStack sinkStack, object state, IMessage msg, ITransportHeaders headers)
{
return sinkStack.GetResponseStream(msg, headers);
}
示例7: SerializeResponse
private void SerializeResponse(IServerResponseChannelSinkStack sinkStack, IMessage msg, bool bClientIsClr, ref ITransportHeaders headers, out Stream stream)
{
BaseTransportHeaders headers2 = new BaseTransportHeaders();
if (headers != null)
{
foreach (DictionaryEntry entry in headers)
{
headers2[entry.Key] = entry.Value;
}
}
headers = headers2;
headers2.ContentType = "text/xml; charset=\"utf-8\"";
if (this._protocol == Protocol.Http)
{
IMethodReturnMessage message = msg as IMethodReturnMessage;
if ((message != null) && (message.Exception != null))
{
headers["__HttpStatusCode"] = "500";
headers["__HttpReasonPhrase"] = "Internal Server Error";
}
}
bool flag = false;
stream = sinkStack.GetResponseStream(msg, headers);
if (stream == null)
{
stream = new ChunkedMemoryStream(CoreChannel.BufferPool);
flag = true;
}
bool bBashedUrl = CoreChannel.SetupUrlBashingForIisSslIfNecessary();
CallContext.SetData("__ClientIsClr", bClientIsClr);
try
{
CoreChannel.SerializeSoapMessage(msg, stream, this._includeVersioning);
}
finally
{
CallContext.FreeNamedDataSlot("__ClientIsClr");
CoreChannel.CleanupUrlBashingForIisSslIfNecessary(bBashedUrl);
}
if (flag)
{
stream.Position = 0L;
}
}
示例8: SerializeResponseMessage
private static void SerializeResponseMessage(IServerResponseChannelSinkStack sinkStack
, IMessage responseMsg
, ref ITransportHeaders responseHeaders
, ref Stream responseStream)
{
if (sinkStack == null)
throw new ArgumentNullException("sinkStack");
if (responseMsg == null)
throw new ArgumentNullException("responseMsg");
var methodReturnMessage = responseMsg as IMethodReturnMessage;
if (methodReturnMessage == null)
throw new ArgumentException(string.Format(
"Invalid response message type: '{0}'.", responseMsg.GetType()), "responseMsg");
if (responseHeaders == null)
responseHeaders = new TransportHeaders();
bool shouldRewindStream = false;
if (responseStream == null)
{
responseStream = sinkStack.GetResponseStream(responseMsg, responseHeaders);
if (responseStream == null)
{
responseStream = new MemoryStream();
shouldRewindStream = true;
}
}
byte[] data = _serializer.SerializeMethodReturn(new MethodReturn()
{
Exception = methodReturnMessage.Exception,
ReturnValue = methodReturnMessage.ReturnValue
});
responseStream.Write(data, 0, data.Length);
if (shouldRewindStream)
{
responseStream.Position = 0;
}
}
示例9: SerializeResponse
private void SerializeResponse(IServerResponseChannelSinkStack sinkStack, IMessage msg, ref ITransportHeaders headers, out Stream stream)
{
BaseTransportHeaders headers2 = new BaseTransportHeaders();
if (headers != null)
{
foreach (DictionaryEntry entry in headers)
{
headers2[entry.Key] = entry.Value;
}
}
headers = headers2;
if (this._protocol == Protocol.Http)
{
headers2.ContentType = "application/octet-stream";
}
bool flag = false;
stream = sinkStack.GetResponseStream(msg, headers);
if (stream == null)
{
stream = new ChunkedMemoryStream(CoreChannel.BufferPool);
flag = true;
}
bool bBashedUrl = CoreChannel.SetupUrlBashingForIisSslIfNecessary();
try
{
CallContext.SetData("__ClientIsClr", true);
CoreChannel.SerializeBinaryMessage(msg, stream, this._includeVersioning);
}
finally
{
CallContext.FreeNamedDataSlot("__ClientIsClr");
CoreChannel.CleanupUrlBashingForIisSslIfNecessary(bBashedUrl);
}
if (flag)
{
stream.Position = 0L;
}
}
示例10: GetResponseStreamFor
private Stream GetResponseStreamFor(IServerResponseChannelSinkStack sinkStack,
IMessage responseMsg, ITransportHeaders headers) {
Stream stream = sinkStack.GetResponseStream(responseMsg, headers);
if (stream == null) {
// the previous stream-handling sinks delegated the decision to which stream the message should be serialised to this sink
stream = new MemoryStream(); // create a new stream
}
return stream;
}
示例11: SerializeResponseMessage
private static void SerializeResponseMessage(IServerResponseChannelSinkStack sinkStack
, IMessage responseMsg
, ref ITransportHeaders responseHeaders
, ref Stream responseStream)
{
if (sinkStack == null)
throw new ArgumentNullException("sinkStack");
if (responseMsg == null)
throw new ArgumentNullException("responseMsg");
var methodReturnMessage = responseMsg as IMethodReturnMessage;
if (methodReturnMessage == null)
throw new ArgumentException(string.Format(
"Invalid response message type: '{0}'.", responseMsg.GetType()), "responseMsg");
if (responseHeaders == null)
responseHeaders = new TransportHeaders();
bool shouldRewindStream = false;
if (responseStream == null)
{
responseStream = sinkStack.GetResponseStream(responseMsg, responseHeaders);
if (responseStream == null)
{
responseStream = new MemoryStream();
shouldRewindStream = true;
}
}
var m = new JsonMessage();
m.Return = methodReturnMessage.ReturnValue;
m.Exception = methodReturnMessage.Exception;
JSONSerializer.Serialize(responseStream, m, typeof(JsonMessage));
if (shouldRewindStream)
{
responseStream.Position = 0;
}
}
示例12: GenerateSdl
private void GenerateSdl(SdlType sdlType, IServerResponseChannelSinkStack sinkStack, ITransportHeaders requestHeaders, ITransportHeaders responseHeaders, out Stream outputStream)
{
if (!this.MetadataEnabled)
{
throw new RemotingException(CoreChannel.GetResourceString("Remoting_MetadataNotEnabled"));
}
string uri = requestHeaders["__RequestUri"] as string;
string objectUriFromRequestUri = HttpChannelHelper.GetObjectUriFromRequestUri(uri);
if (!this.RemoteApplicationMetadataEnabled && (string.Compare(objectUriFromRequestUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0))
{
throw new RemotingException(CoreChannel.GetResourceString("Remoting_RemoteApplicationMetadataNotEnabled"));
}
string hostName = (string) requestHeaders["Host"];
if (hostName != null)
{
int index = hostName.IndexOf(':');
if (index != -1)
{
hostName = hostName.Substring(0, index);
}
}
string channelUri = SetupUrlBashingForIisIfNecessary(hostName);
ServiceType[] serviceTypes = null;
if (string.Compare(objectUriFromRequestUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0)
{
ActivatedServiceTypeEntry[] registeredActivatedServiceTypes = RemotingConfiguration.GetRegisteredActivatedServiceTypes();
WellKnownServiceTypeEntry[] registeredWellKnownServiceTypes = RemotingConfiguration.GetRegisteredWellKnownServiceTypes();
int num2 = 0;
if (registeredActivatedServiceTypes != null)
{
num2 += registeredActivatedServiceTypes.Length;
}
if (registeredWellKnownServiceTypes != null)
{
num2 += registeredWellKnownServiceTypes.Length;
}
serviceTypes = new ServiceType[num2];
int num3 = 0;
if (registeredActivatedServiceTypes != null)
{
foreach (ActivatedServiceTypeEntry entry in registeredActivatedServiceTypes)
{
serviceTypes[num3++] = new ServiceType(entry.ObjectType, null);
}
}
if (registeredWellKnownServiceTypes != null)
{
foreach (WellKnownServiceTypeEntry entry2 in registeredWellKnownServiceTypes)
{
string url = this._receiver.GetUrlsForUri(entry2.ObjectUri)[0];
if (channelUri != null)
{
url = HttpChannelHelper.ReplaceChannelUriWithThisString(url, channelUri);
}
else if (hostName != null)
{
url = HttpChannelHelper.ReplaceMachineNameWithThisString(url, hostName);
}
serviceTypes[num3++] = new ServiceType(entry2.ObjectType, url);
}
}
}
else
{
Type serverTypeForUri = RemotingServices.GetServerTypeForUri(objectUriFromRequestUri);
if (serverTypeForUri == null)
{
throw new RemotingException(string.Format(CultureInfo.CurrentCulture, "Object with uri '{0}' does not exist at server.", new object[] { objectUriFromRequestUri }));
}
string str6 = this._receiver.GetUrlsForUri(objectUriFromRequestUri)[0];
if (channelUri != null)
{
str6 = HttpChannelHelper.ReplaceChannelUriWithThisString(str6, channelUri);
}
else if (hostName != null)
{
str6 = HttpChannelHelper.ReplaceMachineNameWithThisString(str6, hostName);
}
serviceTypes = new ServiceType[] { new ServiceType(serverTypeForUri, str6) };
}
responseHeaders["Content-Type"] = "text/xml";
bool flag = false;
outputStream = sinkStack.GetResponseStream(null, responseHeaders);
if (outputStream == null)
{
outputStream = new MemoryStream(0x400);
flag = true;
}
MetaData.ConvertTypesToSchemaToStream(serviceTypes, sdlType, outputStream);
if (flag)
{
outputStream.Position = 0L;
}
}