![](/img/trans.png)
[英]Can I turn off NHibernate ShowSQL after initial configuration (at runtime)
[英]How can i turn attributes on or off in XML configuration class?
我的XML配置文件的一部分看起來像這樣
<Formatting Mode="Format1">
<FormatterSettings Range="Range1" Restriction="None" Padding="0" />
</Formatting>
<Formatting Mode="Format2">
<FormatterSettings Range="Range3" Restriction="None" Padding="0" />
</Formatting>
我的課看起來像這樣
public class Formatting
{
[XmlAttribute("Mode")]
public FormatterType Mode { get; set; }
public FormatterSettings FormatSettings { get; set; }
}
public class FormatterSettings
{
[XmlAttribute("Range")]
public CharacterRange CharRange { get; set; }
[XmlAttribute("Restriction")]
public CharacterRangeRestriction RestrictRange { get; set; }
[XmlAttribute("Padding")]
public int Padding { get; set; }
}
但是我有一個特殊的格式化程序,它只有一個設置,所以我需要XML看起來像
<Formatting Mode="DateFormatter">
<FormatterSettings DateFormat="yyyyMMdd" />
</Formatting>
因此,在這種特殊情況下,我的班級將是沒有其他設置的,但是我只希望一個班級,如果可能的話,兩者都可以。
public class FormatterSettings
{
[XmlAttribute("DateFormat")]
public string DateFormat{ get; set; }
}
我怎樣才能做到這一點?
關於什么
public class FormatterSettings
{
[XmlAttribute("Range")]
public CharacterRange CharRange { get; set; }
[XmlAttribute("Restriction")]
public CharacterRangeRestriction RestrictRange { get; set; }
[XmlAttribute("Padding")]
public int Padding { get; set; }
[XmlAttribute("DateFormat")]
public string DateFormat{ get; set; }
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.