public SocketDisplayContext(IContent leftContent, ConnectorDescriptor connectorDefinition, string displayType, SocketsModel socketsContext)
     : base(leftContent, connectorDefinition, socketsContext)
 {
     Left.DisplayType = displayType;
     CacheSocket = false;
     Paradigms = new ParadigmsContext();
 }
Beispiel #2
0
        public void OnResultExecuting(ResultExecutingContext filterContext)
        {
            // Paperclips should only run on a full view rendering result
            var viewResult = filterContext.Result as ViewResult;
            if (viewResult == null)
                return;

            // Don't run on Admin either
            if (AdminFilter.IsApplied(filterContext.RequestContext))
                return;

            var workContext = _workContextAccessor.GetContext(filterContext);

            // Some standard checks
            if (workContext == null ||
                workContext.Layout == null ||
                workContext.CurrentSite == null ||
                AdminFilter.IsApplied(filterContext.RequestContext))
            {
                return;
            }

            var site = workContext.CurrentSite;

            // Create a dummy sockets container which will be used to build user and site display. We don't really want to display this shape
            // (although it could possibly be useful) but we might want certain of its sockets or connectors to appear in zones, which will happen
            // during display building via socket events.
            var sockets = Shape.Sockets();

            var sitePart = site.As<SocketsPart>();
            if (sitePart != null)
            {
                // Building the display will cause any paperclips to perform push into layout
                // TODO: Probably building loads of inefficient sockets, need to check up on this and eradicate via placement.
                var model = new SocketsModel(sitePart, "Detail", null);
                var builder = _origami.Builder(model).WithDisplayType("Detail").WithMode("Display").WithParadigms(new[]{"Paperclip"});
                _origami.Build(builder,sockets);
            }
            // Same for User
            var user = workContext.CurrentUser;
            if (user != null)
            {
                var userPart = user.As<SocketsPart>();
                if (userPart != null)
                {
                    // Building the display will cause any paperclips to perform push into layout
                    var model = new SocketsModel(userPart, "Detail", null);
                    var builder = _origami.Builder(model).WithDisplayType("Detail").WithMode("Display").WithParadigms(new[] { "Paperclip" });
                    _origami.Build(builder, sockets);
                }
            }

        }
 public SocketEventContext(IContent leftContent, ConnectorDescriptor connectorDefinition,SocketsModel socketsContext)
 {
     Left = leftContent.As<SocketsPart>().Endpoint;
     Connector = connectorDefinition;
     SocketFilters = new List<ISocketFilter>();
     SocketSorters= new List<ISocketFilter>();
     RootModel = socketsContext;
     RenderSocket = true;
     SocketMetadata = new SocketMetadata() {
         SocketName = connectorDefinition.Name,
         SocketTitle = Connector.Settings.SocketDisplayName
     };
     QueryFactory = new Lazy<SocketQuery>(() => {
         var query = Left.ContentPart.Sockets[Connector.Name];
         return query;
     });
 }
 public SocketEventContext(IContent leftContent, ConnectorDescriptor connectorDefinition, SocketsModel socketsContext)
 {
     Left           = leftContent.As <SocketsPart>().Endpoint;
     Connector      = connectorDefinition;
     SocketFilters  = new List <ISocketFilter>();
     SocketSorters  = new List <ISocketFilter>();
     RootModel      = socketsContext;
     RenderSocket   = true;
     SocketMetadata = new SocketMetadata()
     {
         SocketName  = connectorDefinition.Name,
         SocketTitle = Connector.Settings.SocketDisplayName
     };
     QueryFactory = new Lazy <SocketQuery>(() => {
         var query = Left.ContentPart.Sockets[Connector.Name];
         return(query);
     });
 }
Beispiel #5
0
 public SocketDisplayContext(IContent leftContent, ConnectorDescriptor connectorDefinition, string displayType, SocketsModel socketsContext)
     : base(leftContent, connectorDefinition, socketsContext)
 {
     Left.DisplayType = displayType;
     CacheSocket      = false;
     Paradigms        = new ParadigmsContext();
 }
Beispiel #6
0
        // TODO: Slight changes made to ApplyDisplay need applying to Editor/Update also
        public void ApplyDisplay(BuildDisplayContext driverContext) {
            var rootShape = driverContext.Shape;
            var content = driverContext.Content;
            var displayType = driverContext.DisplayType;
            var groupId = driverContext.GroupId;
            SocketParentContext parentContext = null;

            var origamiContext = driverContext as BuildContentDisplayContext;
            if (origamiContext != null) {
                if (origamiContext.ParentContext != null) {
                    origamiContext.ParentContext.With<SocketParentContext>(s => {
                        parentContext = s;
                    });
                }
            }

            // Discover if this item has been displayed further up the chain. This prevents recursion.
            if (parentContext!=null && CheckRecursion(content,parentContext,displayType)) {
                var builder1 = _origami.BuildDisplayShape(new RecursionPreventedModel(content), "", displayType, "Sockets", content.ContentItem.ContentType, parentContext.ModelContext);
                _origami.Build(builder1, rootShape);
                return;
            }

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

            // Build Sockets model
            var model = new SocketsModel(content, displayType, parentContext);

            var builder = _origami.Builder(model)
                .WithMode("Display")
                .WithUpdater(null, prefix)
                .WithDisplayType(displayType)
                .WithStereotype("Sockets")
                .WithContentType(content.ContentItem.ContentType)
                    .WithGroup(groupId);
            if (origamiContext != null) {
                builder.WithParent(origamiContext.ParentContext);
                builder.WithParadigms(origamiContext.ParentContext.Paradigms);
            }

            _origami.Build(builder, rootShape);
        }
Beispiel #7
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);
        }