當前位置: 首頁>>代碼示例>>C#>>正文


C# ResourceSet.GetString方法代碼示例

本文整理匯總了C#中System.Resources.ResourceSet.GetString方法的典型用法代碼示例。如果您正苦於以下問題:C# ResourceSet.GetString方法的具體用法?C# ResourceSet.GetString怎麽用?C# ResourceSet.GetString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Resources.ResourceSet的用法示例。


在下文中一共展示了ResourceSet.GetString方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetResourceSet

        private ResourceSet GetResourceSet(CultureInfo culture, bool custom) {
            ResourceSet resource;
            String resourceKey = GetResourceKey(culture, custom);
            lock(_resourceLock) {

                // if the resource data for this culture has not yet been loaded, load it
                if(!ResourceData.TryGetValue(resourceKey, out resource)) {

                    // set the filename according to the cuture
                    String filename;
                    if(null == culture) {
                        filename = "resources.custom.txt";
                    } else if(culture.Equals(CultureInfo.InvariantCulture)) {
                        filename = "resources.txt";
                    } else {
                        filename = "resources.";
                        if(custom) {
                            filename += "custom.";
                        }
                        filename += culture.Name.ToLowerInvariant() + ".txt";
                    }
                    filename = Path.Combine(_resourcePath, filename);

                    // load the resource set and add it into the resource table
                    resource = new ResourceSet(new PlainTextResourceReader(filename));

                    // Note (arnec): We call GetString to force the lazy loading of the resource stream, thereby making
                    // GetString(), at least theoretically, thread-safe for subsequent calls.
                    resource.GetString("", true);
                    ResourceData.Add(resourceKey, resource);
                }
            }
            return resource;
        }
開發者ID:StackableRegiments,項目名稱:metl2011,代碼行數:34,代碼來源:PlainTextResourceManager.cs

示例2: ReadToken

 static string ReadToken(EmbeddedResource resources, string token)
 {
     using (var resourceStream = resources.GetResourceStream())
     using (var resourceSet = new ResourceSet(resourceStream))
         return resourceSet.GetString(token, true);
 }
開發者ID:nuxleus,項目名稱:openwrap,代碼行數:6,代碼來源:CommandDocumentation.cs

示例3: GetConfigurationFromResourceFile

 /// <summary>
 /// Get the value corresponding to specified key from specified resource file
 /// </summary>
 /// <param name="fileName">Name of the resource file</param>
 /// <param name="keyName">Name of the key</param>
 /// <param name="resourceFileLocation">Resource file location</param>
 /// <returns>
 /// Value of the key
 /// </returns>
 public static string GetConfigurationFromResourceFile(string fileName, string keyName, Enumerators.ResourceFileLocation resourceFileLocation)
 {
     string resourceValue = string.Empty;
     ResXResourceReader resxReader = null;
     try
     {
         resxReader = new ResXResourceReader(HttpContext.Current.Server.MapPath(@"~/" + resourceFileLocation + ConstantStrings.ForwardSlash + fileName + ConstantStrings.ResourceFileExtension));
         ResourceSet resourceSet = new ResourceSet(resxReader);
         resourceValue = resourceSet.GetString(keyName);
     }
     catch (Exception exception)
     {
         Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ConstantStrings.LogTableName);
     }
     finally
     {
         resxReader.Close();
     }
     return resourceValue;
 }
開發者ID:MatthewSammut,項目名稱:mattercenter,代碼行數:29,代碼來源:ConstantStrings.cs

示例4: GetLoadStringFromCall

		private static string GetLoadStringFromCall (MethodReference mr)
		{
			MethodDefinition md = mr.Resolve ();
			if ((md == null) || !IsResource (md))
				return null;

			string resourceName = GetResourceNameFromResourceGetter (md);
			if (resourceName == null)
				return null;

			AssemblyDefinition ad = md.GetAssembly ();
			string resourceClassName = md.DeclaringType.FullName + ".resources";
			EmbeddedResource resource = GetEmbeddedResource (ad, resourceClassName);
			if (resource == null)
				return null;

			using (MemoryStream ms = new MemoryStream (resource.GetResourceData ()))
			using (ResourceSet resourceSet = new ResourceSet (ms)) {
				return resourceSet.GetString (resourceName);
			}
		}
開發者ID:nolanlum,項目名稱:mono-tools,代碼行數:21,代碼來源:ProvideCorrectArgumentsToFormattingMethodsRule.cs

示例5: ResourceSetMatches

        /// <summary>
        /// Checks whether the provided resource set contains an entry matching the provided key.
        /// </summary>
        /// <param name="resources"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static bool ResourceSetMatches(ResourceSet resources, string key)
        {
            if (resources == null)
                return false;

            string output = resources.GetString(key);

            return (output != null && output != String.Empty);
        }
開發者ID:jeremysimmons,項目名稱:sitestarter,代碼行數:15,代碼來源:DynamicLanguage.cs

示例6: GetResourceSetFromAssembly

        /// <summary>
        /// Retrieves the resource set containing the specified key from the provided assembly.
        /// </summary>
        /// <param name="assembly">The assembly containing the target resource set.</param>
        /// <param name="key">The key of the target entry.</param>
        /// <returns>The resource set from the provided assembly containing the provided key.</returns>
        public static ResourceSet GetResourceSetFromAssembly(Assembly assembly, string key)
        {
            string[] resourceNames = assembly.GetManifestResourceNames();

            ResourceSet resources = null;

            foreach (string resourceName in resourceNames)
            {
                string text = String.Empty;

                using (Stream stream = assembly.GetManifestResourceStream(resourceName))
                {
                    resources = new ResourceSet(stream);

                    stream.Close();

                }

                text = resources.GetString(key);

                if (ResourceSetMatches(resources, key))
                {
                    return resources;
                }
            }

            return resources;
        }
開發者ID:jeremysimmons,項目名稱:sitestarter,代碼行數:34,代碼來源:DynamicLanguage.cs


注:本文中的System.Resources.ResourceSet.GetString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。