当前位置: 首页>>代码示例>>C#>>正文


C# ResourceManager.GetString方法代码示例

本文整理汇总了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));
 }
开发者ID:dotnet,项目名称:corefx,代码行数:11,代码来源:ResourceManagerTests.netstandard17.cs

示例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);
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:ResourceManagerTests.cs

示例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);
            }
开发者ID:namatitiben,项目名称:nknight,代码行数:12,代码来源:SecurityLayer.cs

示例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);
    }
开发者ID:rolfbjarne,项目名称:bug33981,代码行数:11,代码来源:Program.cs

示例5: Main

    public static void Main(String[] a)
    {
        ResourceManager FormResources = new ResourceManager("StringTable", Assembly.GetExecutingAssembly());
        string Message;

        Message = FormResources.GetString("Message");
        MessageBox.Show(Message);
    }
开发者ID:dbremner,项目名称:hycs,代码行数:8,代码来源:string.cs

示例6: Main

	static int Main ()
	{
		ResourceManager resMgr = new ResourceManager ("res", 
			Assembly.GetExecutingAssembly ());
		if (resMgr.GetString ("ProbableCause") != "Mögliche Ursache:")
			return 1;
		return 0;
	}
开发者ID:mono,项目名称:gert,代码行数:8,代码来源:test.cs

示例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);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:SRCategoryAttribute.cs

示例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());
    }
开发者ID:leloulight,项目名称:dnx,代码行数:18,代码来源:Program.cs

示例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;
   }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:11,代码来源:co8651publicresources.cs

示例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);
     }
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:14,代码来源:SR.cs

示例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;
	}
开发者ID:lighter-cd,项目名称:premake4-mobile,代码行数:14,代码来源:CsConsoleApp.cs

示例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;
   }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:19,代码来源:co8652privateresources.cs

示例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;
 }
开发者ID:Si13n7,项目名称:PortableAppsSuite,代码行数:40,代码来源:Lang.cs

示例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>&nbsp;";
                            }
                        }
                        else if (IsExternal) UserIMStatus = "<img alt='' src='../layouts/images/status/status_external.gif' border='0' align='absmiddle' title='" + LocRM.GetString("ExternalUser") + "'/>&nbsp;";
                        else if (IsPending) UserIMStatus = "<img alt='' src='../layouts/images/status/status_pending.gif' border='0' align='absmiddle' title='" + LocRM.GetString("PendingUser") + "'/>&nbsp;";

                        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>&nbsp;" +
                                "{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>&nbsp;" +
                                "<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;
        }
开发者ID:0anion0,项目名称:IBN,代码行数:79,代码来源:CommonHelper.cs

示例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 }));
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:6,代码来源:SR.cs


注:本文中的ResourceManager.GetString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。