public void IsInstanceOfType()
        {
            DependencyObjectType t  = DependencyObjectType.FromSystemType(typeof(TestDepObj));
            DependencyObjectType t2 = DependencyObjectType.FromSystemType(typeof(TestSubclass));

            Assert.IsTrue(t.IsInstanceOfType(new TestSubclass()));
            Assert.IsTrue(t2.IsSubclassOf(t));
            Assert.IsFalse(t.IsSubclassOf(t2));
        }
 internal FrameworkObject(DependencyObject d)
 {
     // [code should be identical to Reset(d)]
     this.dependencyObject = d;
     if (FrameworkElementDType.IsInstanceOfType(d))
     {
         this.frameworkElement        = (FrameworkElement)d;
         this.frameworkContentElement = null;
     }
     else if (FrameworkContentElementDType.IsInstanceOfType(d))
     {
         this.frameworkElement        = null;
         this.frameworkContentElement = (FrameworkContentElement)d;
     }
     else
     {
         this.frameworkElement        = null;
         this.frameworkContentElement = null;
     }
 }
        public bool Filter(PropertyDescriptor property)
        {
            if (this.element == null)
            {
                return(true);
            }

            // Filter the 20 stylistic set properties that I've never seen used.
            if (property.Name.Contains("Typography.StylisticSet"))
            {
                return(false);
            }

            AttachedPropertyBrowsableForChildrenAttribute          attachedPropertyForChildren  = (AttachedPropertyBrowsableForChildrenAttribute)property.Attributes[typeof(AttachedPropertyBrowsableForChildrenAttribute)];
            AttachedPropertyBrowsableForTypeAttribute              attachedPropertyForType      = (AttachedPropertyBrowsableForTypeAttribute)property.Attributes[typeof(AttachedPropertyBrowsableForTypeAttribute)];
            AttachedPropertyBrowsableWhenAttributePresentAttribute attachedPropertyForAttribute = (AttachedPropertyBrowsableWhenAttributePresentAttribute)property.Attributes[typeof(AttachedPropertyBrowsableWhenAttributePresentAttribute)];

            if (attachedPropertyForChildren != null)
            {
                DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(property);
                if (dpd == null)
                {
                    return(false);
                }

                FrameworkElement element = this.element;
                do
                {
                    element = element.Parent as FrameworkElement;
                    if (element != null && dpd.DependencyProperty.OwnerType.IsInstanceOfType(element))
                    {
                        return(true);
                    }
                }while (attachedPropertyForChildren.IncludeDescendants && element != null);
                return(false);
            }
            else if (attachedPropertyForType != null)
            {
                // when using [AttachedPropertyBrowsableForType(typeof(IMyInterface))] and IMyInterface is not a DependencyObject, Snoop crashes.
                // see http://snoopwpf.codeplex.com/workitem/6712

                if (attachedPropertyForType.TargetType.IsSubclassOf(typeof(DependencyObject)))
                {
                    DependencyObjectType doType = DependencyObjectType.FromSystemType(attachedPropertyForType.TargetType);
                    if (doType != null && doType.IsInstanceOfType(this.element))
                    {
                        return(true);
                    }
                }

                return(false);
            }
            else if (attachedPropertyForAttribute != null)
            {
                Attribute dependentAttribute = TypeDescriptor.GetAttributes(this.target)[attachedPropertyForAttribute.AttributeType];
                if (dependentAttribute != null)
                {
                    return(!dependentAttribute.IsDefaultAttribute());
                }
                return(false);
            }

            return(true);
        }