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


C# Stream.WriteInt32方法代码示例

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


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

示例1: Save

        public void Save(Stream stream)
        {
            stream.WriteUInt16((UInt16)Name.Length);
            stream.WriteAsciiString(Name);
            stream.WriteUInt8(ContainerType);
            stream.WriteUInt16((UInt16)Flags);
            stream.WriteUInt16((UInt16)Primitives.Count);
            stream.WriteUInt32(PackfileBaseOffset);
            stream.WriteUInt8(CompressionType);
            if (StubContainerParentName != null && StubContainerParentName != "")
            {
                stream.WriteUInt16((UInt16)StubContainerParentName.Length);
                stream.WriteAsciiString(StubContainerParentName);
            }
            else
            {
                stream.WriteUInt16(0);
            }
            stream.WriteInt32(AuxData.Length);
            stream.Write(AuxData, 0, AuxData.Length);
            stream.WriteInt32(TotalCompressedPackfileReadSize);

            foreach (WriteTimeSizes sizes in PrimitiveSizes)
            {
                stream.WriteStruct(sizes);
            }

            foreach (Primitive primitive in Primitives)
            {
                primitive.Save(stream);
            }
        }
开发者ID:rodrigonh,项目名称:ThomasJepp.SaintsRow,代码行数:32,代码来源:Container.cs

示例2: WriteToStream

 public override void WriteToStream(Stream outputStream)
 {
     outputStream.WriteInt32(CancelRequestMessageSize);
     outputStream.WriteInt32(CancelRequestCode);
     outputStream.WriteInt32(BackendKeydata.ProcessID);
     outputStream.WriteInt32(BackendKeydata.SecretKey);
 }
开发者ID:timoch,项目名称:Npgsql-fdb,代码行数:7,代码来源:NpgsqlCancelRequest.cs

示例3: WriteValue

 public override void WriteValue(Stream stream, object value, SerializerSession session)
 {
     var data = decimal.GetBits((decimal) value);
     stream.WriteInt32(data[0]);
     stream.WriteInt32(data[1]);
     stream.WriteInt32(data[2]);
     stream.WriteInt32(data[3]);
 }
开发者ID:Horusiath,项目名称:Wire,代码行数:8,代码来源:DecimalSerializer.cs

示例4: PackFull

 public void PackFull(Stream stream)
 {
     long start = stream.Position;
     stream.WriteInt32(1);
     stream.WriteInt8((byte) ID);
     Pack(stream);
     long end = stream.Position;
     stream.Position = start;
     stream.WriteInt32((int) (end - start) - 4);
     stream.Position = end;
 }
开发者ID:Enerdy,项目名称:TShock,代码行数:11,代码来源:BaseMsg.cs

示例5: WriteToStream

        public override void WriteToStream(Stream outputStream)
        {
            NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "WriteToStream");

            switch (protocolVersion)
            {
                case ProtocolVersion.Version2:
                    // Write the size of the packet.
                    // 4 + (passwordlength + 1) -> Int32 + NULL terminated string.
                    // output_stream.Write(BitConverter.GetBytes(IPAddress.HostToNetworkOrder(4 + (password.Length + 1))), 0, 4);
                    outputStream
                        .WriteInt32(4 + password.Length + 1)
                        .WriteBytesNullTerminated(password);

                    break;

                case ProtocolVersion.Version3:
                    outputStream
                        .WriteBytes((Byte)ASCIIBytes.p)
                        .WriteInt32(4 + password.Length + 1)
                        .WriteBytesNullTerminated(password);

                    break;
            }
        }
开发者ID:NoeGarcia,项目名称:Npgsql,代码行数:25,代码来源:NpgsqlPasswordPacket.cs

示例6: WriteValue

 public override void WriteValue(Stream stream, object value, SerializerSession session)
 {
     //null = 0
     // [0]
     //length < 255 gives length + 1 as a single byte + payload
     // [B length+1] [Payload]
     //others gives 254 + int32 length + payload
     // [B 254] [I Length] [Payload]
     if (value == null)
     {
         stream.WriteByte(0);
     }
     else
     {
         var bytes = Encoding.UTF8.GetBytes((string) value);
         if (bytes.Length < 255)
         {
             stream.WriteByte((byte)(bytes.Length+1));
             stream.Write(bytes, 0, bytes.Length);
         }
         else
         {
             stream.WriteByte(254);
             stream.WriteInt32(bytes.Length);
             stream.Write(bytes,0,bytes.Length);
         }
         
     }
 }
