Example #1
0
        protected override bool CreateChildren(bool diffOldChildren)
        {
            try {
                object[] rgobjs = (object[])objValue;


                ChildCollection.Clear();

                MultiPropertyDescriptorGridEntry[] mergedProps = PropertyMerger.GetMergedProperties(rgobjs, this, this.PropertySort, CurrentTab);

                Debug.WriteLineIf(CompModSwitches.DebugGridView.TraceVerbose && mergedProps == null, "PropertyGridView: MergedProps returned null!");

                if (mergedProps != null)
                {
                    ChildCollection.AddRange(mergedProps);
                }
                bool fExpandable = this.Children.Count > 0;
                if (!fExpandable)
                {
                    //Debug.WriteLine("Object " + rgobjs[0].GetType().FullName + " is not expandable because it has no children");
                    SetFlag(GridEntry.FL_EXPANDABLE_FAILED, true);
                }
                CategorizePropEntries();
                return(fExpandable);
            }
            catch {
                return(false);
            }
        }
        public void Should_return_definded_values_when_only_filled_section_provided()
        {
            var mergerUnderTest = new PropertyMerger<MergeSection>();
            var fullSection = NConfigurator.UsingFile("Configs\\MergeTest.config").GetSection<MergeSection>("FullSection");

            var resultSection = mergerUnderTest.Merge(new[] { fullSection });

            Assert.That(resultSection.IntValue, Is.EqualTo(4321));
            Assert.That(resultSection.BoolValue, Is.EqualTo(false));
            Assert.That(resultSection.StringValue, Is.EqualTo("FULL"));
        }
        public void Should_return_definded_values_when_only_filled_section_provided()
        {
            var mergerUnderTest = new PropertyMerger <MergeSection>();
            var fullSection     = NConfigurator.UsingFile("Configs\\MergeTest.config").GetSection <MergeSection>("FullSection");

            var resultSection = mergerUnderTest.Merge(new[] { fullSection });

            Assert.That(resultSection.IntValue, Is.EqualTo(4321));
            Assert.That(resultSection.BoolValue, Is.EqualTo(false));
            Assert.That(resultSection.StringValue, Is.EqualTo("FULL"));
        }
        public void Should_return_default_values_when_only_empty_section_provided()
        {
            var mergerUnderTest = new PropertyMerger<MergeSection>();
            var emptySection = NConfigurator.UsingFile("Configs\\MergeTest.config").GetSection<MergeSection>("EmptySection");

            var resultSection = mergerUnderTest.Merge(new[]{emptySection});

            Assert.That(resultSection.IntValue, Is.EqualTo(1234));
            Assert.That(resultSection.BoolValue, Is.EqualTo(true));
            Assert.That(resultSection.StringValue, Is.EqualTo("DEFAULT"));
        }
        public void Should_return_default_values_when_only_empty_section_provided()
        {
            var mergerUnderTest = new PropertyMerger <MergeSection>();
            var emptySection    = NConfigurator.UsingFile("Configs\\MergeTest.config").GetSection <MergeSection>("EmptySection");

            var resultSection = mergerUnderTest.Merge(new[] { emptySection });

            Assert.That(resultSection.IntValue, Is.EqualTo(1234));
            Assert.That(resultSection.BoolValue, Is.EqualTo(true));
            Assert.That(resultSection.StringValue, Is.EqualTo("DEFAULT"));
        }
        public void Should_return_overrided_values_when_several_sections_provided()
        {
            var mergerUnderTest = new PropertyMerger<MergeSection>();
            var fullSection = NConfigurator.UsingFile("Configs\\MergeTest.config").GetSection<MergeSection>("FullSection");
            var overrideSection = NConfigurator.UsingFile("Configs\\MergeTest.config").GetSection<MergeSection>("OverrideSection");

            var resultSection = mergerUnderTest.Merge(new[] { overrideSection ,fullSection });

            Assert.That(resultSection.IntValue, Is.EqualTo(4321));
            Assert.That(resultSection.BoolValue, Is.EqualTo(true));
            Assert.That(resultSection.StringValue, Is.EqualTo("OVERRIDE"));
        }
        public void Should_not_override_with_default_values_when_several_sections_provided()
        {
            var mergerUnderTest = new PropertyMerger<MergeSection>();
            var fullSection = NConfigurator.UsingFile("Configs\\MergeTest.config").GetSection<MergeSection>("FullSection");
            var emptySection = NConfigurator.UsingFile("Configs\\MergeTest.config").GetSection<MergeSection>("EmptySection");

            var resultSection = mergerUnderTest.Merge(new[] { emptySection, fullSection });

            Assert.That(resultSection.IntValue, Is.EqualTo(4321));
            Assert.That(resultSection.BoolValue, Is.EqualTo(false));
            Assert.That(resultSection.StringValue, Is.EqualTo("FULL"));
        }
        public void Should_not_override_with_default_values_when_several_sections_provided()
        {
            var mergerUnderTest = new PropertyMerger <MergeSection>();
            var fullSection     = NConfigurator.UsingFile("Configs\\MergeTest.config").GetSection <MergeSection>("FullSection");
            var emptySection    = NConfigurator.UsingFile("Configs\\MergeTest.config").GetSection <MergeSection>("EmptySection");

            var resultSection = mergerUnderTest.Merge(new[] { emptySection, fullSection });

            Assert.That(resultSection.IntValue, Is.EqualTo(4321));
            Assert.That(resultSection.BoolValue, Is.EqualTo(false));
            Assert.That(resultSection.StringValue, Is.EqualTo("FULL"));
        }
        public void Should_return_overrided_values_when_several_sections_provided()
        {
            var mergerUnderTest = new PropertyMerger <MergeSection>();
            var fullSection     = NConfigurator.UsingFile("Configs\\MergeTest.config").GetSection <MergeSection>("FullSection");
            var overrideSection = NConfigurator.UsingFile("Configs\\MergeTest.config").GetSection <MergeSection>("OverrideSection");

            var resultSection = mergerUnderTest.Merge(new[] { overrideSection, fullSection });

            Assert.That(resultSection.IntValue, Is.EqualTo(4321));
            Assert.That(resultSection.BoolValue, Is.EqualTo(true));
            Assert.That(resultSection.StringValue, Is.EqualTo("OVERRIDE"));
        }
