从 Public 枚举中删除值

Remove Value From Public Enum

我正试图从我的项目中的 public enum 中删除一个值。我遇到的问题是,每当我删除该值时,都会收到

错误

There is an error in XML document (1,2909)

阻止我删除元素的代码是什么?

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.6.1586.0")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http:Site")]
public enum TDOTT {

    /// <remarks/>
    AD,        
    /// <remarks/>
    AP,
    /// <remarks/>
    AT,
    /// <remarks/>
    AT1,
    /// <remarks/>
    AD1,
    /// <remarks/>
    ED,
    /// <remarks/>
    EP,
    /// <remarks/>
    SP,
}

如果需要更多代码,请告诉我,我很乐意提供。

编辑
这是删除元素时的样子(我是手动删除的)

public enum TDOTT {

    /// <remarks/>
    AD,        
    /// <remarks/>
    AP,
    /// <remarks/>
    AT,
    /// <remarks/>
    AT1,
    /// <remarks/>
    AD1,
    /// <remarks/>
    ED,
    /// <remarks/>
    EP,
}

这就是使用 C# 调用它的方式

foreach (TDOTT ts in td.DOT)
{
    Console.WriteLine("{0}: {1}", ts.T, ts.D);                                      
}

编辑 2
这是进一步的 C# 语法,以及在产生错误

的行上方的注释
    static void Main(string[] args)
    {
        List<string> tempList = new List<string> { "666288603319" };

        try
        {
            foreach (var trackingNumber in tempList)
            {
                TrackRequest request = CreateTrackRequest(trackingNumber);
                TrackService service = new TrackService();
                //The below line is hit and error is thrown
                TrackReply reply = service.track(request);
            }
        }
        catch (SoapException e)
        {
            Console.WriteLine(e.Detail.InnerText);
        }
    }
    private static TrackRequest CreateTrackRequest(string trackingNumber)
    {
        TrackRequest request = new TrackRequest();

        request.WebAuthenticationDetail = new WebAuthenticationDetail();
        request.WebAuthenticationDetail.UserCredential = new WebAuthenticationCredential();
        request.WebAuthenticationDetail.UserCredential.Key = usercredentialKEY;
        request.WebAuthenticationDetail.UserCredential.Password = usercredentialPassword;
        request.WebAuthenticationDetail.ParentCredential = new WebAuthenticationCredential();
        request.WebAuthenticationDetail.ParentCredential.Key = parentcredentialKEY;
        request.WebAuthenticationDetail.ParentCredential.Password = parentcredentialPassword;

        request.ClientDetail = new ClientDetail();
        request.ClientDetail.AccountNumber = AccountNumber;
        request.ClientDetail.MeterNumber = MeterNumber;

        request.TransactionDetail = new TransactionDetail();
        request.TransactionDetail.CustomerTransactionId = "any value";  //This is a reference field for the customer.  Any value can be used and will be provided in the response.

        request.Version = new VersionId();

        request.SelectionDetails = new TrackSelectionDetail[1] { new TrackSelectionDetail() };
        request.SelectionDetails[0].PackageIdentifier = new TrackPackageIdentifier();
        request.SelectionDetails[0].PackageIdentifier.Value = trackingNumber;

        request.SelectionDetails[0].PackageIdentifier.Type = TrackIdentifierType.TRACKING_NUMBER_OR_DOORTAG;
        request.SelectionDetails[0].ShipDateRangeBeginSpecified = false;
        request.SelectionDetails[0].ShipDateRangeEndSpecified = false;

        request.ProcessingOptions = new TrackRequestProcessingOptionType[1] { new TrackRequestProcessingOptionType() };
        request.ProcessingOptions[0] = TrackRequestProcessingOptionType.INCLUDE_DETAILED_SCANS;

        return request;
    }

