1
yhj
2024-07-24 5e5d945e91568b973faa27d8ab0bcef99fc4a6c5
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
55
56
57
58
59
60
61
62
63
64
65
#region
 
using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Channels;
using CSFrameworkV5.WCFContract.WCF_Class;
 
#endregion
 
namespace CSFrameworkV5.WCFContract
{
    public static class WCFServiceProvider
    {
        public static Binding CreateBinding(BindingType type)
        {
            if (BindingType.BasicHttpBinding == type)
                return new BasicHttpBinding("BasicHttpBinding");
 
            if (BindingType.NetTcpBinding == type)
                return new NetTcpBinding("NetTcpBinding");
 
            if (BindingType.wsHttpBinding == type)
                return new WSHttpBinding("WSHttpBinding");
 
            throw new NotImplementedException();
        }
 
        /// <summary>
        ///     获取WCF服务的接口
        /// </summary>
        /// <param name="classType"></param>
        /// <returns></returns>
        public static Type GetWCFInterfaceType(Type classType)
        {
            if (classType == typeof(CommonService))
                return typeof(ICommonService);
 
            if (classType == typeof(DataDictService))
                return typeof(IDataDictService);
 
            if (classType == typeof(MessageCenter))
                return typeof(IMessageCenter);
 
            if (classType == typeof(SystemSecurityService))
                return typeof(ISystemSecurityService);
 
            return null;
        }
 
        /// <summary>
        ///     获取WCF服务的类
        /// </summary>
        /// <returns></returns>
        public static List<Type> GetWCFServiceType()
        {
            var list = new List<Type>();
            list.Add(typeof(CommonService));
            list.Add(typeof(DataDictService));
            list.Add(typeof(MessageCenter));
            list.Add(typeof(SystemSecurityService));
            return list;
        }
    }
}