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