Hi there,
I have an enum field that I serialize:
[XmlAttribute("direction"), XmlText(typeof(ParameterDirection))]
public ParameterDirection Direction = ParameterDirection.Out;
The enum looks like this:
public enum ParameterDirection { In, Out, Both };
In the generated XML, the value has to be lowercase. But, since "In" is a
reserved word, I cannot have this as an enum value.
How can I do this in a generic way?
Any help appreciated,
Thanks,
Michel 2 2833
"Michel" <mi****@nospam.nl> wrote in message news:c0**********@reader11.wxs.nl... public enum ParameterDirection { In, Out, Both };
In the generated XML, the value has to be lowercase. But, since "In" is a reserved word, I cannot have this as an enum value.
How can I do this in a generic way?
The XmlEnumAttribute can be applied to the members of an Enum to
alter the text representation of their value emitted by XmlSerializer.
public enum ParameterDirection {
[XmlEnum( "in")] In,
[XmlEnum( "out")] Out,
[XmlEnum( "both")] Both
};
That should be all you need to make it work.
Derek Harmon
Thanks Derek,
Exactly what I needed.
"Derek Harmon" <lo*******@msn.com> wrote in message
news:uN****************@tk2msftngp13.phx.gbl... "Michel" <mi****@nospam.nl> wrote in message
news:c0**********@reader11.wxs.nl... public enum ParameterDirection { In, Out, Both };
In the generated XML, the value has to be lowercase. But, since "In" is
a reserved word, I cannot have this as an enum value.
How can I do this in a generic way?
The XmlEnumAttribute can be applied to the members of an Enum to alter the text representation of their value emitted by XmlSerializer.
public enum ParameterDirection { [XmlEnum( "in")] In, [XmlEnum( "out")] Out, [XmlEnum( "both")] Both };
That should be all you need to make it work.
Derek Harmon
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Anirudh |
last post by:
Hi,
i wanted to know if there is any way to convert an object to
XMlText to XMLElement. Thanks in advance.
|
by: Nikhil Patel |
last post by:
Hi all,
I am a VB6 programmer and learning C#. I am currently reading a chapter
on types. I have question regarding enums. Why do we need to convert enum
members to the value that they represent?...
|
by: Ken Allen |
last post by:
The ToString() function, when applied to a variable that is an enumeration
type, results in a string that is the name of the enumerated value that was
defined in the source code. This is cool, but...
|
by: Sanjay Pais |
last post by:
I know that string/char enum is not possible in c# (.NET2.0)
I need to create the equivalent of this:
public enum HOW_GOOD
{
AWESOME = "A",
GREAT= "G",
NOT_TOO_BAD = "N",
TERRIBLE="T"
}
|
by: thejeffross |
last post by:
I have a memory problem that keeps causing server resets, so I'm using
WinDbg to figure out what the problem is.
When I look at the heap, WinDbg tells me that there are over one
million XmlText...
|
by: Joe HM |
last post by:
Hello -
I have two Enums for which I would like to define type conversions ...
Public Enum eA
A2 = 0
A2 = 1
End Enum
Public Enum eB
B1 = 2
|
by: None |
last post by:
I'm trying to mark up an enum in a .h file such that when it is emitted
to the .idl file the elements of the enum can be marked up with
helpstring attributes.
Microsoft has a published sample...
|
by: Steven Nagy |
last post by:
So I was needing some extra power from my enums and implemented the
typesafe enum pattern.
And it got me to thinking... why should I EVER use standard enums?
There's now a nice little code...
|
by: Chevron Boyde |
last post by:
Hi There
I have some codes that represent Sale Types i.e. A = On Account, C = Cash, D
= Debtor, V = Voucher
I want to create an enum or struct to work with the logical names like
"Cash" as...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |