我将使用 WebForms 制作一个词汇表(用于 N 种语言),我将为我的所有 Web 应用程序共享。
像 MyLanguages.cs。然后我将创建静态方法来获取我的话。但是我不会将它用于我的所有应用程序,只为所有应用程序提供一个(一个在内存中,而不是 N)。
您可以向我建议的最佳策略是什么?
例子
这应该是我的课:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public class Vocabulary
{
public const string HelloEnglish = "Hello";
public const string HelloItalian = "Ciao";
public Vocabulary()
{
}
}
而且,在我的 Web 应用程序的任何地方,我都想调用:
Vocabulary.HelloEnglish;
无需为每个 Web 应用程序复制和继承该类,这始终是相同的……浪费资源……还因为它会增长……