English 中文(简体)
从 SQL 表格构建 C# dll
原标题:Build C# dll from SQL table

I have a SQL-table with three columns: Id, English and Norwegian. Id is the primary key. In my application I have a flag (EN/NO) to decide which language to use for labels, buttons ++ in the GUI. The application is now doing a select * everytime the application loads, and the application is looking up all required values at runtime. But instead of loading the whole dataset for every instance, i want to export these values and create a dll so i can store these values locally.

有没有可能创建此代码, 使 Dll 会随着每栋建筑而更新自己? 还是我必须运行一些外部程序才能动态创建 ex. a. cs 代码才能复制/ 粘贴到我的班级? (我需要能够重新运行此进程, 因为每次需要新标签/ 文本时都会添加行)

到目前为止,我已想出三种解决方案 如何构建我的出口结构, 但对于如何输出数据却一无所知:

  1. 维护数据表在静态背景下的状况,并提供帮助方法,使取出值的方法标准化。

  2. 创建一个包含每个独特的代号为方法名的分类, 以及一个参数, 以决定返回的值 :

    public static class Names
    {
      public static string 12345(string language)
      {
        switch (language)
        {
            case "EN":
                return "Hello";
            case "NO":
                return "Hei";
            default:
                return "Hello";
        }
      }
    }
    
  3. 创建一个包含每种语言的可搜索列表的分类, ID为密钥和值( 作为值)

最佳回答

为何不为不同语言创建不同的资源文件, 并随设置而加载合适的文件 。 您可以使用 < a href=" http:// msdn.microsoft.com/ en- us/library/ system. refources. refources. rel=" nofollow norefererr"\\ code> System. resources. resourcesManager . < a href=" http://www.codeproject.com/ artess/5208/ MultiLanguage- Applications" rel=" nofolveinn noreferr" 这条 < a> 详细解释了这一点 。

EDIT:以下的SO文章也详细讨论这个问题, 在C#/WinForms中采用多种语言应用的最佳做法?

问题回答

不,我不喜欢把国际化字符串放入课堂图书馆的想法, 为什么你不使用 < a href=" http://www.codeproject.com/articles/43160/globalization-Internationalization- I18N-and-Collidi" rel = "nofollow".

资源文件是最好的解决方案, 而不是类库 。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签