IInspector GetInspector <T>()
            {
                IInspector <T> inspector = default;

                switch (Target)
                {
                case InspectorTarget.Inspector:
                    inspector = InspectorRegistry.GetInspector <T>();
                    break;

                case InspectorTarget.PropertyInspector:
                    inspector = InspectorRegistry.GetPropertyInspector <T>(Property);
                    break;

                case InspectorTarget.AttributeInspector:
                    inspector = InspectorRegistry.GetAttributeInspector <T>(Property);
                    break;

                case InspectorTarget.None:
                default:
                    throw new ArgumentOutOfRangeException();
                }

                if (null != inspector)
                {
                    inspector.Context = new InspectorContext <T>(
                        Root,
                        PropertyPath,
                        Property,
                        Property.GetAttributes()
                        );
                }

                return(inspector);
            }
        public static IInspector GetAttributeInspector <TValue>(InspectorVisitor.InspectorContext inspectorContext,
                                                                IProperty property, ref TValue value, PropertyPath path)
        {
            if (RuntimeTypeInfoCache <TValue> .CanBeNull && EqualityComparer <TValue> .Default.Equals(value, default))
            {
                return(null);
            }

            if (!RuntimeTypeInfoCache <TValue> .IsContainerType)
            {
                var inspector = InspectorRegistry.GetAttributeInspector <TValue>(property);
                if (null != inspector)
                {
                    inspector.Context = new InspectorContext <TValue>(
                        inspectorContext.Root,
                        path,
                        property,
                        property.GetAttributes()
                        );
                }

                return(inspector);
            }

            using (var scoped = ScopedVisitor <CustomInspectorVisitor <TValue> > .Make())
            {
                var visitor = scoped.Visitor;
                visitor.Target       = InspectorTarget.AttributeInspector;
                visitor.PropertyPath = path;
                visitor.Root         = inspectorContext.Root;
                visitor.Property     = property;
                PropertyContainer.Accept(visitor, ref value);
                return(visitor.Inspector);
            }
        }
Пример #3
0
 IInspector GetAttributeDrawer <TValue>(
     IProperty property,
     ref TValue value,
     PropertyPath path)
 {
     return(Context.NextInspectorIsIgnored()
         ? null
         : InspectorRegistry.GetAttributeInspector(Context, property, ref value, path));
 }
Пример #4
0
        IInspector GetCustomInspector <TValue>(
            IProperty property,
            ref TValue value,
            PropertyPath path,
            bool root)
        {
            if (Context.NextInspectorIsIgnored())
            {
                return(null);
            }

            if (root && Context.Root is InspectorElement)
            {
                return(InspectorRegistry.GetInspector(Context, property, ref value, path));
            }
            return(InspectorRegistry.GetAttributeInspector(Context, property, ref value, path)
                   ?? InspectorRegistry.GetPropertyInspector(Context, property, ref value, path));
        }