コード例 #1
0
        /// <summary>
        /// Create a context for the execution of the drivers we use to compute the shapes we will have to place
        /// on the frontend editor views. The context is computed only once per request.
        /// </summary>
        /// <param name="definition">The definition of the ContentType we are working on.</param>
        /// <returns>The context for the drivers.</returns>
        private BuildEditorContext BuildContext(ContentTypeDefinition definition)
        {
            if (_defaultContext == null)
            {
                var content = _contentManager.New(definition.Name); //our dummy content

                dynamic itemShape = CreateItemShape("Content_Edit");
                itemShape.ContentItem = content;

                _defaultContext = new BuildEditorContext(itemShape, content, string.Empty, _shapeFactory);
                //get the default placements: if we don't provide these ourselves, placement for shapes will default
                //to null, preventing them to be displayed at all times.
                var defaultPlacements = definition.GetPlacement(PlacementType.Editor);
                BindPlacement(_defaultContext, defaultPlacements);
            }
            return(_defaultContext);
        }