本文整理汇总了C#中System.Resources.ResourceReader.GetEnumerator方法的典型用法代码示例。如果您正苦于以下问题:C# ResourceReader.GetEnumerator方法的具体用法?C# ResourceReader.GetEnumerator怎么用?C# ResourceReader.GetEnumerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Resources.ResourceReader
的用法示例。
在下文中一共展示了ResourceReader.GetEnumerator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
Assembly thisAssembly = Assembly.GetExecutingAssembly();
string[] test = Assembly.GetExecutingAssembly().GetManifestResourceNames();
foreach (string file in test)
{
Stream rgbxml = thisAssembly.GetManifestResourceStream(
file);
try
{
ResourceReader res = new ResourceReader(rgbxml);
IDictionaryEnumerator dict = res.GetEnumerator();
while (dict.MoveNext())
{
Console.WriteLine(" {0}: '{1}' (Type {2})",
dict.Key, dict.Value, dict.Value.GetType().Name);
if (dict.Key.ToString().EndsWith(".ToolTip") || dict.Key.ToString().EndsWith(".Text") || dict.Key.ToString().EndsWith("HeaderText") || dict.Key.ToString().EndsWith("ToolTipText"))
{
dataGridView1.Rows.Add();
dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[colFile.Index].Value = System.IO.Path.GetFileName(file);
dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[colInternal.Index].Value = dict.Key.ToString();
dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[colEnglish.Index].Value = dict.Value.ToString();
dataGridView1.Rows[dataGridView1.RowCount - 1].Cells[colOtherLang.Index].Value = dict.Value.ToString();
}
}
} catch {}
}
}
示例2: DatabaseType
/// <summary> Creates a new <code>DatabaseType</code>.
///
/// </summary>
/// <param name="databaseType">the type of database
/// </param>
public DatabaseType(System.String databaseType)
{
Assembly assembly = Assembly.GetExecutingAssembly();
string resourceName = string.Format("AutopatchNet.{0}.resources", databaseType.ToLower());
System.IO.Stream rs = assembly.GetManifestResourceStream(resourceName);
if (rs == null)
{
throw new System.ArgumentException("Could not find SQL resources file for database '" + databaseType + "'; make sure that there is a '" + databaseType.ToLower() + ".resources' file in package.");
}
try
{
ResourceReader reader = new ResourceReader(rs);
IDictionaryEnumerator en = reader.GetEnumerator();
while(en.MoveNext())
{
string sqlkey = (string)en.Key;
string sql = (string)en.Value;
properties.Add(sqlkey, sql);
}
reader.Close();
}
catch (System.IO.IOException e)
{
throw new System.ArgumentException("Could not read SQL resources file for database '" + databaseType + "'.", e);
}
finally
{
rs.Close();
}
this.databaseType = databaseType;
}
示例3: Phase2
public static bool Phase2()
{
var resName = PhaseParam;
var resReader = new ResourceReader(AsmDef.FindResource(res => res.Name == "app.resources").GetResourceStream());
var en = resReader.GetEnumerator();
byte[] resData = null;
while (en.MoveNext())
{
if (en.Key.ToString() == resName)
resData = en.Value as byte[];
}
if(resData == null)
{
PhaseError = new PhaseError
{
Level = PhaseError.ErrorLevel.Critical,
Message = "Could not read resource data!"
};
}
PhaseParam = resData;
return true;
}
示例4: FixNow
private void FixNow(string path)
{
try
{
string sound = Path.Combine(path, "zone", "snd");
if (!Directory.Exists(sound))
throw new Exception("リソース(資源)の一部が欠けてるようです。");
sound = Path.Combine(sound, "en");
Directory.CreateDirectory(sound);
Assembly asm = Assembly.GetExecutingAssembly();
Stream resource = asm.GetManifestResourceStream("SteamPatch_BO3_BETA.Properties.Resources.resources");
using (IResourceReader render = new ResourceReader(resource))
{
IDictionaryEnumerator id = render.GetEnumerator();
while (id.MoveNext())
{
byte[] bytes = (byte[])id.Value;
string file = Path.Combine(sound, id.Key.ToString());
File.WriteAllBytes(file, bytes);
}
}
MessageBox.Show("適応しました", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例5: SqlStatementsBase
protected SqlStatementsBase(Assembly assembly, string resourcePath)
{
Ensure.That(assembly, "assembly").IsNotNull();
Ensure.That(resourcePath, "resourcePath").IsNotNullOrWhiteSpace();
if (!resourcePath.EndsWith(".resources"))
resourcePath = string.Concat(resourcePath, ".resources");
resourcePath = string.Concat(assembly.GetName().Name, ".", resourcePath);
_sqlStrings = new Dictionary<string, string>();
using (var resourceStream = assembly.GetManifestResourceStream(resourcePath))
{
using (var reader = new ResourceReader(resourceStream))
{
var e = reader.GetEnumerator();
while (e.MoveNext())
{
_sqlStrings.Add(e.Key.ToString(), e.Value.ToString());
}
}
if(resourceStream != null)
resourceStream.Close();
}
}
示例6: ResourceHelper
/// <summary>
/// 默认构造函数
/// </summary>
/// <param name="filepath">资源文件路径</param>
public ResourceHelper(string filepath)
{
this.m_FilePath = filepath;
this.m_Hashtable = new Hashtable();
//如果存在
if (File.Exists(filepath))
{
string tempFile = HConst.TemplatePath + "\\decryptFile.resx";
//解密文件
//System.Net.Security tSecurity = new Security();
//tSecurity.DecryptDES(filepath, tempFile);
File.Copy(filepath, tempFile);
using (ResourceReader ResReader = new ResourceReader(tempFile))
{
IDictionaryEnumerator tDictEnum = ResReader.GetEnumerator();
while (tDictEnum.MoveNext())
{
this.m_Hashtable.Add(tDictEnum.Key, tDictEnum.Value);
}
ResReader.Close();
}
//删除临时文件
File.Delete(tempFile);
}
}
示例7: XamlSnippetProvider
public XamlSnippetProvider(Assembly assembly, string resourceIdString)
{
var resourceIds = new[] { resourceIdString };
foreach (var resourceId in resourceIds)
{
try
{
using (var reader = new ResourceReader(assembly.GetManifestResourceStream(resourceId)))
{
var enumerator = reader.GetEnumerator();
while (enumerator.MoveNext())
{
var name = enumerator.Key as string;
var xaml = enumerator.Value as string;
if (name != null && xaml != null)
{
snippets.Add(new Snippet(name, xaml));
}
}
}
}
catch (Exception e)
{
Debug.WriteLine($"Cannot load snippets. Exception: {e}");
}
}
}
示例8: TranslateFromStream
private void TranslateFromStream(FileStream stream, string outputDirectory)
{
var resourceReader = new ResourceReader(stream);
var enumerator = resourceReader.GetEnumerator();
while (enumerator.MoveNext())
{
var resource = new Resource(enumerator.Key, enumerator.Value);
xamlTranslator.Translate(resource, outputDirectory);
}
}
示例9: Run
public override void Run()
{
// Here an example that shows how to access the current text document:
ITextEditorControlProvider tecp = WorkbenchSingleton.Workbench.ActiveContent as ITextEditorControlProvider;
if (tecp == null) {
// active content is not a text editor control
return;
}
// Get the active text area from the control:
TextArea textArea = tecp.TextEditorControl.ActiveTextAreaControl.TextArea;
if (!textArea.SelectionManager.HasSomethingSelected)
return;
// get the selected text:
string text = textArea.SelectionManager.SelectedText;
string sdSrcPath = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location),
"../../../..");
using (ResourceReader r = new ResourceReader(Path.Combine(sdSrcPath,
"Main/StartUp/Project/Resources/StringResources.resources"))) {
IDictionaryEnumerator en = r.GetEnumerator();
// Goes through the enumerator, printing out the key and value pairs.
while (en.MoveNext()) {
if (object.Equals(en.Value, text)) {
SetText(textArea, en.Key.ToString(), text);
return;
}
}
}
string resourceName = MessageService.ShowInputBox("Add Resource", "Please enter the name for the new resource.\n" +
"This should be a namespace-like construct, please see what the names of resources in the same component are.", PropertyService.Get("ResourceToolLastResourceName"));
if (resourceName == null || resourceName.Length == 0) return;
PropertyService.Set("ResourceToolLastResourceName", resourceName);
string purpose = MessageService.ShowInputBox("Add Resource", "Enter resource purpose (may be empty)", "");
if (purpose == null) return;
SetText(textArea, resourceName, text);
string path = Path.GetFullPath(Path.Combine(sdSrcPath, "Tools/StringResourceTool/bin/Debug"));
ProcessStartInfo info = new ProcessStartInfo(path + "\\StringResourceTool.exe",
"\"" + resourceName + "\" "
+ "\"" + text + "\" "
+ "\"" + purpose + "\"");
info.WorkingDirectory = path;
try {
Process.Start(info);
} catch (Exception ex) {
MessageService.ShowError(ex, "Error starting " + info.FileName);
}
}
示例10: Application_Startup
private void Application_Startup(object sender, StartupEventArgs e)
{
ResourceReader reader = new ResourceReader("C:\\Users\\ssickles\\Desktop\\Infralution.Localization.Wpf\\SampleApp_CS\\bin\\Debug\\fr\\WpfApp.resources.dll");
IDictionaryEnumerator resourceReaderEn = reader.GetEnumerator();
while (resourceReaderEn.MoveNext())
{
Console.WriteLine("Name: {0} - Value: {1}",
resourceReaderEn.Key.ToString().PadRight(10, ' '),
resourceReaderEn.Value);
}
ResourceWriter writer = new ResourceWriter("C:\\Users\\ssickles\\Desktop\\Infralution.Localization.Wpf\\SampleApp_CS\\bin\\Debug\\fr\\WpfApp.resources.dll");
}
示例11: WriteResource
public void WriteResource(IResourceService service)
{
using (ResourceReader reader = new ResourceReader(this.FileName))
{
IResourceWriter writer = service.DefineResource(this.Name, this.Description);
IDictionaryEnumerator e = reader.GetEnumerator();
while (e.MoveNext())
{
writer.AddResource((string)e.Key, e.Value);
}
}
}
示例12: ConvertEmbeddedResourceFile
public static string ConvertEmbeddedResourceFile(Configuration configuration, string assemblyName, Assembly assembly, string resourceName)
{
var output = new StringBuilder();
using (var stream = assembly.GetManifestResourceStream(resourceName))
using (var reader = new ResourceReader(stream)) {
output.AppendLine("{");
bool first = true;
var e = reader.GetEnumerator();
while (e.MoveNext()) {
if (!first)
output.AppendLine(",");
else
first = false;
var key = Convert.ToString(e.Key);
output.AppendFormat(" {0}: ", JSIL.Internal.Util.EscapeString(key));
var value = e.Value;
if (value == null) {
output.Append("null");
} else {
switch (value.GetType().FullName) {
case "System.String":
output.Append(JSIL.Internal.Util.EscapeString((string)value));
break;
case "System.Single":
case "System.Double":
case "System.UInt16":
case "System.UInt32":
case "System.UInt64":
case "System.Int16":
case "System.Int32":
case "System.Int64":
output.Append(Convert.ToString(value));
break;
default:
output.Append(JSIL.Internal.Util.EscapeString(Convert.ToString(value)));
break;
}
}
}
output.AppendLine();
output.AppendLine("}");
}
return output.ToString();
}
示例13: Main
static void Main(string[] args)
{
if(args.Length !=1)
{
Console.Write("[-] Error\nnetZunpacker.exe packedfile.exe\nPress Enter to Exit");
Console.Read();
return;
}
try
{
String path;
if (!Path.IsPathRooted(args[0]))
{
path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\" + args[0];
}
else
{
path = args[0];
}
Assembly a = Assembly.LoadFile(path);
ResourceManager rm = new ResourceManager("app", a);
String[] resourceNames = a.GetManifestResourceNames();
int p;
foreach (string resName in resourceNames)
{
Stream resStream = a.GetManifestResourceStream(resName);
var rr = new ResourceReader(resStream);
IDictionaryEnumerator dict = rr.GetEnumerator();
int ctr = 0;
while (dict.MoveNext())
{
ctr++;
//Console.WriteLine("\n{0:00}: {1} = {2}", ctr, dict.Key, dict.Value);
if (((byte[])rm.GetObject(dict.Key.ToString()))[0] == 120)
{
Decoder((byte[])rm.GetObject(dict.Key.ToString()), dict.Key.ToString());
}
}
rr.Close();
}
}
catch(Exception e)
{
String s = e.Message;
Console.Write(s);
}
}
示例14: GetString
internal static string GetString(string str, string lang)
{
if (string.IsNullOrEmpty(str)) throw new ArgumentNullException("Empty language query string");
if (string.IsNullOrEmpty(lang)) throw new ArgumentNullException("No language resource given");
// culture-specific file, i.e. "LangResources.fr"
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ScreenToGif.Properties.Lang" + lang + ".resources");
//string[] resourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
//if (resourceNames.Any())
//{
// //
//}
// resource not found, revert to default resource
if (null == stream)
{
stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ScreenToGif.Properties.Resources.resources");
}
ResourceReader reader = new ResourceReader(stream);
IDictionaryEnumerator en = reader.GetEnumerator();
while (en.MoveNext())
{
if (en.Key.Equals(str))
{
return en.Value.ToString();
}
}
#region If string is not translated
stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ScreenToGif.Properties.Resources");
reader = new ResourceReader(stream);
IDictionaryEnumerator en1 = reader.GetEnumerator();
while (en1.MoveNext())
{
if (en1.Key.Equals(str))
{
return en1.Value.ToString();
}
}
#endregion
return "<STRING>";
}
示例15: PostRename
public void PostRename(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def)
{
var module = def as ModuleDefMD;
if (module == null)
return;
var wpfResInfo = context.Annotations.Get<Dictionary<string, Dictionary<string, BamlDocument>>>(module, BAMLKey);
if (wpfResInfo == null)
return;
foreach (EmbeddedResource res in module.Resources.OfType<EmbeddedResource>())
{
Dictionary<string, BamlDocument> resInfo;
if (!wpfResInfo.TryGetValue(res.Name, out resInfo))
continue;
var stream = new MemoryStream();
var writer = new ResourceWriter(stream);
res.Data.Position = 0;
var reader = new ResourceReader(new ImageStream(res.Data));
IDictionaryEnumerator enumerator = reader.GetEnumerator();
while (enumerator.MoveNext())
{
var name = (string)enumerator.Key;
string typeName;
byte[] data;
reader.GetResourceData(name, out typeName, out data);
BamlDocument document;
if (resInfo.TryGetValue(name, out document))
{
var docStream = new MemoryStream();
docStream.Position = 4;
BamlWriter.WriteDocument(document, docStream);
docStream.Position = 0;
docStream.Write(BitConverter.GetBytes((int)docStream.Length - 4), 0, 4);
data = docStream.ToArray();
name = document.DocumentName;
}
writer.AddResourceData(name, typeName, data);
}
writer.Generate();
res.Data = MemoryImageStream.Create(stream.ToArray());
}
}