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


C# DataFrame.ToArray方法代码示例

本文整理汇总了C#中DataFrame.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# DataFrame.ToArray方法的具体用法?C# DataFrame.ToArray怎么用?C# DataFrame.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataFrame的用法示例。


在下文中一共展示了DataFrame.ToArray方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Write

 /// <summary>
 /// Write a frame to the adapter
 /// </summary>
 /// <param name="frame">The frame</param>
 public override void Write(DataFrame frame)
 {
     if (frame != null)
     {
         _listener.Write(frame.ToArray(), _ep);
     }
 }
开发者ID:michyer,项目名称:canape,代码行数:11,代码来源:UdpServerDataAdapter.cs

示例2: ConvertBinaryPacketToString

        /// <summary>
        /// Convert a packet to a hex string format
        /// </summary>
        /// <param name="p">The packet to convert</param>
        /// <returns>The converted string</returns>
        public static string ConvertBinaryPacketToString(DataFrame p)
        {
            using (TextWriter writer = new StringWriter())
            {
                writer.WriteLine(GeneralUtils.BuildHexDump(16, p.ToArray()));
                writer.WriteLine();

                return writer.ToString();
            }
        }
开发者ID:michyer,项目名称:canape,代码行数:15,代码来源:ConsoleUtils.cs

示例3: XorFrame

    DataFrame XorFrame(DataFrame frame, byte xorValue)
    {
        byte[] data = frame.ToArray();

        for(int i = 0; i < data.Length; ++i)
        {
            data[i] = (byte)(data[i] ^ xorValue);
        }

        return new DataFrame(data);
    }
开发者ID:michyer,项目名称:canape,代码行数:11,代码来源:xorlayer.cs

示例4: Write

 /// <summary>
 /// Perform write
 /// </summary>
 /// <param name="frame"></param>
 public override void Write(DataFrame frame)
 {
     try
     {
         byte[] data = frame.ToArray();
         _stream.Write(data, 0, data.Length);
     }
     catch(Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.ToString());
     }
 }
开发者ID:michyer,项目名称:canape,代码行数:16,代码来源:StreamDataAdapter.cs

示例5: OnLogPacket

        /// <summary>
        /// Log a packet from the graph
        /// </summary>
        /// <param name="tag">A textual tag for the frame</param>
        /// <param name="color">The color to display the frame (if applicable)</param>
        /// <param name="frame">The frame to log, note this must be cloned to preserve its value</param>
        /// <param name="logAsBytes">Indicates whether the packet should be logged as a byte array</param>
        /// <param name="path">Selection path for which part of the packet to log</param>
        private void OnLogPacket(string tag, ColorValue color, DataFrame frame, bool logAsBytes, string path)
        {
            EventHandler<LogPacketEventArgs> logPacketEvent = LogPacketEvent;

            if (logPacketEvent != null)
            {
                DataFrame logFrame = null;
                if (path != "/")
                {
                    DataNode node = frame.SelectSingleNode(path);

                    if (node != null)
                    {
                        node = node.CloneNode();

                        DataKey key = node as DataKey;
                        if (key != null)
                        {
                            logFrame = new DataFrame(key);
                        }
                        else
                        {
                            logFrame = new DataFrame();
                            logFrame.Root.AddSubNode(node);
                        }

                        if (logAsBytes)
                        {
                            logFrame.ConvertToBasic();
                        }
                    }
                }
                else
                {
                    logFrame = logAsBytes ? new DataFrame(frame.ToArray()) : frame.CloneFrame();
                }

                if (logFrame != null)
                {
                    logPacketEvent(this, new LogPacketEventArgs(tag, Uuid, logFrame, color, NetworkDescription));
                }
            }
        }
开发者ID:michyer,项目名称:canape,代码行数:51,代码来源:NetGraph.cs

示例6: Write

 /// <summary>
 /// Write a data frame to the client
 /// </summary>
 /// <param name="frame">The frame to write</param>
 public override void Write(DataFrame frame)
 {
     if (frame != null)
     {
         byte[] data = frame.ToArray();
         _client.Send(data, data.Length);
     }
 }
开发者ID:michyer,项目名称:canape,代码行数:12,代码来源:UdpClientDataAdapter.cs

示例7: OnInput

        /// <summary>
        /// Override function called when a packet is input
        /// </summary>
        /// <param name="frame"></param>
        protected override void OnInput(DataFrame frame)
        {
            try
            {
                _input.Enqueue(frame.ToArray());
            }
            catch (InvalidOperationException)
            { }
            catch (OperationCanceledException)
            { }

            EnsureThreadRunning();
        }
开发者ID:michyer,项目名称:canape,代码行数:17,代码来源:BaseStreamPipelineNode.cs

