本文整理汇总了C#中ResourceManager.GetString方法的典型用法代码示例。如果您正苦于以下问题:C# ResourceManager.GetString方法的具体用法?C# ResourceManager.GetString怎么用?C# ResourceManager.GetString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResourceManager
的用法示例。
在下文中一共展示了ResourceManager.GetString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IgnoreCase
public static void IgnoreCase(string key, string expectedValue)
{
var manager = new ResourceManager("System.Resources.Tests.Resources.TestResx", typeof(ResourceManagerTests).GetTypeInfo().Assembly);
var culture = new CultureInfo("en-US");
Assert.False(manager.IgnoreCase);
Assert.Equal(expectedValue, manager.GetString(key, culture));
Assert.Null(manager.GetString(key.ToLower(), culture));
manager.IgnoreCase = true;
Assert.Equal(expectedValue, manager.GetString(key, culture));
Assert.Equal(expectedValue, manager.GetString(key.ToLower(), culture));
}
示例2: GetString_FromResourceType
public static void GetString_FromResourceType(string key, string expectedValue)
{
Type resourceType = typeof(Resources.TestResx);
ResourceManager resourceManager = new ResourceManager(resourceType);
string actual = resourceManager.GetString(key);
Assert.Equal(expectedValue, actual);
}
示例3: GetString
/// <summary>
/// reads a string from the resource associated with this assembly and then returns it
/// </summary>
/// <param name="ResourceStringName">the name of the string to read</param>
/// <returns>returns the string</returns>
public static string GetString(string ResourceStringName)
{
ResourceManager ResourceMngr = new ResourceManager(BaseResourceName, Assembly.GetExecutingAssembly());
// get the string from the resource and return it
return ResourceMngr.GetString(ResourceStringName);
}
示例4: Main
static void Main(string [] args)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo ("es-ES");
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
ResourceManager temp = new ResourceManager("ConsoleApplication1.Resources", typeof(gdb).Assembly);
string res = temp.GetString ("String1");
//string res = ConsoleApplication1.Properties.Resources.String1;
Console.WriteLine (res);
}
示例5: Main
public static void Main(String[] a)
{
ResourceManager FormResources = new ResourceManager("StringTable", Assembly.GetExecutingAssembly());
string Message;
Message = FormResources.GetString("Message");
MessageBox.Show(Message);
}
示例6: Main
static int Main ()
{
ResourceManager resMgr = new ResourceManager ("res",
Assembly.GetExecutingAssembly ());
if (resMgr.GetString ("ProbableCause") != "Mögliche Ursache:")
return 1;
return 0;
}
示例7: GetLocalizedString
protected override string GetLocalizedString(string value)
{
if (this.resourceSet.Length > 0)
{
ResourceManager manager = new ResourceManager(this.resourceSet, Assembly.GetExecutingAssembly());
return manager.GetString(value);
}
return SR.GetString(value);
}
示例8: Main
public static void Main(string[] args)
{
var resources = new ResourceManager("ReadFromResources.Program", Assembly.Load(new AssemblyName("ReadFromResources")));
Console.WriteLine(resources.GetString("HelloWorld"));
Console.WriteLine(resources.GetString("HelloWorld", new CultureInfo("fr-FR")));
Console.WriteLine(resources.GetString("HelloWorld", new CultureInfo("de")));
resources = new ResourceManager("ResourcesLibrary.Test", Assembly.Load(new AssemblyName("ResourcesLibrary")));
Console.WriteLine(resources.GetString("Welcome", new CultureInfo("fr-FR")));
var edmAssembly = Assembly.Load(new AssemblyName("Microsoft.Data.Edm"));
var edmResource = new ResourceManager("Microsoft.Data.Edm", edmAssembly);
Console.WriteLine(edmResource.GetString("Bad_AmbiguousElementBinding"));
Console.WriteLine(edmResource.GetString("Bad_AmbiguousElementBinding", new CultureInfo("fr")));
var testClass = new TestClass();
Console.WriteLine(testClass.Print());
}
示例9: runTest
Boolean runTest()
{
ResourceManager manager = new ResourceManager("co8651publicresources", this.GetType().Assembly);
if (manager == null)
return false;
if (manager.GetString("1")!= "2")
return false;
Console.WriteLine("pass");
Environment.ExitCode = 0;
return true;
}
示例10: GetLocalizedString
protected override string GetLocalizedString(string value)
{
if (this.resourceSet.Length > 0)
{
ResourceManager rm = new ResourceManager(resourceSet, Assembly.GetExecutingAssembly());
String localizedString = rm.GetString(value);
System.Diagnostics.Debug.Assert(localizedString != null, string.Format(CultureInfo.CurrentCulture, "String resource {0} not found.", new object[] { value }));
return localizedString;
}
else
{
return SR.GetString(value);
}
}
示例11: Main
static int Main()
{
Assembly assembly = Assembly.GetExecutingAssembly();
ResourceManager resx = new ResourceManager("CsConsoleApp.Resources", assembly);
string greeting = resx.GetString("Greeting");
Console.WriteLine(greeting);
Console.WriteLine("CsConsoleApp");
CsSharedLib lib = new CsSharedLib();
lib.DoIt();
return 0;
}
示例12: runTest
Boolean runTest()
{
ResourceManager manager = new ResourceManager("test", this.GetType().Assembly);
try
{
String str1 = manager.GetString("1");
return false;
}
catch(MissingManifestResourceException)
{
}
catch(Exception ex)
{
Console.WriteLine(ex.GetType().Name);
return false;
}
Console.WriteLine("pass");
return true;
}
示例13: GetText
internal static string GetText(string lang, Control control)
{
try
{
string text;
switch (lang.ToLower())
{
case "de":
case "de-de":
case "en":
case "en-us":
var resManager = new ResourceManager(ResourcesNamespace + ".LangResources." + lang, Assembly.Load(Assembly.GetEntryAssembly().GetName().Name));
text = resManager.GetString(control.Name);
break;
default:
try
{
if (_xmlLang != lang)
{
_xmlLang = lang;
XmlData.Load(PathEx.Combine(PathEx.LocalDir, ResourcesNamespace == "AppsLauncher" ? $"Langs\\{lang}.xml" : $"..\\Langs\\{lang}.xml"));
}
text = XmlData?.DocumentElement?.SelectSingleNode(XmlKey + control.Name)?.InnerText;
text = text?.RemoveText("\\r").Replace("\\n", Environment.NewLine);
}
catch
{
text = GetText("en-US", control);
}
break;
}
if (!string.IsNullOrWhiteSpace(text))
return text;
}
catch (Exception ex)
{
Log.Write(ex);
}
return control.Text;
}
示例14: GetUserStatus
public static string GetUserStatus(int UserID)
{
string RetVal = "";
Hashtable UserStatusList = new Hashtable();
HttpContext context = HttpContext.Current;
if(context != null && context.Items.Contains(sUserStatus))
UserStatusList = (Hashtable)context.Items[sUserStatus];
if (UserStatusList.ContainsKey(UserID))
{
RetVal = UserStatusList[UserID].ToString();
}
else
{
ResourceManager LocRM = new ResourceManager("Mediachase.UI.Web.App_GlobalResources.UserReports.GlobalModules.Resources.strTemplate", typeof(CommonHelper).Assembly);
string UserName = "";
string path = HttpRuntime.AppDomainAppVirtualPath;
if (path == "/") path = "";
string Domain = Mediachase.IBN.Business.Configuration.Domain;
using(IDataReader reader = UserReport.GetUserInfo(UserID,false))
{
if (reader.Read())
{
bool IsActive = (bool)reader["IsActive"];
bool IsExternal = (bool)reader["IsExternal"];
bool IsPending = (bool)reader["IsPending"];
bool IsImInternal = true;
try
{
IsImInternal = Mediachase.IBN.Business.Security.CurrentUser.IsExternal;
}
catch {}
UserName = (string)reader["FirstName"] + " " + (string)reader["LastName"];
if(!IsActive)
UserName = "<font color='#707070'>" + UserName + "</font>";
string UserIMStatus = "";
if (!IsExternal && !IsPending)
{
if (reader["OriginalId"] != DBNull.Value)
{
int OriginalId = (int)reader["OriginalId"];
UserIMStatus = @"<a href='ibnto:" + (string)reader["Login"] + "@" + Domain + "' title='" + LocRM.GetString("SendIBNMessage") + "'><img alt='' src='../WebServices/UserStatusImage.aspx?UserID=" + OriginalId + "' border='0' align='absmiddle'/></a> ";
}
}
else if (IsExternal) UserIMStatus = "<img alt='' src='../layouts/images/status/status_external.gif' border='0' align='absmiddle' title='" + LocRM.GetString("ExternalUser") + "'/> ";
else if (IsPending) UserIMStatus = "<img alt='' src='../layouts/images/status/status_pending.gif' border='0' align='absmiddle' title='" + LocRM.GetString("PendingUser") + "'/> ";
if (IsImInternal)
RetVal = String.Format(
"<a href='mailto:{2}' title='" + LocRM.GetString("SendEmail") + "'>" +
"<img alt='' src='../layouts/images/mail.GIF' border='0' align='absmiddle'/></a> " +
"{0}", UserName,UserID,reader["Email"]);
else
RetVal = String.Format(UserIMStatus + "<a href='mailto:{2}' title='" +
LocRM.GetString("SendEmail")+"'>" +
"<img alt='' src='../layouts/images/mail.GIF' border='0' align='absmiddle'/></a> " +
"<a href='" + path + "/Directory/UserView.aspx?UserID={1}' title='" + LocRM.GetString("ViewUserProfile") + "'>{0}</a>", UserName, UserID, reader["Email"]);
UserStatusList.Add(UserID, RetVal);
context.Items.Remove(sUserStatus);
context.Items.Add(sUserStatus, UserStatusList);
}
}
if (RetVal == String.Empty)
{
RetVal = GetGroupLink(UserID);
UserStatusList.Add(UserID, RetVal);
context.Items.Remove(sUserStatus);
context.Items.Add(sUserStatus, UserStatusList);
}
}
return RetVal;
}
示例15: SRDisplayNameAttribute
public SRDisplayNameAttribute(string name, string resourceSet)
{
ResourceManager rm = new ResourceManager(resourceSet, Assembly.GetExecutingAssembly());
DisplayNameValue = rm.GetString(name);
System.Diagnostics.Debug.Assert(DisplayNameValue != null, string.Format(CultureInfo.CurrentCulture, "String resource {0} not found.", new object[] { name }));
}