当前位置: 首页>>代码示例>>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;未经允许,请勿转载。