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


C# Stream.WriteString方法代码示例

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


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

示例1: StreamMultiPart

        public void StreamMultiPart(Stream stream)
        {
            stream.WriteString(_boundary);

            if (_multipartFormData != null)
            {
                foreach (var entry in _multipartFormData)
                {
                    stream.WriteString(CreateFormBoundaryHeader(entry.Key, entry.Value));
                    stream.WriteString(_boundary);
                }
            }

            if (_multipartFileData != null)
            {
                foreach (var fileData in _multipartFileData)
                {
                    using (var file = new FileStream(fileData.Filename, FileMode.Open))
                    {
                        stream.WriteString(CreateFileBoundaryHeader(fileData));

                        StreamFileContents(file, fileData, stream);

                        stream.WriteString(_boundary);
                    }
                }
            }
            stream.WriteString("--");
        }
开发者ID:klkucan,项目名称:EasyHttp,代码行数:29,代码来源:MultipartStreamer.cs

示例2: SaveTo

        public virtual bool SaveTo(Stream stream)
        {
            stream.Write((uint)KeyValues.Count);
            foreach (var keyValue in KeyValues)
            {
                stream.WriteString(keyValue.Key);
                stream.WriteString(keyValue.Value);
            }

            return true;
        }
开发者ID:fjz13,项目名称:Medusa,代码行数:11,代码来源:BaseSirenAttribute.cs

示例3: RenderCommand

 public override void RenderCommand(Stream stream)
 {
     if (Blob != null)
     {
         stream.WriteString("M 644 ");
         Blob.RenderMarkReference(stream);
         stream.WriteString(string.Format(" \"{0}\"", Path));
         stream.WriteLineFeed();
     }
     else
     {
         stream.WriteLine(string.Format("M 644 inline \"{0}\"", Path));
         stream.RenderCommand(Data);
     }
 }
开发者ID:Spiralis,项目名称:tfs-fast-export,代码行数:15,代码来源:FileModifyCommand.cs

示例4: Serialize

        public void Serialize(Stream dest, Exception value)
        {
            if (dest == null)
                throw new ArgumentNullException("dest");
            if (value == null)
                throw new ArgumentNullException("value");

            var type = value.GetType();
            int typeAlias = _data.TypeTable.GetAlias(type);
            var typeSerializable = _data.MessageSerializer.CanSerialize(type);

            dest.WriteByte((byte)((typeAlias != 0 ? 1 : 0) | (typeSerializable ? 2 : 0)));

            if (typeAlias != 0)
                dest.Write32BitEncodedInt(typeAlias);
            else
                dest.WriteString(type.FullName);

            if (typeSerializable)
            {
                var lengthMarker = new StreamLengthMarker(dest, true);
                _data.MessageSerializer.Serialize(dest, value);
                lengthMarker.WriteLength(true);
            }
        }
开发者ID:SaladLab,项目名称:Akka.Interfaced.SlimSocket,代码行数:25,代码来源:ExceptionSerializer.cs

示例5: Serialize

        public void Serialize(Stream output)
        {
            if (this.Version < 1 || this.Version > 2)
            {
                throw new InvalidOperationException("unsupported blob version");
            }

            output.WriteValueU32(this.Version);
            output.WriteValueS32(this.Entries.Count);

            var nameLength = this.Version == 2 ? 32 : 14;

            foreach (var entry in this.Entries)
            {
                var name = entry.Name;

                if (name.Length + 1 > nameLength)
                {
                    throw new InvalidOperationException();
                }

                output.WriteString(name.PadRight(nameLength, '\0'));
                output.WriteValueU32((uint)entry.Offset);
                output.WriteValueU32(entry.Size);
            }
        }
开发者ID:gibbed,项目名称:Gibbed.Infantry,代码行数:26,代码来源:BlobFile.cs

示例6: RenderMarkReference

        public void RenderMarkReference(Stream stream)
        {
            if (!_HasBeenRendered)
                throw new InvalidOperationException("A MarkCommand cannot be referenced if it has not been rendered.");

            var reference = string.Format(":{0}", MarkId);
            stream.WriteString(reference);
        }
开发者ID:viceroypenguin,项目名称:tfs-fast-export,代码行数:8,代码来源:MarkCommand.cs

示例7: RenderCommand

 public override void RenderCommand(Stream stream)
 {
     stream.WriteLine(string.Format("reset {0}", Reference));
     if (From != null)
     {
         stream.WriteString("from ");
         From.RenderMarkReference(stream);
         stream.WriteLineFeed();
     }
 }
开发者ID:viceroypenguin,项目名称:tfs-fast-export,代码行数:10,代码来源:ResetCommand.cs

示例8: StreamFileContents

	    static void StreamFileContents(Stream file, FileData fileData, Stream requestStream)
        {
            var buffer = new byte[8192];

            int count;

            while ((count = file.Read(buffer, 0, buffer.Length)) > 0)
            {
                if (fileData.ContentTransferEncoding == HttpContentTransferEncoding.Base64)
                {
                    string str = Convert.ToBase64String(buffer, 0, count);

                    requestStream.WriteString(str);
                }
                else if (fileData.ContentTransferEncoding == HttpContentTransferEncoding.Binary)
                {
                    requestStream.Write(buffer, 0, count);
                }
            }
        }
开发者ID:bangq,项目名称:EasyHttp,代码行数:20,代码来源:MultipartStreamer.cs

示例9: Encode

		public static void Encode(Image image, Stream stream)
		{
			stream.WriteString(image.Header);
			stream.WriteBytes(image.LogicalScreenDescriptor.ToBytes());

			if (image.LogicalScreenDescriptor.GlobalColorTableFlag)
			{
				stream.WriteBytes(image.GlobalColorTable);
			}

			foreach (var applicationExtension in image.ApplictionExtensions)
			{
				stream.WriteBytes(applicationExtension.ToBytes());
			}

			foreach (var commentExtension in image.CommentExtensions)
			{
				stream.WriteBytes(commentExtension.ToBytes());
			}

			WriteFrames(image.Frames, stream);
		}
开发者ID:krabishe,项目名称:GIF89a.Transformation,代码行数:22,代码来源:GifEncoder.cs

示例10: AddFunctionColumnListSupport

        private void AddFunctionColumnListSupport(Stream st)
        {
            bool isFirstOutputOrInputOutput = true;

            PGUtil.WriteString(st, " AS (");

            for (int i = 0 ; i < Parameters.Count ; i++)
            {
                var p = Parameters[i];

                switch(p.Direction)
                {
                    case ParameterDirection.Output: case ParameterDirection.InputOutput:
                        if (isFirstOutputOrInputOutput)
                        {
                            isFirstOutputOrInputOutput = false;
                        }
                        else
                        {
                            st.WriteString(", ");
                        }

                        st
                            .WriteString(p.CleanName)
                            .WriteBytes((byte)ASCIIBytes.Space)
                            .WriteString(p.TypeInfo.Name);

                        break;
                }
            }

            st.WriteByte((byte)ASCIIBytes.ParenRight);
        }
开发者ID:herqueles3,项目名称:Npgsql,代码行数:33,代码来源:NpgsqlCommand.Rewrite.cs

示例11: AppendParameterPlaceHolder

        private void AppendParameterPlaceHolder(Stream dest, NpgsqlParameter parameter, int paramNumber)
        {
            string parameterSize = "";

            dest.WriteBytes((byte)ASCIIBytes.ParenLeft);

            if (parameter.TypeInfo.UseSize && (parameter.Size > 0))
            {
                parameterSize = string.Format("({0})", parameter.Size);
            }

            if (parameter.UseCast)
            {
                dest.WriteString("${0}::{1}{2}", paramNumber, parameter.TypeInfo.CastName, parameterSize);
            }
            else
            {
                dest.WriteString("${0}{1}", paramNumber, parameterSize);
            }

            dest.WriteBytes((byte)ASCIIBytes.ParenRight);
        }
开发者ID:herqueles3,项目名称:Npgsql,代码行数:22,代码来源:NpgsqlCommand.Rewrite.cs

示例12: WriteTo

 public override void WriteTo(Stream stream)
 {
     stream.WriteString("Content-Type: application/octet-stream\r\n");
     stream.WriteString(string.Format("Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\n\r\n",
         this.Key,
         this.FileName != null
             ? this.FileName.Replace("\n", "%0A").Replace("\r", "%0D").Replace("\"", "%22")
             : "file"
     ));
     this.WriteContent(stream);
 }
开发者ID:CoreTweet,项目名称:CoreTweet,代码行数:11,代码来源:MultipartItem.cs

