public void Subscribe(RootBuilder describe)
 {
     describe.Scope("Content", content => {
         // Root all items in layout
         content.Factory <RootShape, dynamic>((context) =>
         {
             var layout = _workContextAccessor.GetContext().Layout;
             var item   = context.Get <Model, object>() as IContent;
             // Save the item there so we can use correct CSS class in layout
             layout.ContentItem = item;
             layout.Title       = item.ContentItem.ContentManager.GetItemMetadata(item.ContentItem).DisplayText;
             return(layout);
         }
                                              );
         // Prevent displaying anything in Content zone on layout
         content.Factory <ActionResultBuilder, Func <ControllerBase, object, ActionResult> >((context) => (c, o) => {
             // Return Null (empty) view
             return(new ViewResult()
             {
                 MasterName = null,
                 ViewName = "Null",
                 ViewData = c.ViewData,
                 TempData = c.TempData
             });
         });
     });
 }
        public void Subscribe(RootBuilder describe)
        {
            describe.Scope("Search.Ajax", compose => {
                // Following mutate should be in LensCompositionProvider?
                compose.Mutate <ContentList, ParadigmsContext>((p, context) => p.Add("Lens"));
                compose.Parameter <String>("context", param => {
                    // Context comes from a data attribute on the lens element
                    param.Mutate <ContentList, ParadigmsContext>((p, context) => {
                        switch (param.Get(context))
                        {
                        case "Socket":
                            p.Add("LensSocket");
                            break;

                        case "Search":
                            p.Add("LensSearch");
                            break;
                        }
                    });
                });
                compose.Parameter <string>("contentTypes", param => {
                    param.Mutate <ContentListQuery, ContentListQuery>((q, context) => {
                        var types = param.Get(context).Split(',');
                        q.Query   = q.Query.ForType(types);
                    });
                });
            });

            /*
             * describe.Scope("Mechanics.Connector", compose => {
             *  compose.Chain("Content.Edit");
             *  compose.Chain("Ajax");
             *  compose.Factory<Model, object>((context) => {
             *      var model = new ConnectorDisplayContext(
             *  });
             *  compose.Factory<Model, SocketsPart>((context) => context.Get<Model,IContent>().As<SocketsPart>());
             *  compose.Factory<RootShape, dynamic>((context) => {
             *      var content = context.Get<Model,IContent>();
             *      var socket = content.As<SocketsPart>();
             *
             *      return Shape.Connector_Edit(
             *          ContentItem: c.SocketContext.Left.ContentItem,
             *          RightContentItem: c.Right.Content,
             *          ConnectorType: c.Descriptor.Name,
             *          RightContentType: c.Right.ContentType,
             *          LeftContentType: c.SocketContext.Left.ContentType);
             *  compose.Parameter<string>("socketName", leftId => {
             *
             *  });
             *  compose.Parameter<int>("newRightId", rightId => {
             *      compose.Factory<Model,IConnector>
             *      var socket = context.Get<Model,SocketsPart>();
             *
             *  });
             * });*/
        }
 public void Subscribe(RootBuilder describe)
 {
     describe.Scope("Content", mix => {
         mix.Factory <RootShape, dynamic>((context) => _origami.ContentShape(context.Get <Model, object>() as IContent, context.Get <ShapeMetadataFactory, ShapeMetadata>().DisplayType));
         mix.Factory <ModelBuilder, ModelShapeBuilder>((context) => _origami.ContentBuilder(context.Get <Model, object>() as IContent).WithDisplayType(context.Get <ShapeMetadataFactory, ShapeMetadata>().DisplayType));
         mix.Parameter <int>("contentId", (mix2) => {
             mix2.Factory <Model, object>((ctx) => _contentManager.Get(mix2.Get(ctx), VersionOptions.Published));
         });
     });
 }
Пример #4
0
        public Composition Compose()
        {
            var describe = new RootBuilder();

            _compositionEvents.Subscribe(describe);

            var context = new CompositionContext()
            {
                Builder = describe,
            };

            return(new Composition(context));
        }
Пример #5
0
        public void Ctor1_Deny_Unrestricted()
        {
            RootBuilder rb = new RootBuilder(new PageParser());

            try {
                rb.GetChildControlType(null, null);
            }
            catch (ArgumentNullException) {
                // mono and ms 1.x
            }
            catch (NullReferenceException) {
                // ms 2.0 - more likely parameters don't change this result
            }
            Assert.IsNotNull(rb.BuiltObjects, "BuiltObjects");
        }
Пример #6
0
        public Composition <T> Execute <T>(string identifier, System.Web.Mvc.IValueProvider valueProvider)
        {
            // TODO: Locally cache describe if we ever want >1 call to Execute
            var describe = new RootBuilder();

            _compositionEvents.Subscribe(describe);

            var context = new CompositionContext()
            {
                Identifier = identifier,
                Values     = valueProvider,
                Builder    = describe,
            };

            return(new Composition <T>(context));
        }
