/// <summary>
        /// Construct an instance of TextFormatter implementation with the specified context
        /// </summary>
        /// <param name="soleContext"></param>
        /// <remarks>
        /// TextFormatter created via this special ctor takes a specified context and uses it as the only known
        /// context within its entire lifetime. It prohibits reentering of TextFormatter during formatting as only
        /// one context is allowed. This restriction is critical to the optimal break algorithm supported by the current
        /// version of PTLS.
        /// </remarks>
        internal TextFormatterImp(TextFormatterContext soleContext, TextFormattingMode textFormattingMode)
        {
            _textFormattingMode = textFormattingMode;

            if (soleContext != null)
            {
                _contextList.Add(soleContext);
            }

            _multipleContextProhibited = (_contextList.Count != 0);
        }
예제 #2
0
        /// <summary>
        /// ShrinkToFit - Shrink the data to fit in exactly one chunk
        /// </summary>
        internal void ShrinkToFit()
        {
            Debug.Assert(_chunkList.Count != 0);

            if (_chunkList.Count > 1 ||
                _chunkList[0].Length != _currOffset)
            {
                byte [] buffer = new byte[_currOffset];

                unsafe
                {
                    fixed(byte *pbData = buffer)
                    {
                        ReadData(pbData, 0, _currOffset);
                    }
                }

                ByteStreamGeometryContext.ReturnChunkToPool(_chunkList[0]);

                // The common case is a single chunk in a SingleItemList held by the FrugalStructList.
                // Avoid tearing down and recreating the SingleItemList by updating the lone element in-place,
                // especially since ShrinkToFit is called from DisposeCore when this object is about to die.
                if (_chunkList.Count == 1)
                {
                    _chunkList[0] = buffer;
                }
                else
                {
                    _chunkList = new FrugalStructList <byte[]>();
                    _chunkList.Add(buffer);
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Implementation of Freezable.CloneCurrentValueCore()
        /// </summary>
        protected override void CloneCurrentValueCore(Freezable source)
        {
            PointCollection sourcePointCollection = (PointCollection)source;

            base.CloneCurrentValueCore(source);

            int count = sourcePointCollection._collection.Count;

            _collection = new FrugalStructList <Point>(count);

            for (int i = 0; i < count; i++)
            {
                _collection.Add(sourcePointCollection._collection[i]);
            }
        }
        /// <summary>
        /// Implementation of Freezable.CloneCore()
        /// </summary>
        protected override void CloneCore(Freezable source)
        {
            DoubleCollection sourceDoubleCollection = (DoubleCollection)source;

            base.CloneCore(source);

            int count = sourceDoubleCollection._collection.Count;

            _collection = new FrugalStructList <double>(count);

            for (int i = 0; i < count; i++)
            {
                _collection.Add(sourceDoubleCollection._collection[i]);
            }
        }
예제 #5
0
        /// <summary>
        /// Implementation of Freezable.GetCurrentValueAsFrozenCore()
        /// </summary>
        protected override void GetCurrentValueAsFrozenCore(Freezable source)
        {
            Vector3DCollection sourceVector3DCollection = (Vector3DCollection)source;

            base.GetCurrentValueAsFrozenCore(source);

            int count = sourceVector3DCollection._collection.Count;

            _collection = new FrugalStructList <Vector3D>(count);

            for (int i = 0; i < count; i++)
            {
                _collection.Add(sourceVector3DCollection._collection[i]);
            }
        }
예제 #6
0
        /// <summary>
        /// Implementation of Freezable.GetAsFrozenCore()
        /// </summary>
        protected override void GetAsFrozenCore(Freezable source)
        {
            Point3DCollection sourcePoint3DCollection = (Point3DCollection)source;

            base.GetAsFrozenCore(source);

            int count = sourcePoint3DCollection._collection.Count;

            _collection = new FrugalStructList <Point3D>(count);

            for (int i = 0; i < count; i++)
            {
                _collection.Add(sourcePoint3DCollection._collection[i]);
            }
        }
예제 #7
0
        /// <summary>
        /// Implementation of Freezable.GetCurrentValueAsFrozenCore()
        /// </summary>
        protected override void GetCurrentValueAsFrozenCore(Freezable source)
        {
            TextEffectCollection sourceTextEffectCollection = (TextEffectCollection)source;

            base.GetCurrentValueAsFrozenCore(source);

            int count = sourceTextEffectCollection._collection.Count;

            _collection = new FrugalStructList <TextEffect>(count);

            for (int i = 0; i < count; i++)
            {
                TextEffect newValue = (TextEffect)sourceTextEffectCollection._collection[i].GetCurrentValueAsFrozen();
                OnFreezablePropertyChanged(/* oldValue = */ null, newValue);
                _collection.Add(newValue);
            }
        }
예제 #8
0
        /// <summary>
        /// Implementation of Freezable.CloneCurrentValueCore()
        /// </summary>
        protected override void CloneCurrentValueCore(Freezable source)
        {
            GradientStopCollection sourceGradientStopCollection = (GradientStopCollection)source;

            base.CloneCurrentValueCore(source);

            int count = sourceGradientStopCollection._collection.Count;

            _collection = new FrugalStructList <GradientStop>(count);

            for (int i = 0; i < count; i++)
            {
                GradientStop newValue = (GradientStop)sourceGradientStopCollection._collection[i].CloneCurrentValue();
                OnFreezablePropertyChanged(/* oldValue = */ null, newValue);
                _collection.Add(newValue);
            }
        }
예제 #9
0
        /// <summary>
        /// Implementation of Freezable.GetAsFrozenCore()
        /// </summary>
        protected override void GetAsFrozenCore(Freezable source)
        {
            GeneralTransformCollection sourceGeneralTransformCollection = (GeneralTransformCollection)source;

            base.GetAsFrozenCore(source);

            int count = sourceGeneralTransformCollection._collection.Count;

            _collection = new FrugalStructList <GeneralTransform>(count);

            for (int i = 0; i < count; i++)
            {
                GeneralTransform newValue = (GeneralTransform)sourceGeneralTransformCollection._collection[i].GetAsFrozen();
                OnFreezablePropertyChanged(/* oldValue = */ null, newValue);
                _collection.Add(newValue);
            }
        }
예제 #10
0
        /// <summary>
        /// Implementation of Freezable.CloneCore()
        /// </summary>
        protected override void CloneCore(Freezable source)
        {
            PathSegmentCollection sourcePathSegmentCollection = (PathSegmentCollection)source;

            base.CloneCore(source);

            int count = sourcePathSegmentCollection._collection.Count;

            _collection = new FrugalStructList <PathSegment>(count);

            for (int i = 0; i < count; i++)
            {
                PathSegment newValue = (PathSegment)sourcePathSegmentCollection._collection[i].Clone();
                OnFreezablePropertyChanged(/* oldValue = */ null, newValue);
                _collection.Add(newValue);
            }
        }
예제 #11
0
        /// <summary>
        /// Implementation of Freezable.CloneCore()
        /// </summary>
        protected override void CloneCore(Freezable source)
        {
            GeometryCollection sourceGeometryCollection = (GeometryCollection)source;

            base.CloneCore(source);

            int count = sourceGeometryCollection._collection.Count;

            _collection = new FrugalStructList <Geometry>(count);

            for (int i = 0; i < count; i++)
            {
                Geometry newValue = (Geometry)sourceGeometryCollection._collection[i].Clone();
                OnFreezablePropertyChanged(/* oldValue = */ null, newValue);
                _collection.Add(newValue);
                OnInsert(newValue);
            }
        }
예제 #12
0
        /// <summary>
        /// Implementation of Freezable.CloneCurrentValueCore()
        /// </summary>
        protected override void CloneCurrentValueCore(Freezable source)
        {
            Transform3DCollection sourceTransform3DCollection = (Transform3DCollection)source;

            base.CloneCurrentValueCore(source);

            int count = sourceTransform3DCollection._collection.Count;

            _collection = new FrugalStructList <Transform3D>(count);

            for (int i = 0; i < count; i++)
            {
                Transform3D newValue = (Transform3D)sourceTransform3DCollection._collection[i].CloneCurrentValue();
                OnFreezablePropertyChanged(/* oldValue = */ null, newValue);
                _collection.Add(newValue);
                OnInsert(newValue);
            }
        }
예제 #13
0
        /// <summary>
        /// Implementation of Freezable.GetAsFrozenCore()
        /// </summary>
        protected override void GetAsFrozenCore(Freezable source)
        {
            MaterialCollection sourceMaterialCollection = (MaterialCollection)source;

            base.GetAsFrozenCore(source);

            int count = sourceMaterialCollection._collection.Count;

            _collection = new FrugalStructList <Material>(count);

            for (int i = 0; i < count; i++)
            {
                Material newValue = (Material)sourceMaterialCollection._collection[i].GetAsFrozen();
                OnFreezablePropertyChanged(/* oldValue = */ null, newValue);
                _collection.Add(newValue);
                OnInsert(newValue);
            }
        }
예제 #14
0
        /// <summary>
        /// Creates a Vector3DCollection with all of the same elements as collection
        /// </summary>
        public Vector3DCollection(IEnumerable <Vector3D> collection)
        {
            // The WritePreamble and WritePostscript aren't technically necessary
            // in the constructor as of 1/20/05 but they are put here in case
            // their behavior changes at a later date

            WritePreamble();

            if (collection != null)
            {
                ICollection <Vector3D> icollectionOfT = collection as ICollection <Vector3D>;

                if (icollectionOfT != null)
                {
                    _collection = new FrugalStructList <Vector3D>(icollectionOfT);
                }
                else
                {
                    ICollection icollection = collection as ICollection;

                    if (icollection != null) // an IC but not and IC<T>
                    {
                        _collection = new FrugalStructList <Vector3D>(icollection);
                    }
                    else // not a IC or IC<T> so fall back to the slower Add
                    {
                        _collection = new FrugalStructList <Vector3D>();

                        foreach (Vector3D item in collection)
                        {
                            _collection.Add(item);
                        }
                    }
                }



                WritePostscript();
            }
            else
            {
                throw new ArgumentNullException("collection");
            }
        }
예제 #15
0
        //
        //  This method
        //  1. Adds a ChildPropertyDependent entry to the given
        //     PropertyDependents list. This is used when invalidating
        //     properties dependent upon a certain property on the container.
        //     The dependent properties could have originated from a Trigger
        //     or from a property alias on a TemplateNode.
        //
        private static void AddPropertyDependent(
            int                                             childIndex,
            DependencyProperty                              dp,
            ref FrugalStructList<ChildPropertyDependent>    propertyDependents)
        {
            ChildPropertyDependent dependent = new ChildPropertyDependent();
            dependent.ChildIndex = childIndex;
            dependent.Property = dp;

            propertyDependents.Add(dependent);
        }
예제 #16
0
        //
        //  This method
        //  1. Adds a ChildPropertyDependent entry to the given
        //     ResourceDependents list. This is used when invalidating
        //     resource references
        //
        private static void AddResourceDependent(
            int                                             childIndex,
            DependencyProperty                              dp,
            object                                          name,
            ref FrugalStructList<ChildPropertyDependent>    resourceDependents)
        {
            bool add = true;

            for (int i = 0; i < resourceDependents.Count; i++)
            {
                // Check for duplicate entry
                ChildPropertyDependent resourceDependent = resourceDependents[i];
                if ((resourceDependent.ChildIndex == childIndex) &&
                    (resourceDependent.Property == dp) &&
                    (resourceDependent.Name == name))
                {
                    add = false;
                    break;
                }
            }

            if (add)
            {
                // Since there isn't a duplicate entry,
                // create and add a new one
                ChildPropertyDependent resourceDependent = new ChildPropertyDependent();
                resourceDependent.ChildIndex = childIndex;
                resourceDependent.Property = dp;
                resourceDependent.Name = name;

                resourceDependents.Add(resourceDependent);
            }
        }
예제 #17
0
 /// <summary>
 /// Add a new span to vector
 /// </summary>
 private void Add(Span span)
 {
     _spans.Add(span);
 }
        internal void ShrinkToFit()
        {
            Debug.Assert(_chunkList.Count != 0);
 
            if (_chunkList.Count > 1 ||
                _chunkList[0].Length != _currOffset) 
            { 
                byte [] buffer = new byte[_currOffset];
 
                unsafe
                {
                    fixed (byte *pbData = buffer)
                    { 
                        ReadData(pbData, 0, _currOffset);
                    } 
 
                    _chunkList = new FrugalStructList<byte[]>();
                    _chunkList.Add(buffer); 
                }
            }
        }
예제 #19
0
        //
        //  All table datastructures read-lock-free/write-lock
        //  AddContainerDependent writes the datastructures, locks set by callers
        //
        //  This method
        //  1. Adds a ContainerDependent to the ContainerDependents list if not
        //     already present. This is used to invalidate container dependents.
        //
        internal static void AddContainerDependent(
            DependencyProperty                          dp,
            bool                                        fromVisualTrigger,
            ref FrugalStructList<ContainerDependent>    containerDependents)
        {
            ContainerDependent dependent;

            for (int i = 0; i < containerDependents.Count; i++)
            {
                dependent = containerDependents[i];

                if (dp == dependent.Property)
                {
                    // If the dp is set on targetType tag and can be set via TriggerBase it is recorded as coming
                    // from TriggerBase because that way we are pessimistic in invalidating and always invalidate.
                    dependent.FromVisualTrigger |= fromVisualTrigger;
                    return;
                }
            }

            dependent = new ContainerDependent();
            dependent.Property = dp;
            dependent.FromVisualTrigger = fromVisualTrigger;
            containerDependents.Add(dependent);
        }
예제 #20
0
        /// <summary>
        /// Creates a TextEffectCollection with all of the same elements as collection
        /// </summary>
        public TextEffectCollection(IEnumerable <TextEffect> collection)
        {
            // The WritePreamble and WritePostscript aren't technically necessary
            // in the constructor as of 1/20/05 but they are put here in case
            // their behavior changes at a later date

            WritePreamble();

            if (collection != null)
            {
                bool needsItemValidation = true;
                ICollection <TextEffect> icollectionOfT = collection as ICollection <TextEffect>;

                if (icollectionOfT != null)
                {
                    _collection = new FrugalStructList <TextEffect>(icollectionOfT);
                }
                else
                {
                    ICollection icollection = collection as ICollection;

                    if (icollection != null) // an IC but not and IC<T>
                    {
                        _collection = new FrugalStructList <TextEffect>(icollection);
                    }
                    else // not a IC or IC<T> so fall back to the slower Add
                    {
                        _collection = new FrugalStructList <TextEffect>();

                        foreach (TextEffect item in collection)
                        {
                            if (item == null)
                            {
                                throw new System.ArgumentException(SR.Get(SRID.Collection_NoNull));
                            }
                            TextEffect newValue = item;
                            OnFreezablePropertyChanged(/* oldValue = */ null, newValue);
                            _collection.Add(newValue);
                        }

                        needsItemValidation = false;
                    }
                }

                if (needsItemValidation)
                {
                    foreach (TextEffect item in collection)
                    {
                        if (item == null)
                        {
                            throw new System.ArgumentException(SR.Get(SRID.Collection_NoNull));
                        }
                        OnFreezablePropertyChanged(/* oldValue = */ null, item);
                    }
                }


                WritePostscript();
            }
            else
            {
                throw new ArgumentNullException("collection");
            }
        }
        internal void ShrinkToFit()
        {
            Debug.Assert(_chunkList.Count != 0);

            if (_chunkList.Count > 1 ||
                _chunkList[0].Length != _currOffset)
            {
                byte [] buffer = new byte[_currOffset];

                unsafe
                {
                    fixed (byte *pbData = buffer)
                    {
                        ReadData(pbData, 0, _currOffset);
                    }
                }

                ByteStreamGeometryContext.ReturnChunkToPool(_chunkList[0]);

                // The common case is a single chunk in a SingleItemList held by the FrugalStructList.
                // Avoid tearing down and recreating the SingleItemList by updating the lone element in-place,
                // especially since ShrinkToFit is called from DisposeCore when this object is about to die.
                if (_chunkList.Count == 1)
                {
                    _chunkList[0] = buffer;
                }
                else
                {
                    _chunkList = new FrugalStructList<byte[]>();
                    _chunkList.Add(buffer);
                }
            }
        }