Example #1
0
        // 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;
        }
Example #2
0
        // 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);
            }
        }
Example #3
0
 // Binary serializer
 void Write(BinaryWriter writer)
 {
     writer.Write(this.FileName ?? string.Empty);
     if (this.Symbols != null)
     {
         SymbolHelper.WriteEncodedInt32(writer, this.Symbols.Count);
         foreach (ActivitySymbol actSym in this.Symbols)
         {
             actSym.Write(writer);
         }
     }
     else
     {
         SymbolHelper.WriteEncodedInt32(writer, 0);
     }
 }
Example #4
0
 // Binary serializer.
 internal void Write(BinaryWriter writer)
 {
     SymbolHelper.WriteEncodedInt32(writer, this.StartLine);
     SymbolHelper.WriteEncodedInt32(writer, this.StartColumn);
     SymbolHelper.WriteEncodedInt32(writer, this.EndLine);
     SymbolHelper.WriteEncodedInt32(writer, this.EndColumn);
     if (this.QualifiedId != null)
     {
         SymbolHelper.WriteEncodedInt32(writer, this.QualifiedId.Length);
         writer.Write(this.QualifiedId, 0, this.QualifiedId.Length);
     }
     else
     {
         SymbolHelper.WriteEncodedInt32(writer, 0);
     }
 }
Example #5
0
        internal string Encode(EncodingFormat encodingFormat)
        {
            using (MemoryStream ms = new MemoryStream())
            {
                using (BinaryWriter writer = new BinaryWriter(ms))
                {
                    if (this.checksum != null)
                    {
                        writer.Write((byte)(encodingFormat | EncodingFormat.Checksum));
                        SymbolHelper.WriteEncodedInt32(writer, this.checksum.Length);
                        writer.Write(this.checksum);
                    }
                    else
                    {
                        writer.Write((byte)encodingFormat);
                    }
                    switch (encodingFormat)
                    {
                    case EncodingFormat.Binary:
                        this.Write(writer);
                        break;

                    case EncodingFormat.String:
                        writer.Write(this.ToString());
                        break;

                    default:
                        throw FxTrace.Exception.AsError(new SerializationException());
                    }
                    // Need to copy to a buffer to trim excess capacity.
                    byte[] buffer = new byte[ms.Length];
                    Array.Copy(ms.GetBuffer(), buffer, ms.Length);
                    return(Convert.ToBase64String(buffer));
                }
            }
        }