所以我有一个处理文件信息的类,根据文件信息,它将以两种可能的方式之一存储。决定处理文件的两个中的哪一个将基于枚举。
public class Route1
{
public enum Route1Type
{
OneWay,
TwoWay
};
}
其他枚举类:
public class Route2
{
public enum Route2Type
{
publicMade,
privateMade
};
}
处理枚举的主要课程:
public class MyClass
{
private MyService _Svc;
public IOtherClass OtherClass{ get; private set; }
public enum Route2Type { publicMade, privateMade }
public enum Route1Type { OneWay, TwoWay}
public MyClass(MyService svc, Route2Type route2Type)
{
_Svc = svc;
//retrieve from MyService for the route2 type configuration based on the enum
//retrieve from MyService the route1 type
/*if (route2Type.Equals(route1Type.OneWay))
OtherClass= new OtherClass.OneWay();
else
OtherClass= new OtherClass.TwoWay();
*/
}
我迷失在何处开始思考如何实现评论中的内容。任何帮助都会很棒。
单向()
public OneWay(string user, string password, string aurl)
{
_resource = new Resource(new WebdavSession(new NetworkCredential(user, password)), aurl);
_aurl = aurl;
_user = user; }
双向
public TwoWay(string aPath)
{
_aPath = aPath;
}
为MyService
public MyService(Guid AGuid, Guid BGuid)
{
_aGuid = AGuid;
_bGuid = BGuid;
}
答案 0 :(得分:0)
你只想验证route2Type有哪个枚举值?
if(route2Type == Route2Type.publicMade)
OtherClass= new OtherClass.OneWay();
else
OtherClass= new OtherClass.TwoWay();