编辑 3
这是 TrackRequest Class synatx

    public partial class TrackRequest {

    private WebAuthenticationDetail webAuthenticationDetailField;

    private ClientDetail clientDetailField;

    private TransactionDetail transactionDetailField;

    private VersionId versionField;

    private TrackSelectionDetail[] selectionDetailsField;

    private string transactionTimeOutValueInMillisecondsField;

    private TrackRequestProcessingOptionType[] processingOptionsField;

    /// <remarks/>
    public WebAuthenticationDetail WebAuthenticationDetail {
        get {
            return this.webAuthenticationDetailField;
        }
        set {
            this.webAuthenticationDetailField = value;
        }
    }

    /// <remarks/>
    public ClientDetail ClientDetail {
        get {
            return this.clientDetailField;
        }
        set {
            this.clientDetailField = value;
        }
    }

    /// <remarks/>
    public TransactionDetail TransactionDetail {
        get {
            return this.transactionDetailField;
        }
        set {
            this.transactionDetailField = value;
        }
    }

    /// <remarks/>
    public VersionId Version {
        get {
            return this.versionField;
        }
        set {
            this.versionField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("SelectionDetails")]
    public TrackSelectionDetail[] SelectionDetails {
        get {
            return this.selectionDetailsField;
        }
        set {
            this.selectionDetailsField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(DataType="nonNegativeInteger")]
    public string TransactionTimeOutValueInMilliseconds {
        get {
            return this.transactionTimeOutValueInMillisecondsField;
        }
        set {
            this.transactionTimeOutValueInMillisecondsField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute("ProcessingOptions")]
    public TrackRequestProcessingOptionType[] ProcessingOptions {
        get {
            return this.processingOptionsField;
        }
        set {
            this.processingOptionsField = value;
        }
    }
}

如果这个问题真的是关于 FedEx 开发人员 API 那么我将假设你的 public enum TDOTT 实际上是(直接从 FedEx API 文档)

    public enum TrackingDateOrTimestampType {

    /// <remarks/>
    ACTUAL_DELIVERY,        
    /// <remarks/>
    ACTUAL_PICKUP,
    /// <remarks/>
    ACTUAL_TENDER,
    /// <remarks/>
    ANTICIPATED_TENDER,
    /// <remarks/>
    APPOINTMENT_DELIVERY,
    /// <remarks/>
    ESTIMATED_DELIVERY,
    /// <remarks/>
    ESTIMATED_PICKUP,
    /// <remarks/>
    SHIP,
}

现在基于相同的假设,根据您的代码 posted 您想要排除 SP 这似乎等同于 SHIP

脱离上述假设,如果您 post 编辑了您的行抛出错误后出现的语法,它看起来像下面这样(我说的是因为我有修改我的以满足我的需要,但这会理解一般的想法)

static void Main(string[] args)
{
    //Pulled this from the example you gave
    List<string> tempList = new List<string> { "666288603319" };
        foreach (var trackingNumber in tempList)
        {
            TrackRequest request = CreateTrackRequest(trackingNumber);
            TrackService service = new TrackService();
            TrackReply reply = service.track(request);

            //Now here is where my syntax is set-up that should closely mirror what the FedEx API shows straight from the .zip
            if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING)
                foreach (CompletedTrackDetail completedTrackDetail in reply.CompletedTrackDetails)
                    foreach (TrackDetail trackDetail in completedTrackDetail.TrackDetails)
                        if (trackDetail.DatesOrTimes != null)
                        {
                            foreach (TrackingDateOrTimestamp timestamp in trackDetail.DatesOrTimes)
                                //if my assumption is accurate and you want to exclude ship add this
                                if (Convert.ToString(timestamp.Type) != "SHIP")
                                    Console.WriteLine("{0}: {1}", timestamp.Type, timestamp.DateOrTimestamp); 
                        }

现在看看我添加的注释,而不是试图修改一个 public enum ,它可能与语法中的多个位置相关联,所有这些都需要更改,这超出了您的编码经验,我建议根据 timestamp.Type

简单地通过 "filtering" 来修改它,就像我在上面显示的那样

供将来参考 如果您想收到 valid/helpful 回复,您需要包含准确的语法。如果它是敏感信息或个人信息,则可以更改语法(例如为跟踪号提供 XXX),但是当 FedEx API 源代码可免费下载时更改 public enum 是愚蠢的.我很少仔细阅读这些论坛,但自从最近学习 FedEx 后我准备剃光头 API - 我想我会插话。

如果我的任何假设不正确,请使用 FedEx API 的 ACCURATE 代码修改您的原始 post,我将能够协助(我相信还有很多其他人)。