// Decode from Base64 string. public static WorkflowSymbol Decode(string symbolString) { byte[] data = Convert.FromBase64String(symbolString); using (BinaryReader reader = new BinaryReader(new MemoryStream(data))) { byte[] checksum = null; EncodingFormat format = (EncodingFormat)reader.ReadByte(); int payloadBytesCount = data.Length - sizeof(EncodingFormat); if (0 != (format & EncodingFormat.Checksum)) { int bytesCount = SymbolHelper.ReadEncodedInt32(reader); checksum = reader.ReadBytes(bytesCount); payloadBytesCount -= SymbolHelper.GetEncodedSize(bytesCount); format &= (~EncodingFormat.Checksum); } switch (format) { case EncodingFormat.Binary: return(ParseBinary(reader.ReadBytes(payloadBytesCount), checksum)); // Compute the case EncodingFormat.String: return(ParseStringRepresentation(reader.ReadString(), checksum)); } } throw FxTrace.Exception.AsError(new SerializationException()); }
// These constructors are private and used by Decode() method. // Binary deserializer. WorkflowSymbol(BinaryReader reader, byte[] checksum) { this.FileName = reader.ReadString(); int numSymbols = SymbolHelper.ReadEncodedInt32(reader); this.Symbols = new List <ActivitySymbol>(numSymbols); for (int i = 0; i < numSymbols; ++i) { this.Symbols.Add(new ActivitySymbol(reader)); } this.checksum = checksum; }
// Binary deserializer. internal ActivitySymbol(BinaryReader reader) { this.StartLine = SymbolHelper.ReadEncodedInt32(reader); this.StartColumn = SymbolHelper.ReadEncodedInt32(reader); this.EndLine = SymbolHelper.ReadEncodedInt32(reader); this.EndColumn = SymbolHelper.ReadEncodedInt32(reader); int qidLength = SymbolHelper.ReadEncodedInt32(reader); if (qidLength > 0) { this.QualifiedId = reader.ReadBytes(qidLength); } }