本文整理汇总了C#中StringTable.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# StringTable.ToArray方法的具体用法?C# StringTable.ToArray怎么用?C# StringTable.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringTable
的用法示例。
在下文中一共展示了StringTable.ToArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendServiceFault
/// <summary>
/// Sends a fault response secured with the asymmetric keys.
/// </summary>
private void SendServiceFault(uint requestId, ServiceResult fault)
{
// Utils.Trace("Channel {0} Request {1}: SendServiceFault()", ChannelId, requestId);
BufferCollection chunksToSend = null;
try
{
// construct fault.
ServiceFault response = new ServiceFault();
response.ResponseHeader.ServiceResult = fault.Code;
StringTable stringTable = new StringTable();
response.ResponseHeader.ServiceDiagnostics = new DiagnosticInfo(
fault,
DiagnosticsMasks.NoInnerStatus,
true,
stringTable);
response.ResponseHeader.StringTable = stringTable.ToArray();
// serialize fault.
byte[] buffer = BinaryEncoder.EncodeMessage(response, Quotas.MessageContext);
// secure message.
chunksToSend = WriteAsymmetricMessage(
TcpMessageType.Open,
requestId,
ServerCertificate,
ClientCertificate,
new ArraySegment<byte>(buffer, 0, buffer.Length));
// write the message to the server.
BeginWriteMessage(chunksToSend, Int32.MaxValue, null);
chunksToSend = null;
}
catch (Exception e)
{
if (chunksToSend != null)
{
chunksToSend.Release(BufferManager, "SendServiceFault");
}
ForceChannelFault(ServiceResult.Create(e, StatusCodes.BadTcpInternalError, "Unexpected error sending a service fault."));
}
}
示例2: CreateResponse
/// <summary>
/// Creates the response header.
/// </summary>
/// <param name="requestHeader">The object that contains description for the RequestHeader DataType.</param>
/// <param name="exception">The exception used to create DiagnosticInfo assigned to the ServiceDiagnostics.</param>
/// <returns>Returns a description for the ResponseHeader DataType. </returns>
protected ResponseHeader CreateResponse(RequestHeader requestHeader, ServiceResultException exception)
{
ResponseHeader responseHeader = new ResponseHeader();
responseHeader.ServiceResult = exception.StatusCode;
responseHeader.Timestamp = DateTime.UtcNow;
responseHeader.RequestHandle = requestHeader.RequestHandle;
StringTable stringTable = new StringTable();
responseHeader.ServiceDiagnostics = new DiagnosticInfo(exception, (DiagnosticsMasks)requestHeader.ReturnDiagnostics, true, stringTable);
responseHeader.StringTable = stringTable.ToArray();
return responseHeader;
}
示例3: GenerateNamespaceIndexMappings
/// <summary>
/// compares the new server namespace table with the (saved) table known to the client. Provides a
/// mapping for any namespaces which are new or removed and indices which have changed.
/// </summary>
/// <param name="clsid"></param>
private void GenerateNamespaceIndexMappings(Guid clsid)
{
try
{
StringTable savedStringTable = new StringTable();
for (int i = 0; i < m_configFile.SavedNamespaceTable.Length; i++)
savedStringTable.Append(m_configFile.SavedNamespaceTable[i]);
NamespaceTable serverNamespaceTable = m_session.NamespaceUris;
string[] serverNamespaceArray = serverNamespaceTable.ToArray();
for (int i = 0; i < serverNamespaceArray.Length; i++)
{
// Generate the serverIndex->clientIndex mapping table. Update the client namespace
// table in the process if new namespaces have been added to the server namespace
m_serverMappingTable.Add(savedStringTable.GetIndexOrAppend(serverNamespaceArray[i]));
}
m_configFile.SavedNamespaceTable = savedStringTable.ToArray();
for (int i = 0; i < m_configFile.SavedNamespaceTable.Length; i++)
{
// Generate the clientIndex->serverIndex mapping table
m_clientmappingTable.Add(serverNamespaceTable.GetIndex(m_configFile.SavedNamespaceTable[i]));
}
}
catch (Exception e)
{
Utils.Trace(e, "Unexpected error in InitNamespaceMappingTable");
}
}
示例4: AfterReceiveReply
/// <summary cref="IClientMessageInspector.AfterReceiveReply" />
public void AfterReceiveReply(ref System.ServiceModel.Channels.Message reply, object correlationState)
{
// check for fault.
if (reply.IsFault)
{
return;
}
// parse request parameters.
object[] parameters = correlationState as object[];
if (parameters == null || parameters.Length != 3)
{
throw new InvalidOperationException("Cannot decode request because the IClientMessageInspector not configured properly.");
}
// extract request parameters.
MessageVersion messageVersion = parameters[0] as MessageVersion;
string action = parameters[1] as string;
IServiceMessage request = parameters[2] as IServiceMessage;
object encodeable = null;
if (!reply.Properties.TryGetValue(MessageProperties.UnencodedBody, out encodeable))
{
// extract binary encoded response from body.
XmlDictionaryReader reader = reply.GetReaderAtBodyContents();
reader.MoveToStartElement("InvokeServiceResponse", Namespaces.OpcUaXsd);
byte[] response = reader.ReadElementContentAsBase64();
// decode body.
try
{
encodeable = BinaryDecoder.DecodeMessage(response, null, m_messageContext);
}
catch (Exception e)
{
ServiceResult error = ServiceResult.Create(
e,
StatusCodes.BadDecodingError,
"Could not decoding incoming response message.");
ServiceFault fault = new ServiceFault();
fault.ResponseHeader.RequestHandle = request.GetRequest().RequestHeader.RequestHandle;
fault.ResponseHeader.Timestamp = DateTime.UtcNow;
fault.ResponseHeader.ServiceResult = error.Code;
StringTable stringTable = new StringTable();
fault.ResponseHeader.ServiceDiagnostics = new DiagnosticInfo(
error,
DiagnosticsMasks.NoInnerStatus,
true,
stringTable);
fault.ResponseHeader.StringTable = stringTable.ToArray();
encodeable = fault;
}
}
object unencodedBody = request.CreateResponse((IServiceResponse)encodeable);
// create the unencoded reply message.
Message unencodedReply = Message.CreateMessage(
messageVersion,
action + "Response",
unencodedBody);
unencodedReply.Headers.MessageId = reply.Headers.MessageId;
unencodedReply.Headers.RelatesTo = reply.Headers.RelatesTo;
unencodedReply.Properties.Add(MessageProperties.UnencodedBody, unencodedBody);
// replace the incoming message.
reply = unencodedReply;
}