Wie kann ich den lokalisierten Text dynamisch in Windows Phone 8 erhalten? finde ich heraus, dass, wenn ich einen Text will, kann ich diese über tun:Get Localize Zeichenfolgen dynamisch WP8 C#
AppResources.ERR_VERSION_NOT_SUPPORTED
Aber nehmen wir an, ich mein Stichwort vom Server erhalten. Ich bekomme nur die Zeichenfolge zurück
ERR_VERSION_NOT_SUPPORTED
Nun möchte ich den richtigen Text von AppResources
erhalten möchte.
Ich habe folgendes versucht:
string methodName = "ERR_VERSION_NOT_SUPPORTED";
AppResources res = new AppResources();
//Get the method information using the method info class
MethodInfo mi = res.GetType().GetMethod(methodName);
//Invoke the method
// (null- no parameter for the method call
// or you can pass the array of parameters...)
string message = (string)mi.Invoke(res, null);
das Problem in diesem Beispiel ist die MethodInfo
mi null ist ...
jemand ein paar Ideen hat?
EDIT:
Vielen Dank für die schnellen Antworten. in Tatsache, ich bin ziemlich neu mit C# und ich verwechsle immer die Properties
wegen der Syntax Getter und Setter.
meine AppResources
sieht wie folgt aus:
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class AppResources
{
...
/// <summary>
/// Looks up a localized string similar to This version is not supported anymore. Please update to the new version..
/// </summary>
public static string ERR_VERSION_NOT_SUPPORTED
{
get
{
return ResourceManager.GetString("ERR_VERSION_NOT_SUPPORTED", resourceCulture);
}
}
}
auch dynamisch das Eigentum am Ende nicht funktioniert ... und ich herausgefunden ich direkt auf diese Weise verwenden können, um zu bekommen versuchen:
string message = AppResources.ResourceManager.GetString("ERR_VERSION_NOT_SUPPORTED", AppResources.Culture);
Prost an alle
Sind Sie sicher, dass 'ERR_VERSION_NOT_SUPPORTED' eine Methode ist? – polkduran