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


C# OutputStream.Write方法代码示例

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


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

示例1: WriteMultipleData_OneFramePerWrite

        public void WriteMultipleData_OneFramePerWrite()
        {
            using (Stream transport = new QueueStream())
            using (WriteQueue queue = new WriteQueue(transport))
            {
                Task pumpTask = queue.PumpToStreamAsync();
                Stream output = new OutputStream(1, Framing.Priority.Pri1, queue);
                FrameReader reader = new FrameReader(transport, false, CancellationToken.None);

                int dataLength = 100;
                output.Write(new byte[dataLength], 0, dataLength);
                output.Write(new byte[dataLength * 2], 0, dataLength * 2);
                output.Write(new byte[dataLength * 3], 0, dataLength * 3);

                Frame frame = reader.ReadFrameAsync().Result;
                Assert.False(frame.IsControl);
                Assert.Equal(dataLength, frame.FrameLength);

                frame = reader.ReadFrameAsync().Result;
                Assert.False(frame.IsControl);
                Assert.Equal(dataLength * 2, frame.FrameLength);

                frame = reader.ReadFrameAsync().Result;
                Assert.False(frame.IsControl);
                Assert.Equal(dataLength * 3, frame.FrameLength);
            }
        }
开发者ID:Tratcher,项目名称:HTTP-SPEED-PLUS-MOBILITY,代码行数:27,代码来源:OutputStreamTests.cs

示例2: CopyStream

 public static void CopyStream(Stream inputStream, OutputStream os)
 {
     int buffer_size = 1024;
     try {
         byte[] bytes = new byte[buffer_size];
         for (;;) {
             int count = inputStream.Read (bytes, 0, buffer_size);
             if (count <= 0)
                 break;
             os.Write (bytes, 0, count);
         }
     } catch (Exception ex) {
     }
 }
开发者ID:MammothAU,项目名称:TwinTechsFormsLib,代码行数:14,代码来源:ImageLoader.cs

示例3: onSerialize

 public override void onSerialize(OutputStream stream)
 {
     string json = JsonHelper.ToJson<MyOutput>(this);
     byte[] data = Encoding.Default.GetBytes(json);
     stream.Write(data, 0, data.Length);
     stream.Flush();
 }
开发者ID:coolmay,项目名称:HPCSOA,代码行数:7,代码来源:MyOutput.cs

示例4: InternalSendMessage

        private Stream InternalSendMessage(Message message)
        {
            if(!IsAlive)
                throw new RemotingException("TCP error: Connection closed!");

            writer.Write(magic);
            writer.Write(Version);
            writer.Write((byte)message.Type);

            writer.Write(ThisMachineID.ToByteArray());
            writer.Write(message.ID.ToByteArray());

            foreach(DictionaryEntry entry in message.Headers)
            {
                writer.Write((string)entry.Key);
                writer.Write((string)entry.Value);
            }
            writer.Write("");
            Stream outStream = new OutputStream(this);
            if(message.Stream != null)
            {
                MemoryStream ms = message.Stream as MemoryStream;
                if(ms != null)
                    try
                    {
                        outStream.Write(ms.GetBuffer(), 0, (int)ms.Length);
                    }
                    catch(UnauthorizedAccessException)
                    {
                        ms = null;
                    }
                if(ms == null)
                {
                    byte[] buffer = new byte[DefaultBufferSize];
                    while(true)
                    {
                        int read = message.Stream.Read(buffer, 0, buffer.Length);
                        if(read == 0)
                            break;
                        outStream.Write(buffer, 0, read);
                    }
                }
                outStream.Close();
                return null;
            }
            return outStream;
        }
开发者ID:sciaopin,项目名称:bang-sharp,代码行数:47,代码来源:TcpConnection.cs

示例5: _get

        ///tamir: updated to jcsh-0.1.30
        private void _get(String src, OutputStream dst, SftpProgressMonitor monitor, int mode, long skip)
        {
            try
            {
                sendOPENR(src.GetBytes());

                Header _header = new Header();
                _header = header(buf, _header);
                int length = _header.length;
                int type = _header.type;

                buf.rewind();

                fill(buf.buffer, 0, length);

                if (type != SSH_FXP_STATUS && type != SSH_FXP_HANDLE)
                {
                    throw new SftpException(SSH_FX_FAILURE, "Type is " + type);
                }

                if (type == SSH_FXP_STATUS)
                {
                    int i = buf.getInt();
                    throwStatusError(buf, i);
                }

                byte[] handle = buf.getString(); // filename

                long offset = 0;
                if (mode == RESUME)
                {
                    offset += skip;
                }

                int request_len = 0;

                while (true)
                {
                    request_len = buf.buffer.Length - 13;
                    if (server_version == 0)
                    {
                        request_len = 1024;
                    }
                    sendREAD(handle, offset, request_len);

                    _header = header(buf, _header);
                    length = _header.length;
                    type = _header.type;

                    int i;
                    if (type == SSH_FXP_STATUS)
                    {
                        buf.rewind();
                        fill(buf.buffer, 0, length);
                        i = buf.getInt();
                        if (i == SSH_FX_EOF)
                        {
                            goto BREAK;
                        }
                        throwStatusError(buf, i);
                    }

                    if (type != SSH_FXP_DATA)
                    {
                        goto BREAK;
                    }

                    buf.rewind();
                    fill(buf.buffer, 0, 4);
                    length -= 4;
                    i = buf.getInt(); // length of data
                    int foo = i;
                    while (foo > 0)
                    {
                        int bar = foo;
                        if (bar > buf.buffer.Length)
                        {
                            bar = buf.buffer.Length;
                        }
                        i = io.ins.read(buf.buffer, 0, bar);
                        if (i < 0)
                        {
                            goto BREAK;
                        }
                        int data_len = i;
                        dst.Write(buf.buffer, 0, data_len);

                        offset += data_len;
                        foo -= data_len;

                        if (monitor != null)
                        {
                            if (!monitor.count(data_len))
                            {
                                while (foo > 0)
                                {
                                    i = io.ins.read(buf.buffer,
                                                    0,
                                                    (buf.buffer.Length < foo ? buf.buffer.Length : foo));
//.........这里部分代码省略.........
开发者ID:akrisiun,项目名称:SharpSSH,代码行数:101,代码来源:ChannelSftp.cs


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