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


C# BinaryWriter.Write方法代码示例

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


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

示例1: Save

	public override void Save(BinaryWriter bw) {
		base.Save(bw);
		bw.Write(dir == 1);
		bw.Write((byte)height);
		bw.Write(sin);
		bw.Write(sinSpeed);
	}
开发者ID:mugmickey,项目名称:Terraria-tConfig-Mods,代码行数:7,代码来源:EffectFireflyHover.cs

示例2: Serialize

	public static byte[] Serialize(Account account)
	{
		using (MemoryStream stream = new MemoryStream())
		using (BinaryWriter writer = new BinaryWriter(stream))
		{
			try
			{
				writer.Write(account.Email);
				writer.Write(account.Username);
				writer.Write((byte)account.Characters.Length);
				for (int i = 0; i < account.Characters.Length; i++)
				{
					byte[] bytes = Serialize(account.Characters[i]);
					writer.Write(bytes.Length);
					writer.Write(bytes);
				}
				return stream.ToArray();
			}
			catch (Exception e)
			{
				Debug.Log("Exception at Serialization.Serialize: " + e.Message);
				return new byte[0];
			}

		}
	}
开发者ID:dallinnguyen,项目名称:Pokemon,代码行数:26,代码来源:Serialization.cs

示例3: DrawImage

	private void DrawImage(VideoFrameType type)
	{
		Stream str = new MemoryStream();
		BinaryWriter writer = new BinaryWriter(str);
		// LITTLE ENDIAN!!
		writer.Write(new byte[] { 0x42, 0x4D });
		writer.Write((int)(type.managedData.Length + 0x36));
		writer.Write((int)0);
		writer.Write((int)0x36);
		writer.Write((int)40);
		writer.Write((int)type.width);
		writer.Write((int)type.height);
		writer.Write((short)1);
		writer.Write((short)24);
		writer.Write((int)0);
		writer.Write((int)type.managedData.Length);
		writer.Write((int)3780);
		writer.Write((int)3780);
		writer.Write((int)0);
		writer.Write((int)0);
		for (int y = type.height - 1; y >= 0; y--)
			writer.Write(type.managedData, y * type.linesize, type.width * 3);
		writer.Flush();
		writer.Seek(0, SeekOrigin.Begin);
		Bitmap bitmap = new Bitmap(str);
		g.DrawImage(bitmap, 0, 0, mainDraw.WidthRequest, mainDraw.HeightRequest);
		writer.Close();

	}
开发者ID:crazyender,项目名称:FFMPEG.net,代码行数:29,代码来源:MainWindow.cs

示例4: Save

 public void Save(BinaryWriter Stream)
 {
     Stream.Write(PathTexture, true);
     Stream.Write(PathNormalmap, true);
     Stream.Write(ScaleTexture);
     Stream.Write(ScaleNormalmap);
 }
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:7,代码来源:Layer.cs

示例5: Main

	public static int Main () {
		MemoryStream mr = new MemoryStream();
		BinaryWriter wr = new BinaryWriter(mr);

		wr.Write ((byte) 1);
		wr.Write ((int) 1);
		wr.Write ((int) -1);

		byte [] arr = mr.ToArray();

		Console.Write ("Array (should be: 1 1 0 0 0 ff ff ff ff): ");

		for (int a = 0; a != arr.Length; a++)
			Console.Write(arr[a].ToString("x") + " ");		

		Console.WriteLine();

		if (arr.Length != 9)
			return 4;

		if (arr[0] != 1) 
			return 1;

		if (arr[1] != 1 && arr[2] != 0 && arr[3] != 0 && arr[4] != 0)
			return 2;

		if (arr[5] != 0xff && arr[6] != 0xff && arr[7] != 0xff && arr[8] != 0xff)
			return 3;
	
		Console.WriteLine("test-ok");

		return 0;
	}
开发者ID:Zman0169,项目名称:mono,代码行数:33,代码来源:binwritter.cs

示例6: Write

 public void Write(BinaryWriter w)
 {
     //if (w == null) throw new ArgumentNullException("w");
     w.Write(FResult.ToString());
     w.Write(FSeparator);
     w.Write(FEmpty);
 }
开发者ID:APouchkov,项目名称:ExtendedStoredProcedures,代码行数:7,代码来源:Strings.cs

示例7: WriteBlock

 public void WriteBlock(Stream stream)
 {
     BinaryWriter writer = new BinaryWriter(stream);
     writer.Write(Tag);
     writer.Write(Size);
     writer.Write(Data);
 }
开发者ID:dotnet,项目名称:corefx,代码行数:7,代码来源:ZipBlocks.cs

示例8: Save

            // Binary save
            public void Save(string filename)
            {
                FileStream binFile = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite);
                //			ICSharpCode.SharpZipLib.GZip.GZipOutputStream gz = new ICSharpCode.SharpZipLib.GZip.GZipOutputStream(binFile);
                //			BinaryWriter writer = new BinaryWriter(gz);
                BinaryWriter writer = new BinaryWriter(binFile);

                writer.Write(BinaryHeaderVersionString);
                writer.Write(mFormat);

                // Write out string table
                writer.Write( stringTable.Count );
                for (int i = 0, e = stringTable.Count; i < e; i++)
                {
                    writer.Write( stringTable[i] );
                }

                // Write out categories
                writer.Write( categories.Count );
                foreach (string i in categories)
                {
                    writer.Write( i );
                }

                // Write out heap ranges.
                writer.Write( mAllocators.Count );
                foreach (LogEntryAllocators e in mAllocators)
                {
                    writer.Write(e.mName);
                    writer.Write(e.mStartAddress);
                    writer.Write(e.mEndAddress);
                }

                //Write out DataFields.
                writer.Write(field.Count);
                foreach (string e in field)
                {
                    writer.Write(e);
                }

                writer.Write( log.Count );
                for (int i = 0, e = log.Count; i < e; i++)
                {
                    LogEntry logentry = (LogEntry)(log[i]);
                    writer.Write( logentry.type );
                    writer.Write( logentry.category );
                    writer.Write( logentry.allocator );
                    writer.Write( logentry.address );
                //	writer.Write( logentry.reqSize );
                    writer.Write( logentry.allocSize );
                    writer.Write( logentry.alignment );
                    writer.Write( logentry.nameString );
                    writer.Write( logentry.stackTraceString );
                    writer.Write( logentry.number );
                }

                writer.Close();
                binFile.Close();
            }
