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