src/Runtime/Runtime/Core/Main/INTERNAL_PropertyStore.cs
/// <summary>
/// Attemp to get a Property Storage for an inherited property 
/// (faster than generic accessor 'TryGetStorage')
/// </summary>
/// <param name="dependencyObject"></param>
/// <param name="dependencyProperty"></param>
/// <param name="createIfNotFoud">when set to true, it forces the creation of the storage if it does not exists yet.</param>
/// <param name="storage"></param>
/// <returns></returns>
Attemp to get a Property Storage for an inherited property
(faster than generic accessor 'TryGetStorage')
Attemp to get a Property Storage for an inherited property ( faster than generic accessor ' TryGetStorage ' )
internal static bool TryGetInheritedPropertyStorage(DependencyObject dependencyObject,
                                                            DependencyProperty dependencyProperty,
                                                            bool createIfNotFoud,
                                                            out INTERNAL_PropertyStorage storage)
        {
            if (dependencyObject.INTERNAL_AllInheritedProperties.TryGetValue(dependencyProperty, out storage))
            {
                return true;
            }
            if (createIfNotFoud)
            {
                PropertyMetadata typeMetadata = dependencyProperty.GetTypeMetaData(dependencyObject.GetType());
                global::System.Diagnostics.Debug.Assert(typeMetadata != null && typeMetadata.Inherits,
                                                        $"{dependencyProperty.Name} is not an inherited property.");
                storage = new INTERNAL_PropertyStorage(dependencyObject, dependencyProperty, typeMetadata);
                if (dependencyProperty.OwnerType.IsAssignableFrom(dependencyObject.GetType()))
                {
                    dependencyObject.INTERNAL_PropertyStorageDictionary.Add(dependencyProperty, storage);
                }
                dependencyObject.INTERNAL_AllInheritedProperties.Add(dependencyProperty, storage);
            }
            return createIfNotFoud;
        }
internal static bool TryGetInheritedPropertyStorage ( DependencyObject dependencyObject , DependencyProperty dependencyProperty , bool createIfNotFoud , out INTERNAL_PropertyStorage storage ) { if ( dependencyObject . INTERNAL_AllInheritedProperties . TryGetValue ( dependencyProperty , out storage ) ) { return true ; } if ( createIfNotFoud ) { PropertyMetadata typeMetadata = dependencyProperty . GetTypeMetaData ( dependencyObject . GetType ( ) ) ; global :: System . Diagnostics . Debug . Assert ( typeMetadata != null && typeMetadata . Inherits , $" { dependencyProperty . Name }  is not an inherited property. " ) ; storage = new INTERNAL_PropertyStorage ( dependencyObject , dependencyProperty , typeMetadata ) ; if ( dependencyProperty . OwnerType . IsAssignableFrom ( dependencyObject . GetType ( ) ) ) { dependencyObject . INTERNAL_PropertyStorageDictionary . Add ( dependencyProperty , storage ) ; } dependencyObject . INTERNAL_AllInheritedProperties . Add ( dependencyProperty , storage ) ; } return createIfNotFoud ; }
Attemp to get a Property Storage for an inherited property
(faster than generic accessor 'TryGetStorage')
Attemp to get a Property Storage for an inherited property ( faster than generic accessor ' TryGetStorage ' )
// Create the Storage if it does not already exist // Get the type metadata (if any): // Create the storage: //----------------------- // CHECK IF THE PROPERTY BELONGS TO THE OBJECT (OR TO ONE OF ITS ANCESTORS): //----------------------- //below: we check if the property is useful to the current DependencyObject, in which case we set it as its inheritedValue in "PropertyStorageDictionary" //----------------------- // ADD THE STORAGE TO "INTERNAL_PropertyStorageDictionary" //-----------------------
None
dependencyObject
DependencyObject
None
dependencyProperty
DependencyProperty
None
createIfNotFoud
bool
when set to true, it forces the creation of the storage if it does not exists yet.
when set to true it forces the creation of the storage if it does not exists yet .
INTERNAL_PropertyStorage
out
storage
None