0

我的核心应用程序中有这些代码

[System.Serializable()]
public enum FieldOfDiscipline : int
{
None = 0,
ArchitecturalEngineeringFacilitiesManagement = 1,
ArtsLibraryScienceServices = 2,
AssetManagement = 3,
BusinessCorporatePlanning = 4,
DataStatistics = 5,
ExecutiveAssistance = 6,
FinancialServices = 7,
HealthServices = 8,
HumanResourceTrainingServices = 9,
InformationTechnologyServices = 10,
InternalAudit = 11,
InternationalOperations = 12,
LegalInvestigationServices = 13,
LoansCreditOperations = 14,         
ManagerialExecutive = 15,
PaymentsSettlements = 16,
ProcurementServices = 17,
PublicRelationsCommunications = 18,
ResearchDevelopment = 19,
Others = 255
}

我在我的网络服务中使用它

现在,当我引用我的 Web 服务并在我的 Web 应用程序中使用枚举时,它给了我一个不同的整数值,所以我调查了我被引用的定义

#region Assembly App_WebReferences.3joumvby.dll, v2.0.50727
// C:\Users\Carlo\AppData\Local\Temp\Temporary ASP.NET Files\bsper.website\6db12346\_shadow\6f228f03\286299993\30323649\App_WebReferences.3joumvby.dll
#endregion

using System;
using System.CodeDom.Compiler;
using System.Xml.Serialization;

namespace BSPeR.ApplicationServiceProvider
{
    [Serializable]
    [XmlType(Namespace = "http://tempuri.org/")]
    [GeneratedCode("System.Xml", "4.0.30319.2022")]
    public enum FieldOfDiscipline
    {
        None = 0,
        ArchitecturalEngineeringFacilitiesManagement = 1,
        ArtsLibraryScienceServices = 2,
        AssetManagement = 3,
        BusinessCorporatePlanning = 4,
        DataStatistics = 5,
        ExecutiveAssistance = 6,
        FinancialServices = 7,
        HealthServices = 8,
        HumanResourceTrainingServices = 9,
        InformationTechnologyServices = 10,
        InternalAudit = 11,
        InternationalOperations = 12,
        LegalInvestigationServices = 13,
        LoansCreditOperations = 14,
        ManagerialExecutive = 15,
        PaymentsSettlements = 16,
        ProcurementServices = 17,
        PublicRelationsCommunications = 18,
        ResearchDevelopment = 19,
        Others = 20,
    }
}

注意到 Others 的整数值了吗?它从 255 更改为 20。

例如,当我使用此代码时

(int) FieldOfDiscipline.Others 它将返回一个整数值 20 而不是 255

如何获得原始值或我分配的值?

4

1 回答 1

1

WSDL 使用 XML 模式来描述数据类型。.NET 枚举(int 和标签)没有直接等效的 XML 架构数据类型,因此 .NET 将枚举表示为一组标签。因此,int 值不会出现在 Web 服务的服务描述 (WSDL + XSD) 中。我只能假设客户端代理生成过程(我假设是 svcutil)已经生成了自己的 int 值。

另请参阅类似的 Java 问题:WSDL 表示中的枚举类型

于 2013-09-17T16:47:13.170 回答