Override Enum Type Web Service Usage Type

I actually consume the web service in a console application in C # .NET. And this service is written in PHP, and I have no sources. So, there Enum types have everything they want: "?" "" numebrs, string ...

So, when it is interpreted by my application, I have: Item, Item0 ... with XmlAttribute.

I want to know: is it possible to have a class that overrides these enumerations in order to replace the "dot" with ".". and others that are not deleted every time I update my web link?

thanks for your reply

+1
source share
1 answer

Well, I'm not very sure that you can override the enumeration that is created when creating the service link.

Perhaps this solution is for you:

When a service link is created, the generated .cs file is a partial class. You can create yourself another partial class with the same namespace. Inside this class, you can create a method or property that returns a converted enumeration type. This file will not be overridden when updating the help service.

Example:

(Reference class of generated services)

public partial class ServiceReferenceComplexType { public enum EnumValues { Item0, Item1, Item2 } } 

(Self created partial class)

 public partial class ServiceReferenceComplexType { public string GetCorrectEnumValue() { // Do your enum logic magic. EnumValues.Tostring(); } } 

Now you can use the ServiceReferenceComplexType.GetCorrectEnumValue () method to get your value.

0
source

Source: https://habr.com/ru/post/1480430/


All Articles