public static IReadOnlyList <WriteValueInstr> ParseWriteValues(string text) { var result = new List <WriteValueInstr>(); var lastPattern = new AddressPattern(); foreach (var line in text.Split('\n').Where(l => l.Trim().Length > 0)) { var newMaskMatch = NewMaskRegex.Match(line); if (newMaskMatch.Success) { lastPattern = new AddressPattern(newMaskMatch.Groups[1].Value); continue; } var writeValueMatch = WriteValueRegex.Match(line); if (writeValueMatch.Success) { result.Add(new WriteValueInstr( lastPattern.Apply(long.Parse(writeValueMatch.Groups[1].Value)), long.Parse(writeValueMatch.Groups[2].Value))); continue; } throw new InvalidDataException(); } return(result); }
public byte[] ToBytes() { var bytes = AddressPattern.ToBytes(); bytes = bytes.Concat(GetTypeTags()).ToArray(); bytes = Arguments.Aggregate(bytes, (current, argument) => current.Concat(argument.ToBytes()).ToArray()); return(bytes); }
public WriteValueInstr(AddressPattern address, long value) => (AddressPattern, Value) = (address, value);