C# Flag Enum delimiter
I have an Enum and member it type
[Flags]
public enum SearchFilter
{
types = 0x01,
attributes = 0x02,
methods = 0x04
}
[System.Xml.Serialization.XmlAttribute("search-filter")]
public开发者_StackOverflow中文版 SearchFilter search_filter = SearchFilter.types | SearchFilter.attributes | SearchFilter.methods;
when serialize this class result attribute will be like that:
<filter search_filter="types attributes methods" />
but need attribute:
<filter search_filter="types|attributes|methods" />
how can change delimiter when class serializing?
You're going to have to take complete control of it, then - for example my marking that member as [XmlIgnore]
and adding a public string
property such as:
[XmlAttribute("search-filter")]
public string SearchShim {
get { /* translate */ }
set { /* translate */ }
}
精彩评论