【发布时间】:2014-01-14 12:35:46
【问题描述】:
我正在尝试将现有的 C# 项目移植到新的分布式项目,使用连接客户端和服务器组件的接口(它是一款用于大学练习的推箱子游戏)。
这是我的问题:
在一个组件中,比如说:Level.cs,我有:
Level.cs
namespace Sokoban
{
public enum MoveDirection { Right, Left, Down, Up }
public class Level
{
private MoveDirection sokoDirection = MoveDirection.Right;
...
}
...
}
另一方面,接口:
Interfaces.cs:
namespace Interfaces
{
public class ILevel : MarshalByRefObject
{
---> what should i place here??? <---
}
}
我尝试了以下选项但没有成功:
Interfaces.cs:
public virtual enum MoveDirection { get; set; }
public virtual enum MoveDirection() { throw new NotImplementedException(); }
Level.cs:
public static enum MoveDirection { return { Right, Left... }; }
public static enum MoveDirection { get { return { right, Left, ...}; } }
【问题讨论】:
-
你为什么使用
MarshalByRefObject?您是否尝试使用远程处理? Remoting 是一项遗留技术,为了向后兼容现有应用程序而保留,不建议用于新开发。现在应该使用 WCF 或 ASP.NET Web API 开发分布式应用程序。请参阅msdn.microsoft.com/en-us/library/vstudio/xws7132e.aspx 顶部的注释以获取证据。 -
嗨,约翰!感谢您的即时回复!
-
还有,为什么你使用
MarshalByRefObject? -
我将 Marshal 用于序列化目的。你是对的:我正在使用 Remoting。
-
为自己省去悲伤,别再那样做了。远程处理是古老的,早已被 WCF 取代。您应该尽快停止使用 Remoting。
标签: c# interface enums remoting .net-remoting