private static bool ValidateCacheSizeBeforeOrAfterViewport(object value)
        {
            VirtualizationCacheLength cacheLength = (VirtualizationCacheLength)value;

            return(DoubleUtil.GreaterThanOrClose(cacheLength.CacheBeforeViewport, 0.0) &&
                   DoubleUtil.GreaterThanOrClose(cacheLength.CacheAfterViewport, 0.0));
        }
 public override object ConvertTo(ITypeDescriptorContext typeDescriptorContext, CultureInfo cultureInfo, object value, Type destinationType)
 {
     if (destinationType == null)
     {
         throw new ArgumentNullException("destinationType");
     }
     if (value != null && value is VirtualizationCacheLength)
     {
         VirtualizationCacheLength cacheLength = (VirtualizationCacheLength)value;
         if (destinationType == typeof(string))
         {
             return(VirtualizationCacheLengthConverter.ToString(cacheLength, cultureInfo));
         }
         if (destinationType == typeof(InstanceDescriptor))
         {
             ConstructorInfo constructor = typeof(VirtualizationCacheLength).GetConstructor(new Type[]
             {
                 typeof(double),
                 typeof(VirtualizationCacheLengthUnit)
             });
             return(new InstanceDescriptor(constructor, new object[]
             {
                 cacheLength.CacheBeforeViewport,
                 cacheLength.CacheAfterViewport
             }));
         }
     }
     throw base.GetConvertToException(value, destinationType);
 }
 /// <summary>Initializes a new instance of the <see cref="T:System.Windows.Controls.HierarchicalVirtualizationConstraints" /> class.</summary>
 /// <param name="cacheLength">The size of the cache before and after the viewport.</param>
 /// <param name="cacheLengthUnit">The type of unit that is used by the <see cref="P:System.Windows.Controls.HierarchicalVirtualizationConstraints.CacheLength" /> property.</param>
 /// <param name="viewport">The size of the cache before and after the viewport.</param>
 // Token: 0x06005412 RID: 21522 RVA: 0x00174D2F File Offset: 0x00172F2F
 public HierarchicalVirtualizationConstraints(VirtualizationCacheLength cacheLength, VirtualizationCacheLengthUnit cacheLengthUnit, Rect viewport)
 {
     this._cacheLength      = cacheLength;
     this._cacheLengthUnit  = cacheLengthUnit;
     this._viewport         = viewport;
     this._scrollGeneration = 0L;
 }
 /// <summary>Sets the <see cref="P:System.Windows.Controls.VirtualizingPanel.CacheLength" /> attached property.</summary>
 /// <param name="element">The object to set the property on.</param>
 /// <param name="value">The size of the cache before and after the viewport when the <see cref="T:System.Windows.Controls.VirtualizingPanel" /> is virtualizing.</param>
 // Token: 0x06005A1C RID: 23068 RVA: 0x0018D557 File Offset: 0x0018B757
 public static void SetCacheLength(DependencyObject element, VirtualizationCacheLength value)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     element.SetValue(VirtualizingPanel.CacheLengthProperty, value);
 }
        // Token: 0x0600540E RID: 21518 RVA: 0x00174C2C File Offset: 0x00172E2C
        internal static string ToString(VirtualizationCacheLength cacheLength, CultureInfo cultureInfo)
        {
            char          numericListSeparator = TokenizerHelper.GetNumericListSeparator(cultureInfo);
            StringBuilder stringBuilder        = new StringBuilder(26);

            stringBuilder.Append(cacheLength.CacheBeforeViewport.ToString(cultureInfo));
            stringBuilder.Append(numericListSeparator);
            stringBuilder.Append(cacheLength.CacheAfterViewport.ToString(cultureInfo));
            return(stringBuilder.ToString());
        }
        //-------------------------------------------------------------------
        //
        //  Internal Methods
        //
        //-------------------------------------------------------------------

        #region Internal Methods

        /// <summary>
        /// Creates a string from a VirtualizationCacheLength given the CultureInfo.
        /// </summary>
        /// <param name="cacheLength">VirtualizationCacheLength.</param>
        /// <param name="cultureInfo">Culture Info.</param>
        /// <returns>Newly created string instance.</returns>
        static internal string ToString(VirtualizationCacheLength cacheLength, CultureInfo cultureInfo)
        {
            char listSeparator = TokenizerHelper.GetNumericListSeparator(cultureInfo);

            // Initial capacity [64] is an estimate based on a sum of:
            // 24 = 2x double (twelve digits is generous for the range of values likely)
            //  2 = 2x separator characters
            // Is 26 really a good number???
            StringBuilder sb = new StringBuilder(26);

            sb.Append(cacheLength.CacheBeforeViewport.ToString(cultureInfo));
            sb.Append(listSeparator);
            sb.Append(cacheLength.CacheAfterViewport.ToString(cultureInfo));
            return(sb.ToString());
        }