本文整理汇总了C#中System.Globalization.CultureInfo.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# CultureInfo.Equals方法的具体用法?C# CultureInfo.Equals怎么用?C# CultureInfo.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Globalization.CultureInfo
的用法示例。
在下文中一共展示了CultureInfo.Equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestDiffCultureTextInfo
public void TestDiffCultureTextInfo()
{
TextInfo textInfoFrance = new CultureInfo("fr-FR").TextInfo;
TextInfo textInfoUS = new CultureInfo("en-US").TextInfo;
Assert.False(textInfoFrance.Equals((object)textInfoUS));
}
示例2: TestIntObject
public void TestIntObject()
{
TextInfo textInfoUS = new CultureInfo("en-US").TextInfo;
int i = TestLibrary.Generator.GetInt32(-55);
object intObject = i as object;
Assert.False(textInfoUS.Equals(intObject));
}
示例3: TestStringObject
public void TestStringObject()
{
TextInfo textInfoUS = new CultureInfo("en-US").TextInfo;
String str = TestLibrary.Generator.GetString(-55, false, _MINI_STRING_LENGTH, _MAX_STRING_LENGTH);
object strObject = str as object;
Assert.False(textInfoUS.Equals(strObject));
}
示例4: CulturesEqual
private static bool CulturesEqual(CultureInfo refCI, CultureInfo defCI)
{
bool flag = defCI.Equals(CultureInfo.InvariantCulture);
if ((refCI == null) || refCI.Equals(CultureInfo.InvariantCulture))
{
return flag;
}
return (!flag && defCI.Equals(refCI));
}
示例5: FindMissingProperty
public string FindMissingProperty(PropertyToken property, CultureInfo culture)
{
var defaultValue = culture.Equals(_defaultCulture)
? property.Header ?? property.DefaultHeaderText(culture) ?? BreakUpCamelCase(property.PropertyName)
: property.DefaultHeaderText(culture) ?? culture.Name + "_" + property.PropertyName;
writeMissing(property.StringTokenKey, defaultValue, culture);
return defaultValue;
}
示例6: Compatible
private static bool Compatible(XmlLanguage lang, CultureInfo culture)
{
if (lang == null || lang == XmlLanguage.Empty) return true;
var ll = lang.IetfLanguageTag.ToLowerInvariant();
while (!culture.Equals(CultureInfo.InvariantCulture))
{
if (ll == culture.IetfLanguageTag.ToLowerInvariant()) return true;
culture = culture.Parent;
}
return false;
}
示例7: FindMissingText
public string FindMissingText(StringToken key, CultureInfo culture)
{
var defaultValue = culture.Name + "_" + key.Key;
if (key.DefaultValue.IsNotEmpty() && culture.Equals(_defaultCulture))
{
defaultValue = key.DefaultValue;
}
_storage.WriteMissing(key.Key, defaultValue, culture);
return defaultValue;
}
示例8: FindMissingText
public string FindMissingText(StringToken key, CultureInfo culture)
{
var defaultValue = culture.Name + "_" + key.ToLocalizationKey();
if (key.DefaultValue.IsNotEmpty() && culture.Equals(_defaultCulture))
{
defaultValue = key.DefaultValue;
}
writeMissing(key.ToLocalizationKey().ToString(), defaultValue, culture);
return defaultValue;
}
示例9: GetLocalizer
public Localizer GetLocalizer (CultureInfo culture)
{
Localizer loc = LookupLocalizer(culture);
if (loc == null)
lock (_localizers.SyncRoot)
{
loc = LookupLocalizer(culture);
if (loc == null)
{
if (culture.Equals(_defaultculture))
loc = CreateDefaultLocalizer();
else if (culture.IsNeutralCulture || culture.Equals(CultureInfo.InvariantCulture))
loc = CreateLocalizer(culture, _defaultculture);
else
loc = CreateLocalizer(culture, culture.Parent);
CacheLocalizer(culture, loc);
}
}
return loc;
}
示例10: CultureInfoScope
public CultureInfoScope(CultureInfo cultureInfo)
{
if (cultureInfo != null && !cultureInfo.Equals(Thread.CurrentThread.CurrentCulture))
{
if (cultureInfo.IsNeutralCulture)
{
cultureInfo = LanguageHelper.GetSpecificCultureInfo(cultureInfo);
}
originalCultureInfo = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = cultureInfo;
}
}
示例11: GetCultureInfoName
private string GetCultureInfoName(CultureInfo ci)
{
CultureInfo en_US = new CultureInfo("en-US");
// For "English (United States)" we'd rather just display "English"
if (ci.Equals(en_US))
{
return GetCultureInfoName(ci.Parent);
}
else
{
return ci.NativeName;
}
}
示例12: GetClosestMatchingLanguage
private CultureInfo GetClosestMatchingLanguage(CultureInfo culture)
{
if(culture == null || culture.Equals(CultureInfo.InvariantCulture)) {
return null;
}
var cultures = _cultureProvider.GetSupportedCultures.ToList();
var specificCulture = cultures.FirstOrDefault(c => c.IsSameCultureAs(culture));
var neutralCulture = cultures.FirstOrDefault(c => c.IsSameLanguageAs(culture));
var fallBackCulture = culture.IsSameLanguageAs(FallbackCulture) ? FallbackCulture : null;
return specificCulture ?? neutralCulture ?? fallBackCulture;
}
示例13: GetLocalizerByCulture
/// <summary>
/// Returns a localizer instance based on the culture.
/// </summary>
internal BaseLocalizer GetLocalizerByCulture(CultureInfo ci)
{
if (customLocalizer != null)
return customLocalizer;
if (ci.Equals(FarsiCulture))
{
return fa;
}
if (ci.Equals(ArabicCulture))
{
return ar;
}
return en;
}
示例14: GetCultureSpecifiedFile
/// <summary>
/// 返回与特定区域性相关的文件名。
/// </summary>
/// <param name="path">文件的路径。</param>
/// <param name="fileName">文件的名称。</param>
/// <param name="culture">要获取的文件的区域性信息。</param>
/// <returns>与特定区域性相关的文件名,如果不存在则为 <c>null</c>。</returns>
/// <remarks>与特定区域性相关的文件名,其形式为 path/culture.Name/fileName。</remarks>
/// <exception cref="ArgumentNullException"><paramref name="path"/>、<paramref name="fileName"/> 或
/// <paramref name="culture"/> 为 <c>null</c>。</exception>
/// <exception cref="ArgumentException"><paramref name="path"/> 或 <paramref name="fileName"/>
/// 中包含一个或多个无效字符。</exception>
public static string GetCultureSpecifiedFile(string path, string fileName, CultureInfo culture)
{
CommonExceptions.CheckArgumentNull(path, "path");
CommonExceptions.CheckArgumentNull(fileName, "fileName");
CommonExceptions.CheckArgumentNull(culture, "culture");
Contract.EndContractBlock();
while (true)
{
string filePath = Path.Combine(path, culture.Name, fileName);
if (File.Exists(filePath))
{
return filePath;
}
if (culture.Equals(CultureInfo.InvariantCulture))
{
break;
}
culture = culture.Parent;
}
return null;
}
示例15: TryGetSatteliteAssembly
public static bool TryGetSatteliteAssembly(this Assembly assembly, CultureInfo culture,
out Assembly satteliteAssembly)
{
Contract.Requires(assembly != null);
Contract.Requires(culture != null);
if (culture.Equals(CultureInfo.InvariantCulture))
{
satteliteAssembly = assembly;
return true;
}
try
{
satteliteAssembly = assembly.GetSatelliteAssembly(culture);
}
catch
{
satteliteAssembly = null;
return false;
}
return true;
}