IInspector GetInspector <T>()
        {
            var inspector = CustomInspectorDatabase.GetBestInspectorType <T>(Property);

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

            return(inspector);
        }
        static IInspector <TValue> GetInspector <TValue>(IProperty property, PropertyElement root, PropertyPath propertyPath)
        {
            var inspector = CustomInspectorDatabase.GetBestInspectorType <TValue>(property);

            if (null != inspector)
            {
                inspector.Context = new InspectorContext <TValue>(
                    root,
                    propertyPath,
                    property,
                    property.GetAttributes()
                    );
            }
            return(inspector);
        }
        static IInspector <TValue> GetPropertyDrawer <TValue>(IProperty property, PropertyElement root, PropertyPath propertyPath)
        {
            var drawer = CustomInspectorDatabase.GetPropertyDrawer <TValue>(property.GetAttributes());

            if (null != drawer)
            {
                drawer.Context = new InspectorContext <TValue>(
                    root,
                    propertyPath,
                    property,
                    property.GetAttributes()
                    );
            }
            return(drawer);
        }
Esempio n. 4
0
        public VisitStatus Visit <TContainer, TValue>(Property <TContainer, TValue> property, ref TContainer container,
                                                      ref TValue value)
        {
            if (RuntimeTypeInfoCache <TValue> .IsEnum)
            {
                return(RuntimeTypeInfoCache <TValue> .IsEnumFlags
                    ? VisitPrimitive(property, ref value, GuiFactory.FlagsField)
                    : VisitPrimitive(property, ref value, GuiFactory.EnumField));
            }

            if (RuntimeTypeInfoCache <TValue> .IsLazyLoadReference)
            {
                Visitor.AddToPath(property);
                try
                {
                    var path      = Visitor.GetCurrentPath();
                    var inspector = CustomInspectorDatabase.GetBestInspectorType <TValue>(property);
                    if (null == inspector)
                    {
                        var assetType     = typeof(TValue).GetGenericArguments()[0];
                        var inspectorType = typeof(LazyLoadReferenceInspector <>).MakeGenericType(assetType);
                        inspector = (Inspector <TValue>)Activator.CreateInstance(inspectorType);
                    }
                    inspector.Context = new InspectorContext <TValue>(
                        Visitor.VisitorContext.Root,
                        path,
                        property,
                        property.GetAttributes()
                        );
                    Visitor.VisitorContext.Parent.contentContainer.Add(
                        new CustomInspectorElement(path, inspector, Visitor.VisitorContext.Root));
                }
                finally
                {
                    Visitor.RemoveFromPath(property);
                }

                return(VisitStatus.Stop);
            }

            return(VisitStatus.Unhandled);
        }