wcf host service

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ServiceModel;

namespace Sleven.WcfConHost
{
/// <summary>
/// wcf ServiceHost 添加的服务类
/// </summary>
public class Service
{
/// <summary>
/// 服务类型(接口);面向接口编程
/// </summary>
Type ServiceType { get; set; }

/// <summary>
/// 提供服务的主机,默认为null
/// </summary>
ServiceHost Host { get; set; }

/// <summary>
/// Http服务配置, 默认为new HttpServiceConfig();
/// </summary>
HttpServiceConfig HttpServiceConfig{get;set;}


}

/// <summary>
/// http 服务配置
/// </summary>
public class HttpServiceConfig
{
/// <summary>
/// 是否是HTTP服务
/// </summary>
/// <value>
/// <c>true</c> if this instance is HTTP; otherwise, <c>false</c>.
/// </value>
public bool IsHttp { get; set; }

/// <summary>
/// HTTP服务端口号
/// </summary>
/// <value>
/// The port.
/// </value>
public int Port { get; set; }
}

/// <summary>
/// TCP 服务配置
/// </summary>
public class TcpServiceConfig
{}

/// <summary>
/// 服务配置
/// </summary>
public class ServiceConfig {

/// <summary>
/// 服务配置类型
/// </summary>
ServiceConfigType ServiceConfigType { get; set; }

/// <summary>
/// 服务端口号
/// </summary>
/// <value>
/// The port.
/// </value>
public int Port { get; set; }

}

/// <summary>
/// 生成Wcf相关服务
/// </summary>
public class LoadService
{

private static readonly List<Service> Services = new List<Service>();

static LoadService()
{
//TODO:新增服务,在此新增服务,按此格式

//审核
// Services.Add(new Service { Type = typeof(IAuditService), ImplType = typeof(AuditService), Name = AuditServiceName });
//客户端验证
//Services.Add(new Service { Type = typeof(IClientService), ImplType = typeof(ClientService) });
}

public static List<Service> GServices
{
get { return Services; }
}
}

/// <summary>
/// 服务配置类型枚举 0:NetTcp; 1:BasicHttp; 2:WsHttp
/// </summary>
public enum ServiceConfigType : short {
/// <summary>
/// NetTcp,对应NetTcpBinding
/// </summary>
NetTcp = 0,
/// <summary>
/// BasicHttp,对应BasicHttpBinding
/// </summary>
BasicHttp = 1,
/// <summary>
/// BasicHttp,对应WsHttpBinding
/// </summary>
WsHttp = 2
}

}

原文地址:https://www.cnblogs.com/lanfeinigal/p/3163953.html