public static RabbitContext Create(this RabbitContext ctx, string fileName) { ctx = new RabbitContext(); var filePath = Path.Combine(@"Configuration", fileName); string fullFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filePath); string json = File.ReadAllText(fullFilePath); ctx = JsonConvert.DeserializeObject <RabbitContext>(json); return(ctx); }
public Receiver(RabbitContext ctx) { this.ctx = ctx; try { var factory = new ConnectionFactory() { VirtualHost = ctx.Connection.VirtualHost, HostName = ctx.Connection.HostName, UserName = ctx.Connection.UserName, Password = ctx.Connection.Password }; this.connection = Connection.Connect(); this.channel = connection.CreateModel(); } catch (Exception ex) { Console.WriteLine($"RabbitListener init error,ex:{ex.Message}"); throw ex; } }
public Sender(RabbitContext ctx) { this.ctx = ctx; }