开发者ID:arjangcore,项目名称:MemoryCompare,代码行数:60,代码来源:Log.cs

示例9: Write

 public void Write( BinaryWriter w )
 {
     w.Write( this.values.Count );
     foreach ( string s in this.values )
     {
         w.Write( s );
     }
 }
开发者ID:ohri,项目名称:netba,代码行数:8,代码来源:TradeAggregator.cs

示例10: Save

	public void Save(BinaryWriter bw) {
		bw.Write(list.Count);
		foreach (TileFirefly tf in list) {
			bw.Write(tf.x);
			bw.Write(tf.y);
			SaveOne(bw,tf.firefly);
		}
	}
开发者ID:mugmickey,项目名称:Terraria-tConfig-Mods,代码行数:8,代码来源:TileFireflyHandler.cs

示例11: SaveNormal

 public void SaveNormal(BinaryWriter Stream)
 {
     string Path = PathNormalmap.Replace("\\", "/");
     if (!string.IsNullOrEmpty(Path) & !Path.StartsWith("/"))
         Path = "/" + Path;
     Stream.Write(Path, true);
     Stream.Write(ScaleNormalmap);
 }
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:8,代码来源:Layer.cs

示例12: SaveAlbedo

 public void SaveAlbedo(BinaryWriter Stream)
 {
     string Path = PathTexture.Replace("\\", "/");
     if (!string.IsNullOrEmpty(Path) & !Path.StartsWith("/"))
         Path = "/" + Path;
     Stream.Write(Path, true);
     Stream.Write(ScaleTexture);
 }
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:8,代码来源:Layer.cs

示例13: Write

 public void Write(BinaryWriter w)
 {
     w.Write(_list.Count);
     foreach(double v in _list)
     {
         w.Write(v);
     }
 }
开发者ID:ben-thul,项目名称:SQLCLR,代码行数:8,代码来源:NaiveSum.cs

示例14: Main

 public static void Main(string[] args)
 {
     if (args.Length != 2) {
       Console.Error.WriteLine("Usage: SHS.SCC1 <leader> <store>");
     } else {
       var sw = Stopwatch.StartNew();
       var store = new Service(args[0]).OpenStore(Guid.Parse(args[1]));
       long numUids = store.NumUrls();
       var bv = new BitVector(numUids);  // All false at creation
       var stk = new LongStack(1 << 23, "scc");
       foreach (long u in store.Uids()) {
     if (!bv[store.UidToLid(u)]) {
       Frame frame = new Frame(null, u, store, Dir.Fwd, bv);
       while (frame != null) {
         while (frame.linkPos < frame.links.Length) {
           long v = frame.links[frame.linkPos++];
           if (!bv[store.UidToLid(v)]) {
             frame = new Frame(frame, v, store, Dir.Fwd, bv);
           }
         }
         stk.Push(frame.uid);
         frame = frame.parent;
       }
     }
       }
       using (var sccWr = new BinaryWriter(new BufferedStream(new FileStream("scc-main.bin", FileMode.Create, FileAccess.Write)))) {
     using (var idxWr = new BinaryWriter(new BufferedStream(new FileStream("scc-index.bin", FileMode.Create, FileAccess.Write)))) {
       long numSCCs = 0;
       long sccPos = 0;
       bv.SetAll(false);
       for (long i = 0; i < numUids; i++) {
         long u = stk.Pop();
         if (!bv[store.UidToLid(u)]) {
           numSCCs++;
           long sccSize = 0;
           Frame frame = new Frame(null, u, store, Dir.Bwd, bv);
           while (frame != null) {
             while (frame.linkPos < frame.links.Length) {
               long v = frame.links[frame.linkPos++];
               if (!bv[store.UidToLid(v)]) {
                 frame = new Frame(frame, v, store, Dir.Bwd, bv);
               }
             }
             sccWr.Write(frame.uid);
             sccSize++;
             frame = frame.parent;
           }
           idxWr.Write(sccSize);
           idxWr.Write(sccPos);
           sccPos += sccSize;
         }
       }
     }
       }
       store.Close();
       Console.WriteLine("Done. Job took {0} seconds.", 0.001 * sw.ElapsedMilliseconds);
     }
 }
开发者ID:pszmyd,项目名称:SHS,代码行数:58,代码来源:SCC1.cs

示例15: Save

	public override void Save(BinaryWriter bw) {
		base.Save(bw);
		NetworkHelper.Write(bw,color);
		bw.Write(rot1);
		bw.Write(rotSpeed1);
		bw.Write(rot2);
		bw.Write(rotSpeed2);
		bw.Write(chaos);
	}
开发者ID:mugmickey,项目名称:Terraria-tConfig-Mods,代码行数:9,代码来源:EffectFireflyCorrupt.cs


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