ReadOnly() приватный Метод

private ReadOnly ( TextInfo textInfo ) : TextInfo
textInfo TextInfo
Результат TextInfo
Пример #1
0
        public static CultureInfo ReadOnly(CultureInfo ci)
        {
            if (ci == null)
            {
                throw new ArgumentNullException("ci");
            }

            if (ci.m_isReadOnly)
            {
                return(ci);
            }
            else
            {
                CultureInfo new_ci = (CultureInfo)ci.Clone();
                new_ci.m_isReadOnly = true;
                if (new_ci.numInfo != null)
                {
                    new_ci.numInfo = NumberFormatInfo.ReadOnly(new_ci.numInfo);
                }
                if (new_ci.dateTimeInfo != null)
                {
                    new_ci.dateTimeInfo = DateTimeFormatInfo.ReadOnly(new_ci.dateTimeInfo);
                }
                if (new_ci.textInfo != null)
                {
                    new_ci.textInfo = TextInfo.ReadOnly(new_ci.textInfo);
                }
                return(new_ci);
            }
        }
Пример #2
0
        public static CultureInfo ReadOnly(CultureInfo ci)
        {
            if (ci == null)
            {
                throw new ArgumentNullException("ci");
            }

            if (ci.m_isReadOnly)
            {
                return(ci);
            }
            else
            {
                CultureInfo new_ci = (CultureInfo)ci.Clone();
                new_ci.m_isReadOnly = true;
                if (new_ci.numInfo != null)
                {
                    new_ci.numInfo = NumberFormatInfo.ReadOnly(new_ci.numInfo);
                }
                if (new_ci.dateTimeInfo != null)
                {
                    new_ci.dateTimeInfo = DateTimeFormatInfo.ReadOnly(new_ci.dateTimeInfo);
                }
#if NET_2_0
                // TextInfo doesn't have a ReadOnly method in 1.1...
                if (new_ci.textInfo != null)
                {
                    new_ci.textInfo = TextInfo.ReadOnly(new_ci.textInfo);
                }
#endif
                return(new_ci);
            }
        }
Пример #3
0
        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._isReadOnly = true;

            return(newInfo);
        }