Beispiel #1
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[]");
        }