private static Dictionary <IColumn, object> GetYapperColumnValues(object dataContract)
        {
            PropertyInfo[] propertyInfoArray          = dataContract.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
            Dictionary <IColumn, object> columnValues = new Dictionary <IColumn, object>();

            foreach (PropertyInfo propInfo in propertyInfoArray)
            {
                IEnumerable <Attribute> attrs = propInfo.GetCustomAttributes();
                if (attrs == null)
                {
                    continue;
                }

                foreach (Attribute a in attrs)
                {
                    if (a is YapperColumnAttribute)
                    {
                        YapperColumnAttribute yapperColumn = a as YapperColumnAttribute;

                        IColumn column = MessageTable.GetColumnFromName(yapperColumn.Name);
                        if (column != null)
                        {
                            columnValues.Add(column, DataContractToTableRowConverter.Convert(propInfo.GetValue(dataContract), column.Type));
                        }
                    }
                }
            }

            return(columnValues);
        }
        public static TableRow ConvertToTableRow(this Message dataContract)
        {
            if (!DataContractToTableRowConverter.CheckIfDataContract(dataContract.GetType()))
            {
                return(null);
            }

            return(new MessageTableRow(DataContractToTableRowConverter.GetYapperColumnValues(dataContract)));
        }
        public static Message ConvertToMessage(ITable table, ITableRow tableRow)
        {
            Message message = null;

            if (table.BlobValueColumn != null)
            {
                byte[] value = (byte[])tableRow.ColumnValues[table.BlobValueColumn];
                message = MessageSerializer.DeSerializeFromProtocolBuffer(value);
            }
            else
            {
                message = new Message();
            }

            DataContractToTableRowConverter.SetYapperColumnValues(message, tableRow);

            return(message);
        }