简体   繁体   English

WCF的接口和数据结构设计

[英]Interface and Datastructure design for WCF

I'm left with an old code that uses remoting. 我剩下一个使用远程处理的旧代码。 I need to upgrade this code to WCF. 我需要将此代码升级到WCF。

Quite frankly, I'm stuck on how to redesign the interface that client & server use for communication. 坦率地说,我坚持如何重新设计客户端和服务器用于通信的接口。 It looks like this: 看起来像这样:

public interface IDDCEngine
    {
        ReadDiagnosticEntirePointValuesResponse ReadDiagnosticEntirePointValues(string host);
        GetEntirePointListResponse GetEntirePointList(string host);

        SetSerialPortListResponse SetSerialPointList(string host, SetSerialPortList serialPortList);
        SetNationalListResponse SetNationalList(string host, SetNationalList nationalList, int count);
        SetModbusListResponse SetModbusList(string host, SetModbusList modbusList, int count);

        SetIOPointListResponse SetIOPointList(string host, SetIOPoint pointList, int count);
        GetIOPointResponse GetIOPointList(string host);
        SetLogicListResponse SetLogicList(string host, SetLogicList logicList, int count);
        GetDDCVersionResponse GetDDCVersion(string host);
        GetDDCUptimeResponse GetDDCUptime(string host);
        GetDDCCPUMemoryStatusResponse GetDDCCPUMemoryStatus(string host, int count);
        ...about 20 more interfaces
    }

And the classes for request/response: 以及请求/响应的类:

[Serializable]
    public class SetIOPoint
    {
        public string[] pointidentifier;
        public string[] pointname;
        public string[] pointaddress;
        public string[] pointtype;
        public string[] devicetype;
        public string[] description;
        public string[] backup;
        public string[] relinquishdefault;
        public string[] unit;
        public string[] minpresvalue;
        public string[] maxpresvalue;
        public string[] correctvalue;
        public string[] covenable;
        public string[] covincrement;
        public string[] covtarget;
        public string[] covlifetime;
        public string[] historyenable;
        public string[] historyincrement;
        public string[] alarmenable;
        public string[] highlimit;
        public string[] lowlimit;
        public string[] polarity;
        public string[] inactivetext;
        public string[] activetext;
        public string[] feedbackenable;
        public string[] feedbacktime;
        public string[] numofstates;
        public string[] statetext;
    }

    [Serializable]
    public class GetIOPointResponse
    {
        public string[] pointidentifier;
        public string[] pointname;
        public string[] pointaddress;
        public string[] pointtype;
        public string[] devicetype;
        public string[] description;
        public string[] backup;
        public string[] relinquishdefault;
        public string[] unit;
        public string[] minpresvalue;
        public string[] maxpresvalue;
        public string[] correctvalue;
        public string[] covenable;
        public string[] covincrement;
        public string[] covtarget;
        public string[] covlifetime;
        public string[] historyenable;
        public string[] historyincrement;
        public string[] alarmenable;
        public string[] highlimit;
        public string[] lowlimit;
        public string[] polarity;
        public string[] inactivetext;
        public string[] activetext;
        public string[] feedbackenable;
        public string[] feedbacktime;
        public string[] numofstates;
        public string[] statetext;
    }

    [Serializable]
public class RequestDDCRebootResponse
{
    public string result;
}

[Serializable]
public class GetDDCCurrenttimeResponse
{
    public string result;
}

[Serializable]
public class StartDDCBackupResponse
{
    public string result;
}

[Serializable]
public class EndDDCBackupResponse
{
    public string result;
}

[Serializable]
public class StartDDCRestoreResponse
{
    public string result;
}

[Serializable]
public class EndDDCRestoreResponse
{
    public string result;
}
...List goes ON

Pretty badly written interfaces and datastructure. 接口和数据结构写得很差。 I'd like to rewrite the interfaces and the datastructure so that I don't have to define millions of operationcontracts. 我想重写接口和数据结构,以便不必定义数百万个操作合同。

Are there any good recommendations on strategies of solid interface and datastructure design for WCF? 关于WCF的固态接口和数据结构设计策略是否有好的建议?

Take a look at this article: 看一下这篇文章:

Writing Highly Maintainable WCF Services 编写高度可维护的WCF服务

This article talks writing a WCF service as realy thin layer on top of an SOLIDly designed architectural pattern based on commands and queries . 本文讨论将WCF服务编写为基于命令查询SOLIDly设计的架构模式之上的真正的薄层。 When using this command/query style of programming, the WCF service can be defined as a really tiny piece of infrastructure code that won't have to be changed, even when new operations are added. 使用这种命令/查询样式的编程时,WCF服务可以定义为非常小的基础结构代码,即使添加了新操作,也无需更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM