gpt4 book ai didi

c# - 定义接口(interface)

转载 作者:太空狗 更新时间:2023-10-29 21:47:54 25 4
gpt4 key购买 nike

我有一个由多个应用程序使用的数据模型,我现在需要由团队外的其他开发人员使用。该模型应该只对开发人员部分可用。

我想知道如何最好地解决这个问题:我目前的方法是创建一个新项目,它只复制原始模型并且只包含请求的属性。

例如

namespace Model
{
public class Car
{
private double m_speed;
private FuelType m_fuelType;

public double Speed
{
get { return m_speed; }
set { m_speed = value; }
}


public FuelType FuelType
{
get { return m_fuelType; }
set { m_fuelType = value; }
}
}
}

在我的精简版模型中,我只想公开速度:

using Model;

namespace ModelLite
{
public class Car
{
private Model.Car car = new Model.Car();

public double Speed
{
get { return this.car.Speed; }
set { this.car.Speed = value; }
}

}
}

由于模型很大,因此涉及大量重复。也许有更好的选择?

谢谢

最佳答案

看看 Martin Fowler 在 Application Facades 上的作品和 Facade Pattern

关于c# - 定义接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2085361/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com