示例13: Write

 public static void Write(object obj, Stream stream)
 {
     stream.WriteString((string)obj);
 }
开发者ID:FPCollab,项目名称:General,代码行数:4,代码来源:FastPacker.cs

示例14: SaveTo

        public override bool SaveTo(Stream stream)
        {
            base.SaveTo(stream);
            Attribute.SaveTo(stream);
            stream.WriteString(BaseTypeName);

            //types
            uint typeCount = (uint)Types.Count;
            stream.Write(typeCount);
            foreach (var baseSirenCustomType in Types)
            {
                byte isClass = baseSirenCustomType.Value.IsCustomClass ? (byte)1 : (byte)0;
                stream.WriteByte(isClass);
                baseSirenCustomType.Value.SaveTo(stream);
            }

            //fields
            uint filedCount = (uint)FieldNameDict.Count;
            stream.Write(filedCount);
            foreach (var sirenField in FieldNameDict)
            {
                sirenField.Value.SaveTo(stream);
            }

            return true;
        }
开发者ID:fjz13,项目名称:Medusa,代码行数:26,代码来源:SirenCustomClass.cs

示例15: Serialize

        // +--------+--------+--+----------+-----------+-------------+-----------+------------+-------+
        // | LEN(4) | CRC(4) |H1| ID (1~6) | AID (1~6) | M_SIG (1~6) | M_LEN (4) | M_DATA (~) | E (~) |
        // +--------+--------+--+----------+-----------+-------------+-----------+------------+-------+
        // H=[ME....TT] T=Type, M=Message?, E=Exception?
        // ID=RequestId, AID=ActorId, M=Message, E=Exception

        public void Serialize(Stream stream, object packet)
        {
            var p = (Packet)packet;

            // Jump 8 Bytes for writing Length | Checksum
            var packetLengthMarker = new StreamLengthMarker(stream, false);
            stream.Seek(8, SeekOrigin.Current);

            // Write Packet Header
            var header = (byte)((byte)(p.Type) |
                                (byte)(p.Message != null ? 0x80 : 0) |
                                (byte)(p.Exception != null ? 0x40 : 0));
            stream.WriteByte(header);
            stream.Write7BitEncodedInt(p.ActorId);
            stream.Write7BitEncodedInt(p.RequestId);

            // Write Message
            if (p.Message != null)
            {
                if (p.Type == PacketType.System)
                {
                    // System message: Always string.
                    stream.WriteString((string)p.Message);
                }
                else
                {
                    // User message: Length, Signature, and Data
                    var messageTypeAlias = _data.TypeTable.GetAlias(p.Message.GetType());
                    stream.Write7BitEncodedInt(messageTypeAlias);
                    var messageLengthMarker = new StreamLengthMarker(stream, true);
                    _data.MessageSerializer.Serialize(stream, p.Message);
                    messageLengthMarker.WriteLength(true);
                }
            }

            // Write Exception
            if (p.Exception != null)
            {
                _exceptionSerializer.Serialize(stream, p.Exception);
            }

            // Write Length
            packetLengthMarker.WriteLength(false);

            // Encrypt and Calc Checksum
            ArraySegment<byte> s0, s1;
            GetBuffers(stream, (int)packetLengthMarker.StartPosition + 8, packetLengthMarker.Length - 4,
                       out s0, out s1);
            var ctx = new EncryptContext { Key = _serializeWrapKey };
            Encrypt(s0.Array, s0.Offset, s0.Array, s0.Offset, s0.Count, ref ctx);
            Encrypt(s1.Array, s1.Offset, s1.Array, s1.Offset, s1.Count, ref ctx);
            if (_serializeWrapKey != 0)
            {
                _serializeWrapKey += 1;
                if (_serializeWrapKey == 0)
                    _serializeWrapKey = 1;
            }

            // Write Checksum
            var hashBytes = BitConverter.GetBytes(ctx.Hash);
            stream.Write(hashBytes, 0, hashBytes.Length);

            // End of stream, again.
            stream.Seek(packetLengthMarker.EndPosition, SeekOrigin.Begin);

            // Pending WrapKey
            if (_serializeWrapPendingKey != 0)
            {
                _serializeWrapKey = _serializeWrapPendingKey;
                _serializeWrapPendingKey = 0;
            }
        }
开发者ID:SaladLab,项目名称:Akka.Interfaced.SlimSocket,代码行数:78,代码来源:PacketSerializerBase.cs


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