示例8: Write

            public override void Write(DataFrame frame)
            {
                if (!_isTransparent)
                {
                    DataKey rootKey = frame.Root;

                    if (rootKey.Class == typeof(HttpRequestDataChunk).GUID)
                    {
                        HttpRequestDataChunk chunk = ObjectConverter.FromNode<HttpRequestDataChunk>(rootKey);

                        // Enqueue the first chunk as a request
                        if (chunk.ChunkNumber == 0)
                        {
                            lock (_requests)
                            {
                                _requests.Enqueue(chunk.ToHeader());
                            }
                        }

                        _adapter.Write(frame);
                    }
                    else
                    {
                        // If we can't use pre-parsed then queue the data up
                        byte[] data = frame.ToArray();

                        lock (_requestStream)
                        {
                            _requestStream.Position = _requestStream.Length;

                            _requestStream.Write(data, 0, data.Length);
                        }

                        _adapter.Write(frame);
                    }
                }
                else
                {
                    // In transparent mode just pass along
                    _adapter.Write(frame);
                }
            }
开发者ID:michyer,项目名称:canape,代码行数:42,代码来源:HttpNetworkLayer.cs

示例9: Write

 public override void Write(DataFrame data)
 {
     _writer.Write(data.ToArray());
 }
开发者ID:michyer,项目名称:canape,代码行数:4,代码来源:ReverseHttpProxyServer.cs

示例10: CreateFilter

        /// <summary>
        /// Create a list of filters for a data frame
        /// </summary>
        /// <param name="frame">The data frame</param>
        /// <returns>The list of filters</returns>
        public static IEnumerable<DataFrameFilterFactory> CreateFilter(DataFrame frame)
        {
            if (frame.IsBasic)
            {
                BinaryDataFrameFilterFactory filter = new BinaryDataFrameFilterFactory();

                filter.Match = frame.ToArray();
                filter.Path = "/";
                filter.SearchMode = DataFrameFilterSearchMode.Equals;

                return new DataFrameFilterFactory[] { filter };
            }
            else
            {
                return CreateFilter(frame.Root);
            }
        }
开发者ID:michyer,项目名称:canape,代码行数:22,代码来源:DataFrameFilterFactory.cs

示例11: Write

        /// <summary>
        /// Write to the data adapter
        /// </summary>
        /// <param name="frame">The frame to write</param>
        public void Write(DataFrame frame)
        {
            if (!fixedConnection)
            {
                string s = BinaryEncoding.Instance.GetString(frame.ToArray());
                StringReader reader = new StringReader(s);
                string header = reader.ReadLine();

                while(header != null)
                {
                    if (header.StartsWith("Connection:"))
                    {
                        s = s.Replace(header, "Connection: close");
                        fixedConnection = true;
                        break;
                    }
                    else if (header.Length == 0)
                    {
                        fixedConnection = true;
                        break;
                    }

                    header = reader.ReadLine();
                }

                frame.ConvertToBasic(s);
            }
            _adapter.Write(frame);
        }
开发者ID:michyer,项目名称:canape,代码行数:33,代码来源:FixHttpConnectionDataAdapter.cs

示例12: Write

            public override void Write(DataFrame frame)
            {
                if (_waitingForHeader)
                {
                    byte[] data = frame.ToArray();

                    // Make a heuristic decision, if the first few characters are not ASCII alpha text then
                    // something is funky, probably trying to force SSL over the connection, reconnect using
                    // CONNECT

                    _requestData.Write(data, 0, data.Length);

                    //foreach (byte b in data)
                    //{
                    //    if ((b < 32) && (b != 10) && (b != 13))
                    //    {
                    //        // This is more likely a binary protocol say SSL, reconnect using connect
                    //        _waitingForHeader = false;

                    //        IpProxyToken token = new IpProxyToken(null, _destHostname, _destPort, IpProxyToken.IpClientType.Tcp, false);

                    //        HttpProxyClient.ConnectWithIpProxyToken(base.Socket.GetStream(),
                    //            token, _logger);
                    //        if (token.Status != NetStatusCodes.Success)
                    //        {
                    //            throw new NetServiceException(Properties.Resources.HttpProxyClient_ErrorReconnecting);
                    //        }

                    //        base.Write(new DataFrame(_requestData.ToArray()));
                    //        _requestData = null;
                    //        break;
                    //    }
                    //}

                    string headers = BinaryEncoding.Instance.GetString(_requestData.ToArray());

                    int nlIndex = headers.IndexOf('\n');

                    if(nlIndex >= 0)
                    {
                        string[] val = headers.Substring(0, nlIndex).Split(new char[] { ' ' }, 3);

                        if(val.Length > 1)
                        {
                            if (_destPort == 80)
                            {
                                val[1] = String.Format("http://{0}{1}", _destHostname, val[1]);
                            }
                            else
                            {
                                val[1] = String.Format("http://{0}:{1}{2}", _destHostname, _destPort, val[1]);
                            }
                        }

                        _waitingForHeader = false;
                        _requestData = null;

                        base.Write(new DataFrame(String.Join(" ", val) + headers.Substring(nlIndex)));
                    }
                }
                else
                {
                    base.Write(frame);
                }
            }
开发者ID:michyer,项目名称:canape,代码行数:65,代码来源:HttpProxyClient.cs


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