Example #1
0
        // Token: 0x060064D7 RID: 25815 RVA: 0x001C4A4C File Offset: 0x001C2C4C
        internal static void StoreItemValues(IContainItemStorage owner, DependencyObject container, object item)
        {
            int[]            itemValueStorageIndices = Helper.ItemValueStorageIndices;
            DependencyObject owner2 = (DependencyObject)owner;

            foreach (int num in itemValueStorageIndices)
            {
                EntryIndex entryIndex = container.LookupEntry(num);
                if (entryIndex.Found)
                {
                    EffectiveValueEntry effectiveValueEntry = container.EffectiveValues[(int)entryIndex.Index];
                    if ((effectiveValueEntry.BaseValueSourceInternal == BaseValueSourceInternal.Local || effectiveValueEntry.BaseValueSourceInternal == BaseValueSourceInternal.ParentTemplate) && !effectiveValueEntry.HasModifiers)
                    {
                        Helper.StoreItemValue(owner2, item, num, effectiveValueEntry.Value);
                    }
                    else if (effectiveValueEntry.IsCoercedWithCurrentValue)
                    {
                        Helper.StoreItemValue(owner2, item, num, new Helper.ModifiedItemValue(effectiveValueEntry.ModifiedValue.CoercedValue, FullValueSource.IsCoercedWithCurrentValue));
                    }
                    else
                    {
                        Helper.ClearItemValue(owner2, item, num);
                    }
                }
            }
        }
Example #2
0
        public void ClearClears()
        {
            var objects = new object[245];

            for (var i = 0; i < 245; i++)
            {
                objects[i] = new object();
            }

            var indexes = new EntryIndex <object> [245];

            for (var i = 0; i < 245; i++)
            {
                var key   = objects[i];
                var value = new object();

                FixedSizeDictionary.AddOrReplace(key, value, out var index);
                indexes[i] = index;
            }

            FixedSizeDictionary.Clear();

            for (var i = 0; i < 245; i++)
            {
                Assert.False(FixedSizeDictionary.ContainsKey(objects[i]));
                Assert.False(FixedSizeDictionary.ContainsKey(indexes[i]));

                Assert.False(FixedSizeDictionary.TryGetValue(objects[i], out _));
                Assert.False(FixedSizeDictionary.TryGetValue(indexes[i], out _));
            }
        }
Example #3
0
        protected override MutableObject Mutate(MutableObject mutable)
        {
            if (DataShare == null)
            {
                DataShare = new NodeDataShare <Dictionary <int, Vector3> >();
            }

            var groupId = GroupId.GetFirstValue(mutable);

            if (!DataShare.ContainsKey(groupId))
            {
                DataShare[groupId] = new Dictionary <int, Vector3>();
            }
            var vectors = DataShare[groupId];

            //var vectors = new Dictionary<int, Vector3>();
            foreach (var subEntry in EntryPosition.GetEntries(mutable))
            {
                var index    = EntryIndex.GetValue(subEntry);
                var position = EntryPosition.GetValue(subEntry);

                vectors[index] = position;
            }
            return(mutable);
        }
