Example #1
0
        public void CanGetPropertyDrawerForType()
        {
            Assert.That(CustomInspectorDatabase.GetPropertyDrawer <NoInspectorType, DrawerAttribute>(), Is.Null);
            Assert.That(CustomInspectorDatabase.GetPropertyDrawer <SingleInspectorType, DrawerAttribute>(), Is.Null);
            Assert.That(CustomInspectorDatabase.GetPropertyDrawer <MultipleInspectorsType, DrawerAttribute>(), Is.Null);

            var d0 = CustomInspectorDatabase.GetPropertyDrawer <NoInspectorButDrawerType, DrawerAttribute>();

            Assert.That(d0, Is.Not.Null);
            Assert.That(d0, Is.TypeOf <NoInspectorButDrawerTypeDrawer>());

            var d1 = CustomInspectorDatabase.GetPropertyDrawer <InspectorAndDrawerType, DrawerAttribute>();

            Assert.That(d1, Is.Not.Null);
            Assert.That(d1, Is.TypeOf <InspectorAndDrawerTypeTypeDrawer>());
        }
Example #2
0
        static bool TryGetDrawer <TValue>(
            InspectorVisitor <T> visitor,
            IProperty property,
            PropertyPath propertyPath,
            string propertyName,
            InspectorVisitLevel visitLevel)
        {
            var inspector = CustomInspectorDatabase.GetPropertyDrawer <TValue>(property);

            if (null == inspector)
            {
                return(false);
            }
            var proxy           = new InspectorContext <TValue>(visitor.VisitorContext.Binding, property, propertyPath, propertyName, visitLevel);
            var customInspector = new CustomInspectorElement <TValue>(inspector, proxy);

            visitor.VisitorContext.Parent.contentContainer.Add(customInspector);
            inspector.Update(proxy);
            return(true);
        }