Пример #7
0
        public void Subscribe(RootBuilder describe)
        {
            describe.Scope("Search.Ajax", compose => {
                // Chain include content list
                compose.Chain("Ajax");
                compose.Chain("ContentList");

                // Hijack with our own bits
                compose.Parameter <string>("query", query => {
                    query.Mutate <ContentList, ContentListQuery>((q, context) => {
                        q.Query = q.Query.Where <TitlePartRecord>(t => t.Title.StartsWith(query.Get(context)));
                    });
                });
                compose.Mutate <ContentList, ParadigmsContext>((p, context) => {
                    p.Add("LensResult");
                });
                compose.Mutate <ContentList, ShapeMetadata>((metadata, context) => {
                });
            });
        }
Пример #8
0
        public void Subscribe(RootBuilder describe)
        {
            describe.Global(global => {
                global.Factory <RootShapeBuilder, dynamic>(context => {
                    var model = context.Get <Model, object>();
                    var root  = context.Get <RootShape, dynamic>();
                    if (model != null)
                    {
                        var builder = context.Get <ModelBuilder, ModelShapeBuilder>();
                        _origami.Build(builder, root);
                    }
                    return(root);
                });
                global.Factory <ActionResult>((context) => {
                    dynamic root    = context.Get <RootShapeBuilder, object>();
                    var controller  = context.Single <ControllerBase>();
                    dynamic display = context.Get <DisplayShape, object>();
                    return(context.Get <ActionResultBuilder, Func <ControllerBase, object, ActionResult> >()(controller, display));
                });

                global.Factory <ActionResultBuilder, Func <ControllerBase, object, ActionResult> >((context) => (c, o) => {
                    return(new ShapeResult(c, o));
                });

                global.Factory <ShapeMetadataFactory, ShapeMetadata>((context) => new ShapeMetadata()
                {
                    DisplayType = "Detail",
                });
                global.Factory <DisplayShape, dynamic>((context) => context.Get <RootShape, dynamic>());
                global.Factory <ModelBuilder, ModelShapeBuilder>((context) => _origami.Builder(context.Get <Model, object>()).WithDisplayType(context.Get <ShapeMetadataFactory, ShapeMetadata>().DisplayType).WithMode("Display"));
            });
            describe.Scope("Ajax", ajax => {
                ajax.Factory <ActionResultBuilder, Func <ControllerBase, object, ActionResult> >((context2) => (c, o) => {
                    return(new ShapePartialResult(c, o));
                });
            });
        }
        public void Subscribe(RootBuilder describe)
        {
            describe.Scope("Search.Fallback", compose => {
                // Chain include content list
                compose.Chain("ContentList");

                // We get the dud path from the url
                compose.Parameter <string>("path", path => {
                    path.Mutate <ContentList, ContentListQuery>((q, context) => {
                        string param  = path.Get(context);
                        string endBit = param;
                        var pos       = param.LastIndexOf('/');
                        if (pos >= 0)
                        {
                            endBit = param.Substring(pos + 1);
                        }
                        endBit = endBit.Replace('-', ' ');
                        // TODO: Any other replaces to fix url special chars etc.?

                        q.Query = q.Query.Where <TitlePartRecord>(t => t.Title.Contains(endBit));
                    });
                });
            });
        }
Пример #10
0
 public ShowsBuilder(RootBuilder root, IEnumerable <string> ids)
     : base(root, "shows", ids)
 {
 }
Пример #11
0
 public UserBuilder(RootBuilder root)
     : base(root, new object[] { "users", new CurrentUserIdPlaceholder() })
 {
 }
Пример #12
0
 public UserBuilder(RootBuilder root, string userId)
     : base(root, new[] { "users", userId })
 {
     SpotifyArgumentAssertUtils.ThrowIfNullOrEmpty(userId, nameof(userId));
 }
Пример #13
0
 public MeBuilder(RootBuilder root)
     : base(root, "me".Yield())
 {
 }
 public FollowedPlaylistBuilder(RootBuilder root)
     : base(root, "playlists".Yield())
 {
 }
Пример #15
0
 internal BuildResultNoCompileTemplateControl(Type baseType, TemplateParser parser)
 {
     this._baseType    = baseType;
     this._rootBuilder = parser.RootBuilder;
     this._rootBuilder.PrepareNoCompilePageSupport();
 }
Пример #16
0
 public TrackBuilder(RootBuilder root, string id)
     : base(root, "tracks", id)
 {
 }
Пример #17
0
 public ArtistBuilder(RootBuilder root, string id)
     : base(root, "artists", id)
 {
 }
Пример #18
0
 public ArtistsBuilder(RootBuilder root, IEnumerable <string> ids)
     : base(root, "artists", ids)
 {
 }
