public override Amount FromParser(BinaryParser parser, int?hint) { BigDecimal value; byte[] mantissa = parser.Read(8); byte b1 = mantissa[0], b2 = mantissa[1]; bool isIou = (b1 & 0x80) != 0; bool isPositive = (b1 & 0x40) != 0; int sign = isPositive ? 1 : -1; if (isIou) { mantissa[0] = 0; Currency curr = Currency.OutTranslate.FromParser(parser); AccountId issuer = AccountId.OutTranslate.FromParser(parser); int offset = ((b1 & 0x3F) << 2) + ((b2 & 0xff) >> 6) - 97; mantissa[1] &= 0x3F; value = new BigDecimal(new BigInteger(sign, mantissa), -offset); return(new Amount(value, curr, issuer, false)); } mantissa[0] &= 0x3F; value = XrpFromDropsMantissa(mantissa, sign); return(new Amount(value)); }
public static AmountValue FromParser(BinaryParser parser) { AmountValue value; var mantissa = parser.Read(8); var b1 = mantissa[0]; var b2 = mantissa[1]; var isIou = (b1 & 0x80) != 0; var isPositive = (b1 & 0x40) != 0; var sign = isPositive ? 1 : -1; if (isIou) { mantissa[0] = 0; var exponent = ((b1 & 0x3F) << 2) + ((b2 & 0xff) >> 6) - 97; mantissa[1] &= 0x3F; value = new IouValue(mantissa, sign, exponent); } else { mantissa[0] &= 0x3F; value = new NativeValue(mantissa, sign); } return(value); }
public override AccountId FromParser(BinaryParser parser, int?hint) { if (hint == null) { hint = 20; } return(FromAddress(parser.Read((int)hint))); }
public override VariableLength FromParser(BinaryParser parser, int?hint) { if (hint == null) { hint = parser.Size; } return(new VariableLength(parser.Read((int)hint))); }
private void FillDataGridView() { BinaryParser parser = new BinaryParser(); Document document = parser.Read(path); var bindingList = new BindingList <Car>(document.Cars); var source = new BindingSource(bindingList, null); dataGridView1.DataSource = source; }
public OcadFile ReadFile() { using (var stream = new FileStream(_filePath, FileMode.Open)) { var reader = new OcadStreamReader(stream); var parser = new BinaryParser<OcadFile>(); return parser.Read(reader); } }
public Demurrage(byte[] bytes) { var parser = new BinaryParser(bytes); parser.Skip(1); // The type. _isoCode = IsoCodeFromBytesAndOffset(parser.Read(3), 0); _intrestStart = RippleDate.FromParser(parser); long l = UInt.UInt64.OutTranslate.FromParser(parser).LongValue(); _intrestRate = BitConverter.Int64BitsToDouble(l); }
/*public OcadDiff GetDiff() * { * var diff = new OcadDiff(); * var compareLogic = new CompareLogic(); * compareLogic.Config.MaxDifferences = Int32.MaxValue; * compareLogic.Config.IgnoreCollectionOrder = true; * compareLogic.Config.CollectionMatchingSpec[typeof(CourseSettingObject)] = new [] { "Code" }; * diff.Report = compareLogic.Compare(GetProject(SourceFile), GetProject(TargetFile)); * return diff; * }*/ private OcadCourseSettingProject GetProject(string sourceFile) { OcadCourseSettingProject project = new OcadCourseSettingProject(); using (var stream = new FileStream(sourceFile, FileMode.Open)) { var reader = new OcadStreamReader(stream); var parser = new BinaryParser <OcadFile>(); var file = parser.Read(reader); project.Load(file); } return(project); }
static void Main(string[] args) { OcadCourseSettingProject project = new OcadCourseSettingProject(); using (var stream = new FileStream(@"D:\temp\testmap.ocd", FileMode.Open)) { var reader = new OcadStreamReader(stream); var parser = new BinaryParser<OcadFile>(); var file = parser.Read(reader); project.Load(file); } foreach (var symbol in project.Symbols) { Console.WriteLine(symbol.Description); } }
static void Main(string[] args) { XmlParser parser = new XmlParser(); BinaryParser binParser = new BinaryParser(); Document _document = new Document(); _document.Cars.Add(new Car { Date = DateTime.Today, BrandName = "asd1231deqd", Price = 121212 }); _document.Cars.Add(new Car { Date = DateTime.Today, BrandName = "asdsda as ", Price = 12212 }); _document.Cars.Add(new Car { Date = DateTime.Today, BrandName = "a1", Price = 112212 }); //binParser.Write(_document, @"C:\Users\IsrafilovR\Desktop\_MyProjects\test35.dat"); binParser.Read(@"C:\Users\IsrafilovR\Desktop\_MyProjects\test35.dat"); }
public new static Currency FromParser(BinaryParser parser, int?hint = null) { return(new Currency(parser.Read(20))); }
public static Blob FromParser(BinaryParser parser, int?hint = null) { Debug.Assert(hint != null, "hint != null"); return(parser.Read((int)hint)); }
public static Hash128 FromParser(BinaryParser parser, int?hint = null) { return(new Hash128(parser.Read(16))); }
public static Hash160 FromParser(BinaryParser parser, int?hint = null) { return(new Hash160(parser.Read(20))); }
public int ReadOrdinal(BinaryParser parser) { return(parser.Read(Width).Aggregate(0, (a, b) => (a >> 8) + b)); }
/*public OcadDiff GetDiff() { var diff = new OcadDiff(); var compareLogic = new CompareLogic(); compareLogic.Config.MaxDifferences = Int32.MaxValue; compareLogic.Config.IgnoreCollectionOrder = true; compareLogic.Config.CollectionMatchingSpec[typeof(CourseSettingObject)] = new [] { "Code" }; diff.Report = compareLogic.Compare(GetProject(SourceFile), GetProject(TargetFile)); return diff; }*/ private OcadCourseSettingProject GetProject(string sourceFile) { OcadCourseSettingProject project = new OcadCourseSettingProject(); using (var stream = new FileStream(sourceFile, FileMode.Open)) { var reader = new OcadStreamReader(stream); var parser = new BinaryParser<OcadFile>(); var file = parser.Read(reader); project.Load(file); } return project; }
public new static AccountId FromParser(BinaryParser parser, int?hint = null) { return(new AccountId(parser.Read(20))); }
public override T FromParser(BinaryParser parser, int?hint) { return(NewInstance(new BigInteger(1, parser.Read(ByteWidth())))); }
public static Uint16 FromParser(BinaryParser parser, int?hint = null) { return(Bits.ToUInt16(parser.Read(2), 0)); }
public static Hash256 FromParser(BinaryParser parser, int?hint = null) { return(new Hash256(parser.Read(32))); }