开发者ID:philiplaureano,项目名称:Wire,代码行数:29,代码来源:StringSerializer.cs

示例7: WriteValue

 public override void WriteValue(Stream stream, object value, SerializerSession session)
 {
     if (value == null)
     {
         stream.WriteInt32(-1);
     }
     else
     {
         var type = (Type) value;
         int existingId;
         if (session.Serializer.Options.PreserveObjectReferences && session.TryGetObjectId(type, out existingId))
         {
             ObjectReferenceSerializer.Instance.WriteManifest(stream, null, session);
             ObjectReferenceSerializer.Instance.WriteValue(stream, existingId, session);
         }
         else
         { 
             //type was not written before, add it to the tacked object list
             var name = type.GetShortAssemblyQualifiedName();
             if (session.Serializer.Options.PreserveObjectReferences)
             {
                 session.TrackSerializedObject(type);
             }
             // ReSharper disable once PossibleNullReferenceException
             // ReSharper disable once AssignNullToNotNullAttribute
             var bytes = Encoding.UTF8.GetBytes(name);
             stream.WriteLengthEncodedByteArray(bytes);
         }
     }
 }
开发者ID:philiplaureano,项目名称:Wire,代码行数:30,代码来源:TypeSerializer.cs

示例8: Finish

		public BlockHandle Finish(Stream output)
		{
			if (_slices.Count > 0)
			{
				GenerateFilter();
			}

			var startPos = output.Position;

			var offsetInBlock = _stream.Position;
			_stream.Position = 0;
			_stream.CopyTo(output);

			foreach (var filterOffset in _filterOffsets)
			{
				output.WriteInt32(filterOffset);
			}
			output.WriteInt32((int)offsetInBlock);
			output.WriteByte(FilterBaseLg);

			return new BlockHandle
				{
					Position = startPos,
					Count = output.Position - startPos
				};
		}
开发者ID:mattwarren,项目名称:temp.raven.storage,代码行数:26,代码来源:FilterBlockBuilder.cs

示例9: WriteToStream

        public override void WriteToStream(Stream outputStream)
        {
            outputStream.WriteByte((byte)FrontEndMessageCode.Parse);

            // message length =
            // Int32 self
            // name of prepared statement + 1 null string terminator +
            // query string + 1 null string terminator
            // + Int16
            // + Int32 * number of parameters.
            Int32 messageLength = 4 + _bPrepareName.Length + 1 + _bQueryString.Length + 1 +
                                  2 + (_parameterIDs.Length * 4);

            outputStream
                .WriteInt32(messageLength)
                .WriteBytesNullTerminated(_bPrepareName)
                .WriteBytesNullTerminated(_bQueryString)
                .WriteInt16((Int16)_parameterIDs.Length);

            for (Int32 i = 0; i < _parameterIDs.Length; i++)
            {
                outputStream.WriteInt32(_parameterIDs[i]);
            }

            outputStream.Flush();
        }
开发者ID:udoliess,项目名称:npgsql,代码行数:26,代码来源:NpgsqlParse.cs

示例10: WriteValue

 public override void WriteValue(Stream stream, object value, SerializerSession session)
 {
     if (value == null)
     {
         stream.WriteInt32(-1);
     }
     else
     {
         var bytes = Encoding.UTF8.GetBytes((string) value);
         stream.WriteLengthEncodedByteArray(bytes);
     }
 }
开发者ID:Horusiath,项目名称:Wire,代码行数:12,代码来源:StringSerializer.cs

示例11: WriteValue

        public override void WriteValue(Stream stream, object arr, SerializerSession session)
        {
            var array = arr as Array;
            var elementSerializer = session.Serializer.GetSerializerByType(_elementType);
            stream.WriteInt32(array.Length);
            var preserveObjectReferences = session.Serializer.Options.PreserveObjectReferences;

            for (var i = 0; i < array.Length; i++) //write the elements
            {
                var value = array.GetValue(i);
                stream.WriteObject(value, _elementType, elementSerializer, preserveObjectReferences, session);
            }
        }