Пример #19
0
 public SearchBuilder(RootBuilder root)
     : base(root, "search".Yield())
 {
 }
Пример #20
0
 public EpisodesBuilder(RootBuilder root, IEnumerable <string> ids)
     : base(root, "episodes", ids)
 {
 }
Пример #21
0
 public TracksBuilder(RootBuilder root, IEnumerable <string> ids)
     : base(root, "tracks", ids)
 {
 }
Пример #22
0
 public ShowBuilder(RootBuilder root, string id)
     : base(root, "shows", id)
 {
 }
Пример #23
0
 public void Subscribe(RootBuilder describe)
 {
     describe.Scope("ContentList", mix => {
         mix.Factory <RootShape, dynamic>((context) => Shape.ContentList(ListItems: ((ContentListViewModel)context.Get <Model, object>()).Rendered));
         mix.Factory <ContentList, ShapeMetadata>((context) => new ShapeMetadata()
         {
             DisplayType = "Summary",
         });
         mix.Factory <ContentList, ParadigmsContext>((context) => new ParadigmsContext());
         mix.Factory <ContentList, ContentListQuery>((context) => new ContentListQuery()
         {
             Query = _contentManager.Query()
         });
         mix.Factory <ContentList, IEnumerable <IContent> >((context) => {
             var query = context.Get <ContentList, ContentListQuery>();
             var pager = context.Get <ContentList, PagerData>();
             if (pager != null)
             {
                 return(query.Query.Slice(pager.PageSize * (pager.Page - 1), pager.PageSize));
             }
             return(query.Query.List());
         });
         mix.Factory <ContentModelBuilder, Func <IContent, ModelShapeBuilder> >((context) => (c) => Builder(c, context));
         // TODO: Could support prefix here
         mix.Factory <ContentShapeBuilder, Func <IContent, object> >((context) => (s) => _origami.ContentShape(s, context.Get <ContentList, ShapeMetadata>().DisplayType));
         mix.Factory <Model, object>((context) => {
             var source  = context.Get <ContentList, IEnumerable <IContent> >();
             var builder = context.Get <ContentModelBuilder, Func <IContent, ModelShapeBuilder> >();
             return(new ContentListViewModel()
             {
                 Rendered = source.Select(s => {
                     var root = context.Get <ContentShapeBuilder, Func <IContent, object> >()(s);
                     _origami.Build(builder(s), root);
                     return root;
                 }).ToList()
             });
         });
         // TODO: Get page size from settings
         mix.Factory <ContentList, PagerData>((context) => {
             var pager = new PagerData()
             {
                 Page     = 1,
                 PageSize = 10
             };
             return(pager);
         });
         mix.Parameter <int>("PageSize", (pageSize) => {
             pageSize.Mutate <ContentList, PagerData>((pager, context) => { pager.PageSize = pageSize.Get(context); });
         });
         mix.Parameter <int>("Page", (page) => {
             page.Mutate <ContentList, PagerData>((pager, context) => { pager.Page = page.Get(context); });
         });
         mix.Parameter <string>("ContentType", (ct) => {
             ct.Mutate <ContentList, ContentListQuery>((q, context) => q.Query = q.Query.ForType(ct.Get(context)));
         });
         mix.Parameter <string>("ContentTypes", (ct) => {
             ct.Mutate <ContentList, ContentListQuery>((q, context) => q.Query = q.Query.ForType(ct.Get(context).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)));
         });
         // Calculate total pages at end
         mix.Mutate <ContentList, PagerData>((pager, context) => {
             var query        = context.Get <ContentList, ContentListQuery>();
             pager.TotalPages = query.Query.Count() / pager.PageSize; // TODO: Check calculation
         });
     });
 }
 public void Subscribe(RootBuilder describe)
 {
     describe.Scope("Content.Edit", compose => {
         compose.Chain("Content");
     });
 }
Пример #25
0
 public EpisodeBuilder(RootBuilder root, string id)
     : base(root, "episodes", id)
 {
 }
 public TracksAudioFeaturesBuilder(RootBuilder root, IEnumerable <string> ids)
     : base(root, "audio-features", ids)
 {
 }
 public BrowseRecommendationsBuilder(RootBuilder root)
     : base(root, "recommendations".Yield())
 {
 }
 public TrackAudioAnalysisBuilder(RootBuilder root, string id)
     : base(root, "audio-analysis", id)
 {
 }
Пример #29
0
        public void Ctor0_Deny_Unrestricted()
        {
            RootBuilder rb = new RootBuilder();

            Assert.IsNotNull(rb.BuiltObjects, "BuiltObjects");
        }
Пример #30
0
 public PlaylistBuilder(RootBuilder root, string id)
     : base(root, "playlists", id)
 {
 }