我在我们的服务器解决方案中有一个枚举值:
public enum TaskStatus
{
//Description attribute modifies how an Enum's label is displayed when displayed via MVC.
[Description("Draft")]
Draft = 1,
[Description("Being Planned")]
BeingPlanned = 2,
[Description("Waiting For Change")]
WaitingForChange = 3,
[Description("In Progress")]
InProgress = 4,
[Description("Waiting For Customer Information")]
WaitingCustomerInformation = 5,
[Description("Cancelled")]
Cancelled = 6,
[Description("Completed")]
Completed = 7
};
此枚举值被序列化并作为 WCF 服务引用传递给客户端。
然后我在模型中显示 Enum 值。然而,我注意到在序列化/反序列化过程中,Description 属性已被删除。
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.450")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.cormant.com/cswebapi")]
public enum TaskStatus {
/// <remarks/>
Draft,
/// <remarks/>
BeingPlanned,
/// <remarks/>
WaitingForChange,
/// <remarks/>
InProgress,
/// <remarks/>
WaitingCustomerInformation,
/// <remarks/>
Cancelled,
/// <remarks/>
Completed,
}
我仍然希望能够描述我的枚举应该如何显示给最终用户。是否有可能做到这一点?反序列化后可以重新应用属性吗?