当前位置: 首页>>代码示例>>C#>>正文


C# StringTable.ToArray方法代码示例

本文整理汇总了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."));
            }
        }
开发者ID:OPCFoundation,项目名称:Misc-Tools,代码行数:51,代码来源:TcpServerChannel.cs

示例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;
        }
开发者ID:OPCFoundation,项目名称:UA-.NETStandardLibrary,代码行数:21,代码来源:StandardServer.cs

示例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");
            }
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:37,代码来源:ComAeProxy.cs

示例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;
		}
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:79,代码来源:BinaryEncodingMessageFormatter.cs


注:本文中的StringTable.ToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。