Beispiel #1
0
 private bool CheckRecursion(IContent content, SocketParentContext parentContext, string displayType)
 {
     // Check the same item hasn't been rendered with the same display type further up the tree
     if (parentContext.Sockets.LeftContent.Id == content.Id && parentContext.Sockets.DisplayType==displayType)
     {
         return true;
     }
     // Move up chain
     if (parentContext.Parent != null)
     {
         return CheckRecursion(content, parentContext.Parent,displayType);
     }
     return false;
 }
Beispiel #2
0
 public SocketsModel(Orchard.ContentManagement.IContent left, string displayType, SocketParentContext parentContext)
 {
     this.LeftContent = left;
     this.DisplayType = displayType;
     ParentContext    = parentContext;
 }
Beispiel #3
0
        public void ApplyEditors(BuildEditorContext driverContext, SocketParentContext parentContext = null) {
            var rootShape = driverContext.Shape;
            var content = driverContext.Content;
            var displayType = "";
            var groupId = driverContext.GroupId;
            var updateContext = driverContext as UpdateEditorContext;
            var updater = updateContext == null ? null : updateContext.Updater;
            
            // Discover if this item has been displayed further up the chain. This prevents recursion.
            if (parentContext != null && CheckRecursion(content, parentContext,displayType))
            {
                _origami.Build(
                    _origami.Builder(new RecursionPreventedModel(content))
                    .WithMode("Display")
                    .WithDisplayType(displayType)
                    .WithStereotype("Sockets")
                    .WithContentType(content.ContentItem.ContentType)
                    .WithParent(parentContext.ModelContext)
                    .WithParadigms(parentContext.ModelContext.Paradigms)
                    , rootShape);
                return;
            }

            var context = new SocketsModel(content, displayType, parentContext);

            var prefix = "Sockets";
            if (parentContext != null && !String.IsNullOrWhiteSpace(parentContext.Prefix))
            {
                prefix = parentContext.Prefix + "." + prefix;
            }
//            ApplyParadigms(rootShape, context);

  //          var paradigms = context..DefaultParadigms.Split(',', StringSplitOptions.RemoveEmptyEntries);
            var builder = _origami.Builder(context)
                .WithMode("Editor")
                .WithUpdater(updater, prefix)
                .WithDisplayType(displayType)
                .WithStereotype("Sockets")
                .WithContentType(content.ContentItem.ContentType)
                .WithGroup(groupId);

            if (parentContext!=null) {
                builder.WithParent(parentContext.ModelContext)
                    .WithParadigms(parentContext.ModelContext.Paradigms);
            }
            _origami.Build(builder,rootShape);
        }
Beispiel #4
0
 public SocketsModel(Orchard.ContentManagement.IContent left, string displayType, SocketParentContext parentContext)
 {
     this.LeftContent = left;
     this.DisplayType = displayType;
     ParentContext = parentContext;
 }