PageRenderTime 20ms CodeModel.GetById 16ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/BamlBinaryReader.cs

http://github.com/icsharpcode/ILSpy
C# | 40 lines | 33 code | 4 blank | 3 comment | 1 complexity | 860d0d0d55d38080c8f9eb225c7df02f MD5 | raw file
 1// Copyright (c) Cristian Civera (cristian@aspitalia.com)
 2// This code is distributed under the MS-PL (for details please see \doc\MS-PL.txt)
 3
 4using System;
 5using System.IO;
 6using System.Text;
 7
 8namespace Ricciolo.StylesExplorer.MarkupReflection
 9{
10	internal class BamlBinaryReader : BinaryReader
11	{
12		// Methods
13		public BamlBinaryReader(Stream stream)
14			: base(stream)
15		{
16		}
17
18		public virtual double ReadCompressedDouble()
19		{
20			switch (this.ReadByte()) {
21				case 1:
22					return 0;
23				case 2:
24					return 1;
25				case 3:
26					return -1;
27				case 4:
28					return ReadInt32() * 1E-06;
29				case 5:
30					return this.ReadDouble();
31			}
32			throw new NotSupportedException();
33		}
34
35		public int ReadCompressedInt32()
36		{
37			return base.Read7BitEncodedInt();
38		}
39	}
40}