當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。