Exemplo n.º 1
0
        public static ObjectBusMessage Deserialize(byte[] bytes)
        {
            Console.WriteLine("GetRowsResponseMessage.Deserialize()");
            Guid      requestID;
            Exception exception;

            using (System.IO.MemoryStream MS = new System.IO.MemoryStream(bytes, false)) {
                using (System.IO.BinaryReader BR = new System.IO.BinaryReader(MS)) {
                    requestID = new Guid(BR.ReadBytes(16));
                    int rc = BR.ReadInt32();
                    Console.WriteLine("Response contains {0} rows", rc);
                    System.Collections.Generic.List <BD2.Conv.Frontend.Table.Row> rows = new  System.Collections.Generic.List <BD2.Conv.Frontend.Table.Row> ();
                    for (int n = 0; n != rc; n++)
                    {
                        Row r = Row.Deserialize(BR.ReadBytes(BR.ReadInt32()));
                        rows.Add(r);
                    }
                    if (MS.ReadByte() == 1)
                    {
                        System.Runtime.Serialization.Formatters.Binary.BinaryFormatter BF = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                        object deserializedObject = BF.Deserialize(MS);
                        if (deserializedObject is Exception)
                        {
                            exception = (Exception)deserializedObject;
                        }
                        else
                        {
                            throw new Exception("buffer contains an object of invalid type, expected System.Exception.");
                        }
                    }
                    else
                    {
                        exception = null;
                    }
                    return(new GetRowsResponseMessage(requestID, rows, exception));
                }
            }
        }