當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。