开发者ID:cpx,项目名称:Wire,代码行数:13,代码来源:ArraySerializer.cs

示例12: WriteValue

 public override void WriteValue(Stream stream, object value, SerializerSession session)
 {
     var array = value as Array;
     var elementType = value.GetType().GetElementType();
     var elementSerializer = session.Serializer.GetSerializerByType(elementType);
     elementSerializer.WriteManifest(stream, elementType, session); //write array element type
     stream.WriteInt32(array.Length);
     for (var i = 0; i < array.Length; i++) //write the elements
     {
         var elementValue = array.GetValue(i);
         elementSerializer.WriteValue(stream, elementValue, session);
     }
 }
开发者ID:Horusiath,项目名称:Wire,代码行数:13,代码来源:ConsistentArraySerializer.cs

示例13: WriteValue

 public override void WriteValue(Stream stream, object value, SerializerSession session)
 {
     if (value == null)
     {
         stream.WriteInt32(-1);
     }
     else
     {
         var type = (Type) value;
         var name = type.AssemblyQualifiedName;
         var bytes = Encoding.UTF8.GetBytes(name);
         stream.WriteLengthEncodedByteArray(bytes);
     }
 }
开发者ID:Horusiath,项目名称:Wire,代码行数:14,代码来源:TypeSerializer.cs

示例14: HandleRequestHandlers

        private void HandleRequestHandlers(Stream stream) {
            string filename = stream.ReadString();

            Debug.WriteLine("Exception handlers requested for: " + filename);
            var statements = GetHandledExceptionRanges(filename);

            lock (_streamLock) {
                stream.Write(SetExceptionHandlerInfoCommandBytes);
                stream.WriteString(filename);

                stream.WriteInt32(statements.Count);

                foreach (var t in statements) {
                    stream.WriteInt32(t.Item1);
                    stream.WriteInt32(t.Item2);

                    foreach (var expr in t.Item3) {
                        stream.WriteString(expr);
                    }
                    stream.WriteString("-");
                }
            }
        }
开发者ID:KevinH-MS,项目名称:PTVS,代码行数:23,代码来源:PythonProcess.cs

示例15: SezializeSaveFile

        private void SezializeSaveFile(Stream stream, SaveFile save)
        {
            var saveDataStream = new MemoryStream();
            var nameTableStream = new MemoryStream();

            var newSave = new SaveFile
            {
                Header =
                {
                    UnkInt1 = save.Header.UnkInt1
                },
                SaveDataHeader =
                {
                    HeaderSize = save.SaveDataHeader.HeaderSize,
                    UnkInt2 = save.SaveDataHeader.UnkInt2
                }
            };

            newSave.SaveData = FillSaveData();

            saveDataStream.SerializeObject(newSave.SaveData, newSave.NameTable.Names);

            nameTableStream.WriteInt32(newSave.NameTable.Names.Count);
            for (var i = 0; i < newSave.NameTable.Names.Count; i++)
            {
                nameTableStream.WriteString(newSave.NameTable.Names[i]);
            }

            newSave.SaveDataHeader.SaveDataSize = (int) saveDataStream.Length + 12; // 12 = SaveDataHeader size
            newSave.Header.FileSize = (int) saveDataStream.Length + 12 + (int) nameTableStream.Length;

            stream.Seek(0, SeekOrigin.Begin);

            // File header
            stream.WriteInt32(newSave.Header.UnkInt1);
            stream.WriteInt32(newSave.Header.FileSize);

            // Save data header
            stream.WriteInt32(newSave.SaveDataHeader.HeaderSize);
            stream.WriteInt32(newSave.SaveDataHeader.SaveDataSize);
            stream.WriteInt32(newSave.SaveDataHeader.UnkInt2);

            // Save data
            saveDataStream.WriteTo(stream);
            //stream.WriteInt32(255);

            // Name table
            nameTableStream.WriteTo(stream);
        }
开发者ID:VakhtinAndrey,项目名称:lis-save-editor,代码行数:49,代码来源:MainForm.cs


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