Files
xEventService/Configuration/XEventServiceConfiguration.cs
2024-01-25 04:48:33 +03:30

51 lines
1.8 KiB
C#

using System.Collections.Generic;
using RabbitMQ.Client;
namespace xEventService.Configuration {
/// <summary>
/// a configuration class for describing how to connect rabbit mq server
/// and how channels must be declared ...
/// </summary>
public class XEventServiceConfiguration {
public string Server { get; set; }
public int Port { get; set; }
public string Username { get; set; }
public string Password { get; set; }
//
public bool AllowDynamicQueues { get; set; } = true;
public XQueueArgs DefaultQueueArgs { get; set; } = new XQueueArgs ();
public IDictionary<string, XQueueArgs> Queues { get; set; }
//
public bool AllowDynamicExchangess { get; set; } = true;
public XExchangeArgs DefaultExchangeArgs { get; set; } = new XExchangeArgs ();
public IDictionary<string, XExchangeArgs> Exchanges { get; set; }
//
public static XEventServiceConfiguration GetDefaults () {
return new XEventServiceConfiguration {
Port = 5672,
Username = "guest",
Password = "guest",
Server = "localhost",
Queues = new Dictionary<string, XQueueArgs> { { "XMainQueue", new XQueueArgs { Name = "XMainQueue" } }
}
};
}
}
public class XQueueArgs {
public string Name { get; set; }
public bool Durable { get; set; } = false;
public bool Exclusive { get; set; } = false;
public bool AutoDelete { get; set; } = true;
}
public class XExchangeArgs {
public string Name { get; set; }
public string Type { get; set; } = ExchangeType.Fanout;
public bool Durable { get; set; } = false;
public bool AutoDelete { get; set; } = true;
}
}