/// <summary> /// 得到RabbitMQ的Meta信息 /// </summary> /// <param name="t">实体类型</param> /// <param name="exchangeName">Exchange名称</param> /// <param name="exchangeType">ExchangeType名称</param> /// <param name="queueName">Queue名称</param> /// <param name="routingKey">RoutingKey名称</param> /// <param name="type">type名称(EasyNetQ中.NET类型完全限定名)</param> public static void GetMetaInfo(Type t, out string exchangeName, out string exchangeType, out string queueName, out string routingKey, out string type) { RabbitMQMetaAttribute attribute = GetMetaAttribute(t); exchangeName = attribute.ExchangeName; exchangeType = attribute.ExchangeType; queueName = attribute.QueueName; routingKey = attribute.RoutingKey; type = attribute.Type; }
/// <summary> /// 得到RabbitMQ的Meta信息 /// </summary> /// <param name="type">实体类型</param> /// <returns></returns> private static RabbitMQMetaAttribute GetMetaAttribute(Type type) { RabbitMQMetaAttribute attribute = type.GetCustomAttributes(typeof(RabbitMQMetaAttribute), true).FirstOrDefault() as RabbitMQMetaAttribute; return(attribute ?? new RabbitMQMetaAttribute()); }