当前位置: 首页>>代码示例>>C#>>正文


C# FaultReason.GetMatchingTranslation方法代码示例

本文整理汇总了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");
		}
开发者ID:nickchal,项目名称:pash,代码行数:9,代码来源:FaultReasonTest.cs

示例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");
		}
开发者ID:nickchal,项目名称:pash,代码行数:36,代码来源:FaultReasonTest.cs

示例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);
                }
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:21,代码来源:FaultException.cs

示例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 });
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:19,代码来源:FaultException.cs

示例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");
		}
开发者ID:nickchal,项目名称:pash,代码行数:24,代码来源:FaultReasonTest.cs


注:本文中的System.ServiceModel.FaultReason.GetMatchingTranslation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。