Example #4
0
        public void Copy()
        {
            var keys   = new object[245];
            var values = new object[245];

            for (int i = 0; i < 245; i++)
            {
                keys[i]   = new object();
                values[i] = new object();
            }

            var indexes = new EntryIndex <object> [245];

            for (int i = 0; i < 245; i++)
            {
                var key   = keys[i];
                var value = values[i];

                FixedSizeDictionary.AddOrReplace(key, value, out var index);
                indexes[i] = index;

                Assert.True(FixedSizeDictionary.ContainsKey(index));
                Assert.True(FixedSizeDictionary.ContainsKey(key));
                Assert.True(FixedSizeDictionary.TryGetValue(key, out var actualValue));

                Assert.Equal(value, actualValue);

                Assert.True(FixedSizeDictionary.TryGetValue(index, out actualValue));

                Assert.Equal(value, actualValue);
            }

            var destination = new FixedSizeDictionary <object, object, EqualityComparers.ReferenceEqualityComparer <object> >(15, 17, new EqualityComparers.ReferenceEqualityComparer <object>());

            FixedSizeDictionary.CopyTo(destination);
            FixedSizeDictionary.Clear();

            for (int i = 0; i < 245; i++)
            {
                var key   = keys[i];
                var value = values[i];
                destination.TryGetIndex(key, out var index);

                Assert.True(destination.ContainsKey(index));
                Assert.True(destination.ContainsKey(key));
                Assert.True(destination.TryGetValue(key, out var actualValue));

                Assert.Equal(value, actualValue);

                Assert.True(destination.TryGetValue(index, out actualValue));

                Assert.Equal(value, actualValue);
            }
        }
        /// <summary>
        /// Calculates current index for the given key
        /// </summary>
        /// <param name="key"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public bool TryGetIndex(TKey key, out EntryIndex <TKey> index)
        {
            if (_count == 0)
            {
                index = default;
                return(false);
            }

            var hash        = _comparer.GetHashCode(key);
            var bucketIndex = hash & _bucketMask;

            var inBucketEntryIndex = hash % _bucketSize;
            var entryIndex         = bucketIndex * _bucketSize + Math.Abs(inBucketEntryIndex);

            var entry = _entries[entryIndex];

            if (entry.Version != _version || hash == entry.Hash && _comparer.Equals(key, entry.Key))
            {
                index = new EntryIndex <TKey>(entryIndex, _version);
                return(true);
            }

            // handling possible collisions
            while (entry.Next != -1)
            {
                entry = _entries[entry.Next];
                if (!entry.IsNotDefault)
                {
                    break;
                }
                if (entry.Version == _version && (hash != entry.Hash || !_comparer.Equals(key, entry.Key)))
                {
                    continue;
                }

                index = new EntryIndex <TKey>(entry.Index, _version);
                return(true);
            }

            index = new EntryIndex <TKey>();
            return(false);
        }
 private static bool TargetFreezeValueCallback(
     DependencyObject d,
     DependencyProperty dp,
     EntryIndex entryIndex,
     PropertyMetadata metadata,
     bool isChecking)
 {
     // We allow the object to which the Target property is attached to be
     // frozen, even though the value of the Target property is not usable
     // from other threads.  Clocks clone & freeze copies of their original
     // timelines because the clocks will not respond to changes to those
     // timelines.
     return true;
 }
Example #7
0
 public object this[in EntryIndex <ChainSegment> entryIndex]
 {
     [MethodImpl(MethodImplOptions.AggressiveInlining)]
     get => _data[entryIndex];
Example #8
0
        // Token: 0x060064D6 RID: 25814 RVA: 0x001C48A4 File Offset: 0x001C2AA4
        internal static void SetItemValuesOnContainer(DependencyObject owner, DependencyObject container, object item)
        {
            int[] itemValueStorageIndices           = Helper.ItemValueStorageIndices;
            List <KeyValuePair <int, object> > list = Helper.GetItemValues(owner, item) ?? new List <KeyValuePair <int, object> >();

            foreach (int num in itemValueStorageIndices)
            {
                DependencyProperty dependencyProperty = DependencyProperty.RegisteredPropertyList.List[num];
                object             obj = DependencyProperty.UnsetValue;
                for (int j = 0; j < list.Count; j++)
                {
                    if (list[j].Key == num)
                    {
                        obj = list[j].Value;
                        break;
                    }
                }
                if (dependencyProperty != null)
                {
                    if (obj != DependencyProperty.UnsetValue)
                    {
                        Helper.ModifiedItemValue modifiedItemValue = obj as Helper.ModifiedItemValue;
                        if (modifiedItemValue == null)
                        {
                            container.SetValue(dependencyProperty, obj);
                        }
                        else if (modifiedItemValue.IsCoercedWithCurrentValue)
                        {
                            container.SetCurrentValue(dependencyProperty, modifiedItemValue.Value);
                        }
                    }
                    else if (container != container.GetValue(ItemContainerGenerator.ItemForItemContainerProperty))
                    {
                        EntryIndex          entryIndex          = container.LookupEntry(num);
                        EffectiveValueEntry effectiveValueEntry = new EffectiveValueEntry(dependencyProperty);
                        if (entryIndex.Found)
                        {
                            effectiveValueEntry = container.EffectiveValues[(int)entryIndex.Index];
                            if (effectiveValueEntry.IsCoercedWithCurrentValue)
                            {
                                container.InvalidateProperty(dependencyProperty, false);
                                entryIndex = container.LookupEntry(num);
                                if (entryIndex.Found)
                                {
                                    effectiveValueEntry = container.EffectiveValues[(int)entryIndex.Index];
                                }
                            }
                        }
                        if (entryIndex.Found && (effectiveValueEntry.BaseValueSourceInternal == BaseValueSourceInternal.Local || effectiveValueEntry.BaseValueSourceInternal == BaseValueSourceInternal.ParentTemplate) && !effectiveValueEntry.HasModifiers)
                        {
                            container.ClearValue(dependencyProperty);
                        }
                    }
                }
                else if (obj != DependencyProperty.UnsetValue)
                {
                    EntryIndex entryIndex2 = container.LookupEntry(num);
                    container.SetEffectiveValue(entryIndex2, null, num, null, obj, BaseValueSourceInternal.Local);
                }
            }
        }