private static bool IsPropertyBindableAsTarget(SceneNode sceneNode, ReferenceStep referenceStep, bool isDeclaringTypeBindable)
        {
            if (referenceStep.Equals((object)referenceStep.DeclaringType.Metadata.NameProperty) || (referenceStep.WriteAccess & (MemberAccessType)14) == MemberAccessType.None)
            {
                return(false);
            }
            SceneNode[] selection = new SceneNode[1]
            {
                sceneNode
            };
            TargetedReferenceStep targetedReferenceStep = new TargetedReferenceStep(referenceStep, sceneNode.Type);

            if ((!PropertyInspectorModel.IsPropertyBrowsable(selection, targetedReferenceStep) || !PropertyInspectorModel.IsAttachedPropertyBrowsable(selection, sceneNode.Type, targetedReferenceStep, (ITypeResolver)sceneNode.ProjectContext)) && !referenceStep.Equals((object)ContentControlElement.ContentProperty))
            {
                return(false);
            }
            if (referenceStep.PropertyType.IsBinding)
            {
                return(true);
            }
            object[] customAttributes = referenceStep.GetCustomAttributes(typeof(BindableAttribute), false);
            if (customAttributes != null && customAttributes.Length > 0)
            {
                return(((BindableAttribute)customAttributes[0]).Bindable);
            }
            return(isDeclaringTypeBindable && referenceStep is DependencyPropertyReferenceStep);
        }
        private static bool IsPropertyBindableAsSource(SceneNode sceneNode, ReferenceStep referenceStep)
        {
            if ((referenceStep.ReadAccess & (MemberAccessType)14) == MemberAccessType.None)
            {
                return(false);
            }
            SceneNode[] selection = new SceneNode[1]
            {
                sceneNode
            };
            TargetedReferenceStep targetedReferenceStep = new TargetedReferenceStep(referenceStep, sceneNode.Type);

            return(PropertyInspectorModel.IsPropertyBrowsable(selection, targetedReferenceStep, true, true) && PropertyInspectorModel.IsAttachedPropertyBrowsable(selection, sceneNode.Type, targetedReferenceStep, (ITypeResolver)sceneNode.ProjectContext));
        }
Beispiel #3
0
        public void Rebuild()
        {
            foreach (PropertyBase propertyBase in this.subProperties)
            {
                propertyBase.Associated = false;
            }
            PropertyDescriptorCollection descriptorCollection = (PropertyDescriptorCollection)null;
            Type         targetType = this.parentProperty.PropertyType;
            bool         isMixed;
            DocumentNode valueAsDocumentNode = this.parentProperty.GetLocalValueAsDocumentNode(true, out isMixed);

            if (valueAsDocumentNode == null || !(valueAsDocumentNode is DocumentPrimitiveNode) && !valueAsDocumentNode.Type.IsBinding)
            {
                TypeConverter converterFromAttributes = MetadataStore.GetTypeConverterFromAttributes(targetType.Assembly, this.parentProperty.Attributes);
                if (converterFromAttributes != null)
                {
                    object obj = this.parentProperty.SceneNodeObjectSet.GetValue(this.parentProperty.Reference, this.parentProperty.IsExpression ? PropertyReference.GetValueFlags.Computed : PropertyReference.GetValueFlags.Local);
                    if (obj != null && obj != MixedProperty.Mixed)
                    {
                        descriptorCollection = converterFromAttributes.GetProperties(obj);
                        targetType           = obj.GetType();
                    }
                }
                if (descriptorCollection == null)
                {
                    object component = this.parentProperty.SceneNodeObjectSet.GetValue(this.parentProperty.Reference, this.parentProperty.IsExpression ? PropertyReference.GetValueFlags.Computed : PropertyReference.GetValueFlags.Local);
                    if (component != null && component != MixedProperty.Mixed)
                    {
                        descriptorCollection = TypeUtilities.GetProperties(component);
                        targetType           = component.GetType();
                    }
                }
            }
            this.objectSet.RebuildObjects();
            IProjectContext projectContext = this.parentProperty.SceneNodeObjectSet.ProjectContext;

            if (projectContext != null && descriptorCollection != null)
            {
                SceneNode[] objects = this.objectSet.Objects;
                foreach (PropertyDescriptor propertyDescriptor in descriptorCollection)
                {
                    ReferenceStep referenceStep = PlatformTypeHelper.GetProperty((ITypeResolver)projectContext, targetType, propertyDescriptor) as ReferenceStep;
                    if (referenceStep != null)
                    {
                        TargetedReferenceStep targetedReferenceStep = new TargetedReferenceStep(referenceStep, this.objectSet.ObjectTypeId);
                        if (PropertyInspectorModel.IsPropertyBrowsable(objects, targetedReferenceStep) && PropertyInspectorModel.IsAttachedPropertyBrowsable(objects, this.objectSet.ObjectTypeId, targetedReferenceStep, (ITypeResolver)this.parentProperty.SceneNodeObjectSet.ProjectContext))
                        {
                            PropertyReference propertyReference = new PropertyReference(referenceStep);
                            SceneNodeProperty property          = this.FindProperty(propertyReference);
                            if (property == null)
                            {
                                SceneNodeProperty sceneNodeProperty = this.objectSet.CreateProperty(propertyReference, referenceStep.Attributes) as SceneNodeProperty;
                                int index = this.subProperties.BinarySearch(sceneNodeProperty, (IComparer <SceneNodeProperty>) new SceneNodePropertyCollection.PropertyNameComparer());
                                if (index < 0)
                                {
                                    index = ~index;
                                }
                                this.subProperties.Insert(index, sceneNodeProperty);
                                this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, (object)sceneNodeProperty, index));
                            }
                            else if (!property.UpdateAndRefresh(propertyReference, referenceStep.Attributes, (Type)null))
                            {
                                property.Associated = true;
                            }
                        }
                    }
                }
            }
            for (int index = this.subProperties.Count - 1; index >= 0; --index)
            {
                if (!this.subProperties[index].Associated)
                {
                    PropertyEntry propertyEntry = (PropertyEntry)this.subProperties[index];
                    this.subProperties[index].OnRemoveFromCategory();
                    this.subProperties.RemoveAt(index);
                    this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, (object)propertyEntry, index));
                }
            }
            this.OnPropertyChanged("Item[]");
        }