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


C# BinaryWriter.Write7BitEncodedInt方法代码示例

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


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

示例1: Save

 public void Save(Stream stream)
 {
     using (var bw = new BinaryWriter(stream, Encoding.UTF8, leaveOpen: true))
     {
         // 1337 - signature that this is us
         bw.Write7BitEncodedInt(1337);
         bw.Write7BitEncodedInt(1); // version
         bw.Write7BitEncodedInt(_dictionary.Length);
         bw.Write(_dictionary);
         _packer.Save(bw);
     }
 }
开发者ID:modulexcite,项目名称:Rhea.Compression,代码行数:12,代码来源:CompressionHandler.cs

示例2: Save

	    public void Save(BinaryWriter writer)
	    {
	        symbols.Save(writer);
            writer.Write7BitEncodedInt(offsets.Length);
	        foreach (var offset in offsets)
	        {
	            offset.Save(writer);
	        }
	    }
开发者ID:modulexcite,项目名称:Rhea.Compression,代码行数:9,代码来源:HuffmanPacker.cs

示例3: SaveLicense

        /// <summary>
        /// Saves the license.
        /// </summary>
        public static void SaveLicense(string user, string key, byte[] license)
        {
            var licfile = Path.Combine(AppDataPath, ".license");

            var xkey = ProtectedData.Protect(Encoding.UTF8.GetBytes(key), null, DataProtectionScope.LocalMachine);
            var lic  = ProtectedData.Protect(license, null, DataProtectionScope.LocalMachine);

            using (var fs = File.Create(licfile))
            using (var bw = new BinaryWriter(fs))
            {
                bw.Write((byte)Utils.Rand.Next(0, 200));
                bw.Write(user);
                bw.Write7BitEncodedInt(xkey.Length);
                bw.Write(xkey);
                bw.Write7BitEncodedInt(lic.Length);
                bw.Write(lic);
            }
        }
开发者ID:x-skywalker,项目名称:RS-TV-Show-Tracker,代码行数:21,代码来源:Signature.cs

示例4: ReadCorruptedJournalFile

        public void ReadCorruptedJournalFile()
        {
            string path = Path.GetFullPath("TestData\\ReadCorruptedJournal");
            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);
            JournalWriter jw = new JournalWriter(path, 324, false);

            List<KeyValuePair<Key, Value>> items = new List<KeyValuePair<Key, Value>>();
            for (int i = 0; i < 10; i++) {
                Key randKey = Key.Random(20);
                Value randValue = Value.Random(100);
                jw.Add(randKey, randValue);
                items.Add(new KeyValuePair<Key, Value>(randKey, randValue));
            }
            jw.Close();

            // Reopen the file and add a partial record
            var fileName = Config.JournalFile(path, 324);
            var writer = new BinaryWriter(new FileStream(fileName, FileMode.Append, FileAccess.Write, FileShare.None, 1024, false));
            Key key = Key.Random(20);
            writer.Write7BitEncodedInt(key.Length);
            writer.Write(key.InternalBytes);
            writer.Write7BitEncodedInt(0);
            writer.Flush();
            writer.Close();

            JournalReader jr = new JournalReader(path, 324);
            int j = 0;
            foreach (var pair in jr.Enumerate()) {
                Assert.AreEqual(items[j].Key, pair.Key);
                Assert.AreEqual(items[j].Value, pair.Value);
                j++;
            }
            jr.Close();
        }
开发者ID:gnoso,项目名称:razordb,代码行数:35,代码来源:JournalTests.cs

示例5: WriteMetadata

        void WriteMetadata()
        {
            MemoryStream ms = new MemoryStream ();
            BinaryWriter writer = new BinaryWriter (ms);

            writer.Write (Encoding.ASCII.GetBytes ("@RAZORDB"));
            writer.Write7BitEncodedInt (totalBlocks + 1);
            writer.Write7BitEncodedInt (dataBlocks);
            writer.Write7BitEncodedInt (indexBlocks);

            byte[] metadata = ms.ToArray ();
            Array.Copy (metadata, _buffer, metadata.Length);

            // Commit the block to disk and wait for the operation to complete
            WriteBlock ();
            _fileStream.EndWrite (_async);
        }
开发者ID:T145,项目名称:razordbx,代码行数:17,代码来源:SortedBlockTable.cs


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