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


C# ResXResourceReader.GetMetadataEnumerator方法代码示例

本文整理汇总了C#中System.Resources.ResXResourceReader.GetMetadataEnumerator方法的典型用法代码示例。如果您正苦于以下问题:C# ResXResourceReader.GetMetadataEnumerator方法的具体用法?C# ResXResourceReader.GetMetadataEnumerator怎么用?C# ResXResourceReader.GetMetadataEnumerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Resources.ResXResourceReader的用法示例。


在下文中一共展示了ResXResourceReader.GetMetadataEnumerator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetMetadataEnumerator

		public void GetMetadataEnumerator ()
		{
			string refFile = Path.Combine (_tempDirectory, "32x32.ico");
			WriteEmbeddedResource ("32x32.ico", refFile);

			string resxFile = Path.Combine (_tempDirectory, "resources.resx");
			using (StreamWriter sw = new StreamWriter (resxFile, false, Encoding.UTF8)) {
				sw.Write (string.Format (CultureInfo.InvariantCulture,
					_resXFileRefTemplate, ResXResourceWriter.ResMimeType, "1.0",
					Consts.AssemblySystem_Windows_Forms, refFile,
					typeof (Bitmap).AssemblyQualifiedName, string.Empty,
					Consts.AssemblyCorlib));
			}

			using (ResXResourceReader r = new ResXResourceReader (resxFile)) {
				IDictionaryEnumerator enumerator = r.GetMetadataEnumerator ();
				Assert.IsTrue (enumerator.MoveNext (), "#A1");
				Assert.IsNotNull (enumerator.Current, "#A2");
				Assert.AreEqual ("panel_label.Locked", enumerator.Key, "#A3");
				Assert.AreEqual(typeof(bool), enumerator.Value.GetType(), "#A4");
				Assert.IsTrue ((bool) enumerator.Value, "#A5");
				Assert.IsFalse (enumerator.MoveNext (), "#A6");
			}

			using (ResXResourceReader r = new ResXResourceReader (resxFile)) {
				r.UseResXDataNodes = true;
				IDictionaryEnumerator enumerator = r.GetMetadataEnumerator ();
				Assert.IsFalse (enumerator.MoveNext (), "#B1");
			}
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:30,代码来源:ResXResourceReaderTest.cs

示例2: LoadFile

		public void LoadFile(string filename, Stream stream)
		{
			resources.Clear();
			metadata.Clear();
			switch (Path.GetExtension(filename).ToLowerInvariant()) {
				case ".resx":
					ResXResourceReader rx = new ResXResourceReader(stream);
					rx.BasePath = Path.GetDirectoryName(filename);
					IDictionaryEnumerator n = rx.GetEnumerator();
					while (n.MoveNext())
						if (!resources.ContainsKey(n.Key.ToString()))
						resources.Add(n.Key.ToString(), new ResourceItem(n.Key.ToString(), n.Value));
					
					n = rx.GetMetadataEnumerator();
					while (n.MoveNext())
						if (!metadata.ContainsKey(n.Key.ToString()))
						metadata.Add(n.Key.ToString(), new ResourceItem(n.Key.ToString(), n.Value));
					
					rx.Close();
					break;
				case ".resources":
					ResourceReader rr=null;
					try {
						rr = new ResourceReader(stream);
						foreach (DictionaryEntry entry in rr) {
							if (!resources.ContainsKey(entry.Key.ToString()))
								resources.Add(entry.Key.ToString(), new ResourceItem(entry.Key.ToString(), entry.Value));
						}
					}
					finally {
						if (rr != null) {
							rr.Close();
						}
					}
					break;
			}
			InitializeListView();
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:38,代码来源:ResourceList.cs

示例3: LoadFile

		public void LoadFile(FileName filename, Stream stream)
		{
			resources.Clear();
			metadata.Clear();
			switch (Path.GetExtension(filename).ToLowerInvariant()) {
				case ".resx":
					ResXResourceReader rx = new ResXResourceReader(stream);
					ITypeResolutionService typeResolver = null;
					rx.BasePath = Path.GetDirectoryName(filename);
					rx.UseResXDataNodes = true;
					IDictionaryEnumerator n = rx.GetEnumerator();
					while (n.MoveNext()) {
						if (!resources.ContainsKey(n.Key.ToString())) {
							ResXDataNode node = (ResXDataNode)n.Value;
							resources.Add(n.Key.ToString(), new ResourceItem(node.Name, node.GetValue(typeResolver), node.Comment));
						}
					}
					
					n = rx.GetMetadataEnumerator();
					while (n.MoveNext()) {
						if (!metadata.ContainsKey(n.Key.ToString())) {
							ResXDataNode node = (ResXDataNode)n.Value;
							metadata.Add(n.Key.ToString(), new ResourceItem(node.Name, node.GetValue(typeResolver)));
						}
					}
					
					rx.Close();
					break;
				case ".resources":
					ResourceReader rr=null;
					try {
						rr = new ResourceReader(stream);
						foreach (DictionaryEntry entry in rr) {
							if (!resources.ContainsKey(entry.Key.ToString()))
								resources.Add(entry.Key.ToString(), new ResourceItem(entry.Key.ToString(), entry.Value));
						}
					}
					finally {
						if (rr != null) {
							rr.Close();
						}
					}
					break;
			}
			InitializeListView();
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:46,代码来源:ResourceList.cs


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