• 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
    }

    }

  • 相关阅读:
    解决QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'问题
    error while loading shared libraries:libQt5SerialPort.so问题解决
    洛谷P4343 [SHOI2015]自动刷题机
    十一届山东省大学生程序设计竞赛 部分题解
    洛谷P4185 [USACO18JAN]MooTube G 题解
    洛谷P4588 [TJOI2018]数学计算
    洛谷P2085《最小函数值》
    多项式小记
    CF932F 【Escape Through Leaf】
    'ipconfig' 不是内部或外部命令,也不是可运行的程序 或批处理文件。持续思考ing
  • 原文地址:https://www.cnblogs.com/lanfeinigal/p/3163953.html
Copyright © 2020-2023  润新知