Example #1
0
        // Initialize the collection holder, by setting its property definition and default value (retrieved
        // from the property definition).
        internal void InitDefaultValue()
        {
            if (AttributeName == "Resources" &&
                Parent is IHaveResources)
            {
                // "Fast Path" handling of Resources non-DP property
                _resourcesParent   = ((IHaveResources)Parent);
                _defaultCollection = _resourcesParent.Resources;
            }

            // the order of precedence according to the spec is DP, then attached property, then PropertyInfo
            else if (PropertyDefinition.DependencyProperty != null)
            {
                _defaultCollection = ((DependencyObject)Parent).GetValue(PropertyDefinition.DependencyProperty);
            }
            else if (PropertyDefinition.AttachedPropertyGetter != null)
            {
                _defaultCollection = PropertyDefinition.AttachedPropertyGetter.Invoke(null, new object[] { Parent });
            }
            else if (PropertyDefinition.PropertyInfo != null)
            {
                if (PropertyDefinition.IsInternal)
                {
                    _defaultCollection = XamlTypeMapper.GetInternalPropertyValue(_reader.ParserContext,
                                                                                 _reader.ParserContext.RootElement,
                                                                                 PropertyDefinition.PropertyInfo,
                                                                                 Parent);

                    if (_defaultCollection == null)
                    {
                        _reader.ThrowException(SRID.ParserCantGetProperty, PropertyDefinition.Name);
                    }
                }
                else
                {
                    _defaultCollection = PropertyDefinition.PropertyInfo.GetValue(
                        Parent, BindingFlags.Instance |
                        BindingFlags.Public | BindingFlags.FlattenHierarchy,
                        null, null, TypeConverterHelper.InvariantEnglishUS);
                }
            }
            else
            {
                _reader.ThrowException(SRID.ParserCantGetDPOrPi, AttributeName);
            }
        }
 // Token: 0x06001D22 RID: 7458 RVA: 0x00087C30 File Offset: 0x00085E30
 internal void InitDefaultValue()
 {
     if (this.AttributeName == "Resources" && this.Parent is IHaveResources)
     {
         this._resourcesParent   = (IHaveResources)this.Parent;
         this._defaultCollection = this._resourcesParent.Resources;
         return;
     }
     if (this.PropertyDefinition.DependencyProperty != null)
     {
         this._defaultCollection = ((DependencyObject)this.Parent).GetValue(this.PropertyDefinition.DependencyProperty);
         return;
     }
     if (this.PropertyDefinition.AttachedPropertyGetter != null)
     {
         this._defaultCollection = this.PropertyDefinition.AttachedPropertyGetter.Invoke(null, new object[]
         {
             this.Parent
         });
         return;
     }
     if (this.PropertyDefinition.PropertyInfo != null)
     {
         if (!this.PropertyDefinition.IsInternal)
         {
             this._defaultCollection = this.PropertyDefinition.PropertyInfo.GetValue(this.Parent, BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy, null, null, TypeConverterHelper.InvariantEnglishUS);
             return;
         }
         this._defaultCollection = XamlTypeMapper.GetInternalPropertyValue(this._reader.ParserContext, this._reader.ParserContext.RootElement, this.PropertyDefinition.PropertyInfo, this.Parent);
         if (this._defaultCollection == null)
         {
             this._reader.ThrowException("ParserCantGetProperty", this.PropertyDefinition.Name);
             return;
         }
     }
     else
     {
         this._reader.ThrowException("ParserCantGetDPOrPi", this.AttributeName);
     }
 }