gpt4 book ai didi

c# - 我如何以编程方式在 resx 文件中创建另一个列

转载 作者:太空宇宙 更新时间:2023-11-03 21:18:29 27 4
gpt4 key购买 nike

描述:
我正在为 MultiLingualMultiOrganization CMS 编写字典。

目前我们正在使用数据库解决方案 (Sql Server),但由于数据库流量巨大,我们正在寻找替代解决方案,我找到了 .resx 文件。

在这里,我们将以编程方式创建 .resx 文件和一个 .resx 文件/语言。在每个 .resx 文件上,我们要添加一个 organizationId。您可以在下面看到英语语言的 .resx 文件。

我们想要 .resx 中的这种结构

Name    Value        Comment                   OrganizationIdAbout   About     this file is for english          1Login   Login     this file is for english          2

The scenario is that when in my cms a lang is added i will be creating a resource file with it which will contain the dictionary(English key , that language value) for the language.

Now everything would have gone as planned if one word would have one meaning but there is a requirement that Two organization can one have different meaning for a single word.

for example word hello will have meaning abc for organization1 and it will have meaning abc2 for organization2.

My Question:
1.How can I do this using .resx file and if its not possible using .resx file then what is the most efficient (speed,maintainance,flexibility) alternate for this scenario.

My Code:
Currently I am trying this sample:

             // Define a resource file named CarResources.resx. 
using (ResXResourceWriter resx = new ResXResourceWriter(@"D:\VSProjects\CreateResourceFile\CreateResourceFile\CarResources.resx"))
{

resx.AddResource(new ResXDataNode("About", "About"){ Comment = "this file is for english" });
resx.AddResource("Login", "Login");
resx.AddResource("News", "News");
resx.AddResource("Headline", "Headline");
resx.AddResource("Information", SystemIcons.Information);

}

最佳答案

Resx 文件具有严格的架构,它不包含您想要的其他字段。因此,即使您设法添加文件(即使用常规 XML API),标准 .Net 资源方法也可能无法处理此类修改后的文件。

根据您的需要,您可以使用完全自定义的 XML(LINQ-to-XML 提供了一种创建/读取 XML 文档的简单方法),或者如果您真的想使用 resx 文件 - 按组织分区文件(除了语言)喜欢

text.org1.en-us.resx
text.org2.en-us.resx
text.org1.fr.rest

关于c# - 我如何以编程方式在 resx 文件中创建另一个列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32482355/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com