tangxu
2023-03-20 3bf8bf5179de8b83bbd6ad997e82d98302abd1c3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
 
namespace IStation.RunQueueFactory
{
    public sealed partial class DataAccess
    {
        private const string DllName_RabbitMq = "IStation.RunQueue4RabbitMq";//RabbitMq DLL 名称
        private const string DllName_Kafka = "IStation.RunQueue4Kafka";//Kafka DLL 名称
 
        //获取DLL名称
        private static string DllName
        {
            get
            {
                var selector = Settings.Queue.Selector_Run.ToUpper();
                if (selector == Queue.RabbitMq.ToUpper())
                {
                    return DllName_RabbitMq;
                }
                if (selector == Queue.Kafka.ToUpper())
                {
                    return DllName_Kafka;
                }
                return default;
            }
        }
 
        /// <summary>
        /// 创建QUEUE
        /// </summary>
        public static I CreateQueue<I>()
        {
            var type = typeof(I);
            var className = string.Format("{0}.{1}", "IStation.RunQueue", type.Name.Remove(0, 1));
            var obj = Assembly.Load(DllName).CreateInstance(className);
            return (I)obj;
        }
 
 
 
 
 
 
 
 
 
 
    }
}