示例#1
0
    private static void PublishMessage(IModel channel, string routingKey)
    {
        var messageBody = new BahyrWithBacon()
        {
            Name = "Bahyr", Description = "Delicious"
        }.Serialize();

        channel.BasicPublish("topic_logs", routingKey, null, messageBody);
        Console.WriteLine(" [x] Sent '{0}':'{1}'", routingKey, "Bahyr");
        Console.ReadLine();
    }
    public static BahyrWithBacon DeserializeToBacon(byte[] data)
    {
        var result = new BahyrWithBacon();

        using (MemoryStream m = new MemoryStream(data))
        {
            using (BinaryReader reader = new BinaryReader(m))
            {
                result.Description = reader.ReadString();
                result.Name        = reader.ReadString();
            }
        }
        return(result);
    }