Come posso ottenere il testo localizzato dinamicamente in Windows Phone 8? scopro che se voglio un testo posso fare questo corso:Ottieni localizzazione stringhe dinamicamente WP8 C#
AppResources.ERR_VERSION_NOT_SUPPORTED
Ma supponiamo ricevo la mia parola chiave dal server. Ho solo la corda
ERR_VERSION_NOT_SUPPORTED
ora vorrei ottenere il testo vero e proprio da AppResources
.
Ho provato quanto segue:
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);
il problema è in questo esempio la MethodInfo
mi è nullo ...
qualcuno ha qualche idea?
EDIT:
Grazie a tutti per le risposte veloci. in Fact Sono abbastanza nuovo con C# e mescolo sempre il Properties
a causa della sintassi getter e setter.
mia AppResources
assomiglia a questo:
/// <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);
}
}
}
anche cercando di ottenere la proprietà si è conclusa in modo dinamico per non lavorare ... e ho capito che posso usare direttamente in questo modo:
string message = AppResources.ResourceManager.GetString("ERR_VERSION_NOT_SUPPORTED", AppResources.Culture);
Acclamazioni a tutti
Sei sicuro che 'ERR_VERSION_NOT_SUPPORTED' è un metodo? – polkduran