當前位置: 首頁>>代碼示例>>C#>>正文


C# CultureInfo.MemberwiseClone方法代碼示例

本文整理匯總了C#中System.Globalization.CultureInfo.MemberwiseClone方法的典型用法代碼示例。如果您正苦於以下問題:C# CultureInfo.MemberwiseClone方法的具體用法?C# CultureInfo.MemberwiseClone怎麽用?C# CultureInfo.MemberwiseClone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Globalization.CultureInfo的用法示例。


在下文中一共展示了CultureInfo.MemberwiseClone方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ReadOnly

        public static CultureInfo ReadOnly(CultureInfo ci)
        {
            if (ci == null)
            {
                throw new ArgumentNullException("ci");
            }
            Contract.Ensures(Contract.Result<CultureInfo>() != null);
            Contract.EndContractBlock();

            if (ci.IsReadOnly)
            {
                return (ci);
            }
            CultureInfo newInfo = (CultureInfo)(ci.MemberwiseClone());

            if (!ci.IsNeutralCulture)
            {
                //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.m_isInherited)
                {
                    if (ci.dateTimeInfo != null)
                    {
                        newInfo.dateTimeInfo = DateTimeFormatInfo.ReadOnly(ci.dateTimeInfo);
                    }
                    if (ci.numInfo != null)
                    {
                        newInfo.numInfo = NumberFormatInfo.ReadOnly(ci.numInfo);
                    }
                }
                else
                {
                    newInfo.DateTimeFormat = DateTimeFormatInfo.ReadOnly(ci.DateTimeFormat);
                    newInfo.NumberFormat = NumberFormatInfo.ReadOnly(ci.NumberFormat);
                }
            }

            if (ci.textInfo != null)
            {
                newInfo.textInfo = TextInfo.ReadOnly(ci.textInfo);
            }

            if (ci.calendar != null)
            {
                newInfo.calendar = Calendar.ReadOnly(ci.calendar);
            }

            // 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.
            newInfo.m_isReadOnly = true;

            return (newInfo);
        }
開發者ID:dagood,項目名稱:coreclr,代碼行數:53,代碼來源:CultureInfo.cs

示例2: 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 (!ci.IsNeutralCulture)
     {
         if (!ci.m_isInherited)
         {
             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);
         }
     }
     if (ci.textInfo != null)
     {
         info.textInfo = System.Globalization.TextInfo.ReadOnly(ci.textInfo);
     }
     if (ci.calendar != null)
     {
         info.calendar = System.Globalization.Calendar.ReadOnly(ci.calendar);
     }
     info.m_isReadOnly = true;
     return info;
 }
開發者ID:randomize,項目名稱:VimConfig,代碼行數:41,代碼來源:CultureInfo.cs

示例3: 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

示例4: ReadOnly

	// Wrap a culture information object to make it read-only.
	public static CultureInfo ReadOnly(CultureInfo ci)
			{
				if(ci == null)
				{
					throw new ArgumentNullException("ci");
				}
				if(ci.IsReadOnly)
				{
					return ci;
				}
				else
				{
					CultureInfo culture = (CultureInfo)(ci.MemberwiseClone());
					culture.readOnly = true;
					return culture;
				}
			}
開發者ID:jjenki11,項目名稱:blaze-chem-rendering,代碼行數:18,代碼來源:CultureInfo.cs


注:本文中的System.Globalization.CultureInfo.MemberwiseClone方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。