我想为我创建一个.dll文件,以使我的工作更轻松,但我想让邀请看起来像CLASS.FUNCTION.FOO.BAR()
,但我只能使它看起来像CLASS.Function()
。
public static class CLASS {
public static void Fuction_name() {
//What do I have to write here for it?
}
}
你认为我应该怎么做?
答案 0 :(得分:1)
你看起来像这样:
public class CarModelBuilder()
{
// prevent from creating this directly
private CarModelBuilder()
{
}
public static CarModelBuilder Build()
{
return new CarModelBuilder();
}
public CarModelBuilder Wheel(Wheel wheel)
{
// add wheel here
return this;
}
public CarModelBuilder Door(Door door)
{
// add door here
return this;
}
public CarModelBuilder Engine(Engine engine)
{
// add engine here
return this;
}
// etc
// completion
public Car Complete()
{
// complete modelling here
return new Car();
}
}
用法:
var car = CarModelBuilder
.Build()
.Wheel(new Wheel())
.Door(new Door())
.Engine(new Engine())
// more spare parts here
.Complete();