我通过以下代码从资源中设置DisplayFormat中的NullDisplayText
public class LocalizedDisplayFormatAttribute : DisplayFormatAttribute
{
private readonly PropertyInfo _propertyInfo;
public LocalizedDisplayFormatAttribute(string resourceKey, Type resourceType)
: base()
{
this._propertyInfo = resourceType.GetProperty(resourceKey, BindingFlags.Static | BindingFlags.Public);
if (this._propertyInfo == null)
{
return;
}
base.NullDisplayText = (string)this._propertyInfo.GetValue(this._propertyInfo.DeclaringType, null);
}
public new string NullDisplayText
{
get
{
return base.NullDisplayText;
}
set
{
base.NullDisplayText = value;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我使用的默认文化是"en-US",一旦我将文化更改为es-AR并加载页面工作正常,但是当我将文化更改回en-US时,字段不会被转换回来.
我通过以下方式改变文化
protected void Application_AcquireRequestState(object sender, EventArgs e)
{
try
{
HttpCookie cookie = HttpContext.Current.Request.Cookies.Get("CurrentCulture");
string culutureCode = cookie != null && !string.IsNullOrEmpty(cookie.Value) ? cookie.Value …Run Code Online (Sandbox Code Playgroud) 我有两个具有相同基本格式的XML文件,但Master.XML中的一些标记和属性未包含在Child.XML中.
我需要将XML文件合并到一个缺少标签和属性的新XML文件中.
如果Master.XML和Child.XML中的值不同,则应使用Child.XML中的值.
我尝试使用Union和Concat与节点,但它不起作用.
master.DescendantNodes().Union(child.DescendantNodes());
Run Code Online (Sandbox Code Playgroud)
任何建议都会有所帮助.
Master.XML
<SysConfig IsRuntime="False" BarcodeEnabled="false" version="1.2.0.0">
<DbPath>C:\Agilent_i1000\ICPT_DB.sqlite</DbPath>
<CardDiagonsticsDelayTime>10</CardDiagonsticsDelayTime>
<ScreenSpecs NameID="CoreID" XrelativeID="X" YrelativeID="Y">
<ScreenSpec Name="MainCtrlPanel" Xrelative="0" Yrelative="0" ></ScreenSpec>
<ScreenSpec Name="1" Xrelative="75" Yrelative="0" NotToUse="1"></ScreenSpec>
<ScreenSpec Name="2" Xrelative="75" Yrelative="25" NotToUse="1"></ScreenSpec>
</ScreenSpecs>
</SysConfig>
Run Code Online (Sandbox Code Playgroud)
Child.XML
<SysConfig IsRuntime="False" BarcodeEnabled="false" version="1.2.0.0">
<CardDiagonsticsDelayTime>20</CardDiagonsticsDelayTime>
<ScreenSpecs NameID="CoreID" XrelativeID="X" YrelativeID="Y">
<ScreenSpec Name="MainCtrlPanel" Xrelative="0" Yrelative="0" ></ScreenSpec>
<ScreenSpec Name="1" Xrelative="100" Yrelative="0" ></ScreenSpec>
<ScreenSpec Name="2" Xrelative="75" Yrelative="25"></ScreenSpec>
<ScreenSpec Name="3" Xrelative="175" Yrelative="25"></ScreenSpec>
</ScreenSpecs>
</SysConfig>
Run Code Online (Sandbox Code Playgroud)
预期产出
<SysConfig IsRuntime="False" BarcodeEnabled="false" version="1.2.0.0">
<DbPath>C:\Agilent_i1000\ICPT_DB.sqlite</DbPath>
<CardDiagonsticsDelayTime>20</CardDiagonsticsDelayTime>
<ScreenSpecs NameID="CoreID" XrelativeID="X" YrelativeID="Y">
<ScreenSpec Name="MainCtrlPanel" Xrelative="0" …Run Code Online (Sandbox Code Playgroud)