static TElement ConstructFoldout <TElement>(
            IProperty property,
            PropertyPath path,
            InspectorVisitorContext visitorContext
            )
            where TElement : Foldout, IContextElement, new()
        {
            var element = ConstructBase <TElement>(property, visitorContext.Parent);

            element.SetContext(visitorContext.Root, path);
            var targetType = visitorContext.Root.GetTargetType();

            element.SetValueWithoutNotify(UiPersistentState.GetFoldoutState(targetType, path));
            element.RegisterCallback <ChangeEvent <bool> >(evt => UiPersistentState.SetFoldoutState(targetType, path, evt.newValue));
            return(element);
        }
        public override void OnContextReady()
        {
            var list     = GetValue();
            var property = GetProperty();

            if (property.IsReadOnly && list.IsReadOnly)
            {
                m_Size.SetEnabledSmart(false);
                m_AddItemButton.SetEnabledSmart(false);
            }

            UsesPagination = HasAttribute <PaginationAttribute>();
            if (!UsesPagination)
            {
                m_PaginationElement.Enabled = false;
            }

            var pagination = GetAttribute <PaginationAttribute>();

            if (null == pagination)
            {
                return;
            }

            m_PaginationElement.OnChanged += () =>
            {
                UiPersistentState.SetPaginationState(Root.GetTargetType(), Path, m_PaginationElement.PaginationSize,
                                                     m_PaginationElement.CurrentPage);
                Reload();
            };

            m_PaginationElement.SetPaginationSizes(pagination.Sizes);
            m_PaginationElement.AutoHide = pagination.AutoHide;
            var paginationData = UiPersistentState.GetPaginationState(Root.GetTargetType(), Path);

            if (!paginationData.Equals(default(UiPersistentState.PaginationData)))
            {
                m_PaginationElement.TotalCount = GetValue()?.Count ?? 0;
                m_PaginationElement.SetPaginationSize(paginationData.PaginationSize);
                m_PaginationElement.GoToPage(paginationData.CurrentPage);
            }
        }