Example #10
0
        protected void RecalculateTemplateBindableProperties()
        {
            this.templateBindableProperties.Clear();
            SceneNode[] objects = this.Objects;
            if (objects.Length != 1)
            {
                return;
            }
            SceneNode sceneNode = objects[0];

            if (sceneNode == null || sceneNode.StoryboardContainer == null || !typeof(ControlTemplateElement).IsAssignableFrom(sceneNode.StoryboardContainer.GetType()) || !sceneNode.Platform.Metadata.IsCapabilitySet(PlatformCapability.SupportNonFrameworkElementTemplateBinding) && !PlatformTypes.FrameworkElement.IsAssignableFrom((ITypeId)sceneNode.Type))
            {
                return;
            }
            Type targetElementType = sceneNode.StoryboardContainer.TargetElementType;

            if (!(targetElementType != (Type)null))
            {
                return;
            }
            IList <TargetedReferenceStep> mergedProperties = PropertyMerger.GetMergedProperties((IEnumerable <SceneNode>) new SceneNode[1]
            {
                sceneNode.ViewModel.CreateSceneNode(targetElementType)
            });
            IProjectContext projectContext = sceneNode.ProjectContext;

            foreach (TargetedReferenceStep targetedReferenceStep in (IEnumerable <TargetedReferenceStep>)mergedProperties)
            {
                DependencyPropertyReferenceStep referenceStep = targetedReferenceStep.ReferenceStep as DependencyPropertyReferenceStep;
                if (referenceStep != null)
                {
                    bool showReadOnly = true;
                    if (PropertyInspectorModel.IsPropertyBrowsable(objects, targetedReferenceStep, showReadOnly) && PropertyInspectorModel.IsAttachedPropertyBrowsable(objects, this.ObjectTypeId, targetedReferenceStep, (ITypeResolver)projectContext))
                    {
                        this.templateBindableProperties.Add(new TemplateBindablePropertyModel(referenceStep));
                    }
                }
            }
            this.templateBindableProperties.Sort((Comparison <TemplateBindablePropertyModel>)((left, right) => string.Compare(left.PropertyName, right.PropertyName, StringComparison.CurrentCulture)));
            this.OnPropertyChanged("TemplateBindableProperties");
        }
 protected override bool CreateChildren(bool diffOldChildren)
 {
     try
     {
         object[] objValue = (object[])base.objValue;
         base.ChildCollection.Clear();
         MultiPropertyDescriptorGridEntry[] entryArray = PropertyMerger.GetMergedProperties(objValue, this, base.PropertySort, this.CurrentTab);
         if (entryArray != null)
         {
             base.ChildCollection.AddRange(entryArray);
         }
         bool flag = this.Children.Count > 0;
         if (!flag)
         {
             this.SetFlag(0x80000, true);
         }
         base.CategorizePropEntries();
         return(flag);
     }
     catch
     {
         return(false);
     }
 }
