Exemple #1
0
        public static void PerformActionOnNativePropertyDefinitions <T>(PropertyDependencyType targetDependencyType, ICollection <T> propertyDefinitions, Action <NativeStorePropertyDefinition> action) where T : PropertyDefinition
        {
            EnumValidator.AssertValid <PropertyDependencyType>(targetDependencyType);
            if (propertyDefinitions == null)
            {
                return;
            }
            int actualDependencyCount = 0;

            foreach (T t in propertyDefinitions)
            {
                PropertyDefinition      propertyDefinition      = t;
                StorePropertyDefinition storePropertyDefinition = InternalSchema.ToStorePropertyDefinition(propertyDefinition);
                storePropertyDefinition.ForEachMatch(targetDependencyType, delegate(NativeStorePropertyDefinition item)
                {
                    action(item);
                    actualDependencyCount++;
                });
            }
            int num = (propertyDefinitions.Count >= StorePropertyDefinition.dependencyEstimates.Length) ? propertyDefinitions.Count : StorePropertyDefinition.dependencyEstimates[propertyDefinitions.Count];

            if (actualDependencyCount != num && propertyDefinitions.Count < StorePropertyDefinition.dependencyEstimates.Length)
            {
                Interlocked.Exchange(ref StorePropertyDefinition.dependencyEstimates[propertyDefinitions.Count], actualDependencyCount);
            }
        }
 protected override void ForEachMatch(PropertyDependencyType targetDependencyType, Action <NativeStorePropertyDefinition> action)
 {
     if ((targetDependencyType & PropertyDependencyType.NeedForRead) != PropertyDependencyType.None)
     {
         action(this);
     }
 }
 protected override void ForEachMatch(PropertyDependencyType targetDependencyType, Action <NativeStorePropertyDefinition> action)
 {
     for (int i = 0; i < this.dependencies.Length; i++)
     {
         PropertyDependency propertyDependency = this.dependencies[i];
         if ((propertyDependency.Type & targetDependencyType) != PropertyDependencyType.None)
         {
             action(propertyDependency.Property);
         }
     }
 }
Exemple #4
0
 public static ICollection <NativeStorePropertyDefinition> GetNativePropertyDefinitions <T>(PropertyDependencyType targetDependencyType, ICollection <T> propertyDefinitions) where T : PropertyDefinition
 {
     return(StorePropertyDefinition.GetNativePropertyDefinitions <T>(targetDependencyType, propertyDefinitions, true, null));
 }
Exemple #5
0
 public static IList <NativeStorePropertyDefinition> GetNativePropertyDefinitions <T>(PropertyDependencyType targetDependencyType, ICollection <T> propertyDefinitions, Predicate <NativeStorePropertyDefinition> addToCollection) where T : PropertyDefinition
 {
     return((IList <NativeStorePropertyDefinition>)StorePropertyDefinition.GetNativePropertyDefinitions <T>(targetDependencyType, propertyDefinitions, false, addToCollection));
 }
Exemple #6
0
 protected abstract void ForEachMatch(PropertyDependencyType targetDependencyType, Action <NativeStorePropertyDefinition> action);
Exemple #7
0
        private static ICollection <NativeStorePropertyDefinition> GetNativePropertyDefinitions <T>(PropertyDependencyType targetDependencyType, ICollection <T> propertyDefinitions, bool hashSetOrList, Predicate <NativeStorePropertyDefinition> addToCollection) where T : PropertyDefinition
        {
            EnumValidator.AssertValid <PropertyDependencyType>(targetDependencyType);
            if (propertyDefinitions == null)
            {
                return(StorePropertyDefinition.EmptyNativeStoreProperties);
            }
            int num = (propertyDefinitions.Count >= StorePropertyDefinition.dependencyEstimates.Length) ? propertyDefinitions.Count : StorePropertyDefinition.dependencyEstimates[propertyDefinitions.Count];
            ICollection <NativeStorePropertyDefinition> collection = null;
            Action <NativeStorePropertyDefinition>      action;

            if (hashSetOrList)
            {
                HashSet <NativeStorePropertyDefinition> nativePropertyDefinitionsSet = new HashSet <NativeStorePropertyDefinition>(num);
                action = delegate(NativeStorePropertyDefinition item)
                {
                    if (addToCollection == null)
                    {
                        nativePropertyDefinitionsSet.TryAdd(item);
                        return;
                    }
                    if (addToCollection(item))
                    {
                        nativePropertyDefinitionsSet.TryAdd(item);
                    }
                };
                collection = nativePropertyDefinitionsSet;
            }
            else
            {
                IList <NativeStorePropertyDefinition> loadList = new List <NativeStorePropertyDefinition>(num);
                action = delegate(NativeStorePropertyDefinition item)
                {
                    if (addToCollection == null)
                    {
                        loadList.Add(item);
                        return;
                    }
                    if (addToCollection(item))
                    {
                        loadList.Add(item);
                    }
                };
                collection = loadList;
            }
            foreach (T t in propertyDefinitions)
            {
                PropertyDefinition      propertyDefinition      = t;
                StorePropertyDefinition storePropertyDefinition = InternalSchema.ToStorePropertyDefinition(propertyDefinition);
                storePropertyDefinition.ForEachMatch(targetDependencyType, action);
            }
            int count = collection.Count;

            if (count != num && propertyDefinitions.Count < StorePropertyDefinition.dependencyEstimates.Length)
            {
                Interlocked.Exchange(ref StorePropertyDefinition.dependencyEstimates[propertyDefinitions.Count], count);
            }
            return(collection);
        }
Exemple #8
0
 private static void AddSmartPropertyToSet <T>(HashSet <T> propertySet, PropertyDependency[] dependencies, PropertyDependencyType dependencyType) where T : PropertyDefinition
 {
     if (dependencies == null)
     {
         return;
     }
     foreach (PropertyDependency propertyDependency in dependencies)
     {
         if ((propertyDependency.Type & dependencyType) != PropertyDependencyType.None)
         {
             propertySet.Add(propertyDependency.Property as T);
         }
     }
 }
 protected sealed override void ForEachMatch(PropertyDependencyType targetDependencyType, Action <NativeStorePropertyDefinition> action)
 {
 }
 internal PropertyDependency(NativeStorePropertyDefinition property, PropertyDependencyType type)
 {
     this.Type     = type;
     this.Property = property;
 }