本文整理匯總了C#中System.ServiceModel.FaultReason.GetMatchingTranslation方法的典型用法代碼示例。如果您正苦於以下問題:C# FaultReason.GetMatchingTranslation方法的具體用法?C# FaultReason.GetMatchingTranslation怎麽用?C# FaultReason.GetMatchingTranslation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.ServiceModel.FaultReason
的用法示例。
在下文中一共展示了FaultReason.GetMatchingTranslation方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Simple
public void Simple ()
{
FaultReason r = new FaultReason ("testing");
FaultReasonText t = r.GetMatchingTranslation ();
Assert.IsNotNull (t);
Assert.AreEqual ("testing", t.Text, "#1");
Assert.AreEqual (CultureInfo.CurrentCulture.Name,
t.XmlLang, "#2");
}
示例2: MultipleLanguages
public void MultipleLanguages ()
{
string current = CultureInfo.CurrentCulture.Name;
FaultReason r = new FaultReason (new FaultReasonText [] {
new FaultReasonText ("hello"),
new FaultReasonText ("hola", "es-ES"),
new FaultReasonText ("bonjour", "fr")});
// CurrentCulture
FaultReasonText t = r.GetMatchingTranslation (
CultureInfo.CurrentCulture);
Assert.IsNotNull (t);
Assert.AreEqual ("hello", t.Text, "#1");
Assert.AreEqual (current, t.XmlLang, "#2");
// non-neutral name, get by non-neutral culture
t = r.GetMatchingTranslation (
new CultureInfo ("es-ES"));
Assert.IsNotNull (t);
Assert.AreEqual ("hola", t.Text, "#3");
Assert.AreEqual ("es-ES", t.XmlLang, "#4");
// .ctor(non-neutral name), get by neutral culture
t = r.GetMatchingTranslation (new CultureInfo ("es"));
Assert.IsNotNull (t);
Assert.AreEqual ("hello", t.Text, "#5");
Assert.AreEqual (current, t.XmlLang, "#6");
// .ctor(neutral name), get by non-neutral culture
t = r.GetMatchingTranslation (
new CultureInfo ("fr-FR"));
Assert.IsNotNull (t);
Assert.AreEqual ("bonjour", t.Text, "#7");
Assert.AreEqual ("fr", t.XmlLang, "#8");
}
示例3: GetSafeReasonText
internal static string GetSafeReasonText(FaultReason reason)
{
if (reason == null)
return SR.GetString(SR.SFxUnknownFaultNullReason0);
try
{
return reason.GetMatchingTranslation(System.Globalization.CultureInfo.CurrentCulture).Text;
}
catch (ArgumentException)
{
if (reason.Translations.Count == 0)
{
return SR.GetString(SR.SFxUnknownFaultZeroReasons0);
}
else
{
return SR.GetString(SR.SFxUnknownFaultNoMatchingTranslation1, reason.Translations[0].Text);
}
}
}
示例4: GetSafeReasonText
internal static string GetSafeReasonText(FaultReason reason)
{
if (reason == null)
{
return System.ServiceModel.SR.GetString("SFxUnknownFaultNullReason0");
}
try
{
return reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text;
}
catch (ArgumentException)
{
if (reason.Translations.Count == 0)
{
return System.ServiceModel.SR.GetString("SFxUnknownFaultZeroReasons0");
}
return System.ServiceModel.SR.GetString("SFxUnknownFaultNoMatchingTranslation1", new object[] { reason.Translations[0].Text });
}
}
示例5: NoCurrentCulture
public void NoCurrentCulture ()
{
string current = CultureInfo.CurrentCulture.Name;
FaultReason r = new FaultReason (new FaultReasonText [] {
new FaultReasonText ("hola", "es-ES"),
new FaultReasonText ("bonjour", "fr")});
// CurrentCulture
FaultReasonText t = r.GetMatchingTranslation (
CultureInfo.CurrentCulture);
Assert.IsNotNull (t);
// seems like the first item is used.
Assert.AreEqual ("hola", t.Text, "#1");
Assert.AreEqual ("es-ES", t.XmlLang, "#2");
// InvariantCulture
t = r.GetMatchingTranslation (
CultureInfo.InvariantCulture);
Assert.IsNotNull (t);
// seems like the first item is used.
Assert.AreEqual ("hola", t.Text, "#3");
Assert.AreEqual ("es-ES", t.XmlLang, "#4");
}