/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. using System;
  4. using System.IO;
  5. using System.Text;
  6. namespace Ricciolo.StylesExplorer.MarkupReflection
  7. {
  8. internal class BamlBinaryReader : BinaryReader
  9. {
  10. // Methods
  11. public BamlBinaryReader(Stream stream)
  12. : base(stream)
  13. {
  14. }
  15. public virtual double ReadCompressedDouble()
  16. {
  17. switch (this.ReadByte()) {
  18. case 1:
  19. return 0;
  20. case 2:
  21. return 1;
  22. case 3:
  23. return -1;
  24. case 4:
  25. return ReadInt32() * 1E-06;
  26. case 5:
  27. return this.ReadDouble();
  28. }
  29. throw new NotSupportedException();
  30. }
  31. public int ReadCompressedInt32()
  32. {
  33. return base.Read7BitEncodedInt();
  34. }
  35. }
  36. }