private IBuilderPropertyView GetPreviousBuilderPropertyView(IBuilderPropertyView builderPropertyView)
        {
            if (builderPropertyView.PropertyPosition.BuilderPropertyIndex != BuilderPropertyIndex.None)
            {
                var previousBuilderPropertyView =
                    BuilderPropertyViews.Value.Select(x => x.Value).FirstOrDefault(
                        x =>
                        x.BuilderProperty ==
                        builderPropertyView.PropertyPosition.BuilderPropertyIndex.PreviousBuilderProperty);

                if (previousBuilderPropertyView != null)
                {
                    return(previousBuilderPropertyView);
                }
            }

            var builderPropertyIndex =
                _builderProperties.IndexOf(
                    _builderProperties.First(x => x.GetType() == builderPropertyView.BuilderProperty));

            // if (builderPropertyIndex == 0)
            //    return null;

            for (int i = builderPropertyIndex - 1; i >= 0; i--)
            {
                var propertyView = BuilderPropertyViews.Value[_builderProperties[i].GetType()];
                if (propertyView.PropertyPosition.BuilderPropertyIndex == null)
                {
                    return(propertyView);
                }
            }

            return(null);
        }
        private IBuilderPropertyView FindRoot(IBuilderPropertyView builderPropertyView)
        {
            var rootBuilderPropertyView = builderPropertyView;

            while (true)
            {
                if (rootBuilderPropertyView.PropertyPosition.BuilderPropertyIndex == null)
                {
                    return(rootBuilderPropertyView);
                }

                rootBuilderPropertyView = GetPreviousBuilderPropertyView(rootBuilderPropertyView);
            }
        }
 /// <summary>
 ///     Initialize a new <see cref="BuilderPropertyEntry" />
 /// </summary>
 /// <param name="builderProperty">The builder property</param>
 /// <param name="builderPropertyView">The view of the builder property</param>
 public BuilderPropertyEntry(IBuilderProperty builderProperty, IBuilderPropertyView builderPropertyView)
 {
     BuilderProperty     = builderProperty;
     BuilderPropertyView = builderPropertyView;
 }