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


C# CultureInfo.GetType方法代码示例

本文整理汇总了C#中System.Globalization.CultureInfo.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# CultureInfo.GetType方法的具体用法?C# CultureInfo.GetType怎么用?C# CultureInfo.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Globalization.CultureInfo的用法示例。


在下文中一共展示了CultureInfo.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetPersianCultureInfo

        public static CultureInfo GetPersianCultureInfo()
        {
            var persianCultureInfo = new CultureInfo("fa-IR");

            SetPersianDateTimeFormatInfo(persianCultureInfo.DateTimeFormat);
            SetNumberFormatInfo(persianCultureInfo.NumberFormat);

            var cal = new PersianCalendar();

            FieldInfo fieldInfo = persianCultureInfo.GetType().GetField("calendar", BindingFlags.NonPublic | BindingFlags.Instance);
            if (fieldInfo != null)
                fieldInfo.SetValue(persianCultureInfo, cal);

            FieldInfo info = persianCultureInfo.DateTimeFormat.GetType().GetField("calendar", BindingFlags.NonPublic | BindingFlags.Instance);
            if (info != null)
                info.SetValue(persianCultureInfo.DateTimeFormat, cal);

            return persianCultureInfo;
        }
开发者ID:VegasoftTI,项目名称:Dnn.Platform,代码行数:19,代码来源:PersianController.cs

示例2: ReadOnly

        /// <include file='doc\CultureInfo.uex' path='docs/doc[@for="CultureInfo.ReadOnly"]/*' />        
        public static CultureInfo ReadOnly(CultureInfo ci) {
            if (ci == null) {
                throw new ArgumentNullException("ci");
            }
            if (ci.IsReadOnly) {
                return (ci);
            }
            CultureInfo info = (CultureInfo)(ci.MemberwiseClone());

            //If this is exactly our type, we can make certain optimizations so that we don't allocate NumberFormatInfo or DTFI unless
            //they've already been allocated.  If this is a derived type, we'll take a more generic codepath.
            if (ci.GetType()==typeof(CultureInfo)) {
                if (ci.dateTimeInfo != null) {
                    info.dateTimeInfo = DateTimeFormatInfo.ReadOnly(ci.dateTimeInfo);
                }
                if (ci.numInfo != null) {
                    info.numInfo = NumberFormatInfo.ReadOnly(ci.numInfo);
                }
            } else {
                info.DateTimeFormat = DateTimeFormatInfo.ReadOnly(ci.DateTimeFormat);
                info.NumberFormat = NumberFormatInfo.ReadOnly(ci.NumberFormat);
            }
            // Don't set the read-only flag too early.
            // We should set the read-only flag here.  Otherwise, info.DateTimeFormat will not be able to set.
            info.m_isReadOnly = true;
            
            return (info);
        }
开发者ID:ArildF,项目名称:masters,代码行数:29,代码来源:cultureinfo.cs

示例3: VerifyCultureName

        internal static bool VerifyCultureName(CultureInfo culture, bool throwException) {
            BCLDebug.Assert(culture!=null, "[CultureInfo.VerifyCultureName]culture!=null");

            //If we have an instance of one of our CultureInfos, the user can't have changed the
            //name and we know that all names are valid in files.
            if (culture.GetType()==typeof(CultureInfo)) {
                return true;
            }
            
            String name = culture.Name;
            
            for (int i=0; i<name.Length; i++) {
                char c = name[i];
                if (Char.IsLetterOrDigit(c) || c=='-' || c=='_') {
                    continue;
                }
                if (throwException) {
                    throw new ArgumentException(Environment.GetResourceString("Argument_InvalidResourceCultureName", name));
                }
                return false;
            }
            return true;
        }
开发者ID:ArildF,项目名称:masters,代码行数:23,代码来源:cultureinfo.cs


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