本文整理汇总了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");
}
}
示例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();
}
示例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();
}