/// <summary> /// Creates an instance using the specified DependencyObject <see cref="Type"/> /// </summary> /// <param name="ownerType">The owner type</param> public DependencyPropertyDetailsCollection(Type ownerType, ManagedWeakReference ownerReference, DependencyProperty dataContextProperty, DependencyProperty templatedParentProperty) { _ownerType = ownerType; _ownerReference = ownerReference; var propertiesForType = DependencyProperty.GetPropertiesForType(ownerType); var entries = _pool.Rent(propertiesForType.Length); for (int i = 0; i < propertiesForType.Length; i++) { ref var entry = ref entries[i]; entry.Id = propertiesForType[i].UniqueId; entry.Details = null; }
/// <summary> /// Creates an instance using the specified DependencyObject <see cref="Type"/> /// </summary> /// <param name="ownerType">The owner type</param> public DependencyPropertyDetailsCollection(Type ownerType, DependencyProperty dataContextProperty, DependencyProperty templatedParentProperty) { _ownerType = ownerType; var propertiesForType = DependencyProperty.GetPropertiesForType(ownerType); var entries = new PropertyEntry[propertiesForType.Length]; for (int i = 0; i < propertiesForType.Length; i++) { entries[i].Id = propertiesForType[i].UniqueId; } // Entries are pre-sorted by the DependencyProperty.GetPropertiesForType method AssignEntries(entries, sort: false); // Prefecth known properties for faster access DataContextPropertyDetails = GetPropertyDetails(dataContextProperty); TemplatedParentPropertyDetails = GetPropertyDetails(templatedParentProperty); }
public DependencyPropertyDetailsCollection(Type ownerType, ManagedWeakReference ownerReference, DependencyProperty dataContextProperty, DependencyProperty templatedParentProperty) { _ownerType = ownerType; _ownerReference = ownerReference; var propertiesForType = DependencyProperty.GetPropertiesForType(ownerType); if (propertiesForType.Length != 0) { _minId = propertiesForType[0].UniqueId; _maxId = propertiesForType[propertiesForType.Length - 1].UniqueId; var entriesLength = _maxId - _minId + 1; var entries = _pool.Rent(entriesLength); // Entries are pre-sorted by the DependencyProperty.GetPropertiesForType method AssignEntries(entries, entriesLength); } _dataContextProperty = dataContextProperty; _templatedParentProperty = templatedParentProperty; }
private void EnsureEntriesInitialized() { if (_entries == null) { var propertiesForType = DependencyProperty.GetPropertiesForType(_ownerType); if (propertiesForType.Length != 0) { _minId = propertiesForType[0].UniqueId; _maxId = propertiesForType[propertiesForType.Length - 1].UniqueId; var entriesLength = _maxId - _minId + 1; var entries = _pool.Rent(entriesLength); // Entries are pre-sorted by the DependencyProperty.GetPropertiesForType method AssignEntries(entries, entriesLength); } else { _entries = Empty; } } }