2010-04-15 72 views
1

我有一个枚举和成员键入它C#标志枚举分隔符

[Flags] 
public enum SearchFilter 
{ 
    types = 0x01, 
    attributes = 0x02, 
    methods = 0x04 
} 
[System.Xml.Serialization.XmlAttribute("search-filter")] 
public SearchFilter search_filter = SearchFilter.types | SearchFilter.attributes | SearchFilter.methods; 

时,序列化该类结果属性将是这样的:

<filter search_filter="types attributes methods" /> 

但需要属性:

<filter search_filter="types|attributes|methods" /> 

类的序列化时如何更改分隔符?

回答

2

你将不得不采取的完全控制权,然后 - 比如我标志着成员作为[XmlIgnore]并增加了公共财产string如:

[XmlAttribute("search-filter")] 
public string SearchShim { 
    get { /* translate */ } 
    set { /* translate */ } 
}