Example #12
0
 private void AddElementPropertiesWithTypeFilter(SceneElement targetElement, ResourceEntryItem resource, System.Windows.Controls.ItemCollection menuItems, Type filterType)
 {
     SceneNode[] selection = new SceneNode[1]
     {
         (SceneNode)targetElement
     };
     foreach (TargetedReferenceStep targetedReferenceStep in (IEnumerable <TargetedReferenceStep>)PropertyMerger.GetMergedProperties((IEnumerable <SceneNode>)selection))
     {
         ReferenceStep referenceStep = targetedReferenceStep.ReferenceStep;
         if (referenceStep.Name != "Name" && PropertyInspectorModel.IsPropertyBrowsable(selection, targetedReferenceStep) && (PropertyInspectorModel.IsAttachedPropertyBrowsable(selection, targetElement.Type, targetedReferenceStep, (ITypeResolver)targetElement.ProjectContext) && PlatformTypeHelper.GetPropertyType((IProperty)referenceStep) != (Type)null) && (PlatformTypeHelper.GetPropertyType((IProperty)referenceStep).IsAssignableFrom(resource.Resource.Type.RuntimeType) && (filterType == (Type)null || filterType.IsAssignableFrom(PlatformTypeHelper.GetPropertyType((IProperty)referenceStep)))))
         {
             menuItems.Add((object)this.BuildPropertyMenuItem(targetElement, referenceStep, resource));
         }
     }
 }
        private static IList <ReferenceStep> GetBindablePropertiesInternal(SceneNode sceneNode, int maxCount, BindingPropertyHelper.BindingType bindingType)
        {
            List <ReferenceStep> list = new List <ReferenceStep>();

            if (!BindingPropertyHelper.IsBindableSceneNode(sceneNode))
            {
                return((IList <ReferenceStep>)list);
            }
            bool isDeclaringTypeBindable = BindingPropertyHelper.IsBindableType(sceneNode.Type.NearestResolvedType, bindingType);

            foreach (TargetedReferenceStep targetedReferenceStep in (IEnumerable <TargetedReferenceStep>)PropertyMerger.GetMergedProperties((IEnumerable <SceneNode>) new SceneNode[1]
            {
                sceneNode
            }))
            {
                if ((!BindingPropertyHelper.IsTargetMode(bindingType) || BindingPropertyHelper.IsPropertyBindableAsTarget(sceneNode, targetedReferenceStep.ReferenceStep, isDeclaringTypeBindable)) && (!BindingPropertyHelper.IsSourceMode(bindingType) || BindingPropertyHelper.IsPropertyBindableAsSource(sceneNode, targetedReferenceStep.ReferenceStep)))
                {
                    list.Add(targetedReferenceStep.ReferenceStep);
                    if (list.Count >= maxCount)
                    {
                        break;
                    }
                }
            }
            return((IList <ReferenceStep>)list);
        }