/// <summary>
        /// Maps the Sitecore.Context.Item to a model
        /// </summary>
        /// <typeparam name="T">The type to return</typeparam>
        /// <param name="options">Options for how the model will be retrieved</param>
        /// <returns></returns>
        public virtual T GetContextItem <T>(GetKnownOptions options) where T : class
        {
            Assert.IsNotNull(options, "options must no be  null");

            options.Item = ContextItem;

            return(SitecoreService.GetItem <T>(options));
        }
        /// <summary>
        /// Maps the Sitecore.Context.Item to a model
        /// </summary>
        /// <typeparam name="T">The type to return</typeparam>
        /// <param name="options">Options for how the model will be retrieved</param>
        /// <returns></returns>
        public virtual object GetContextItem(GetKnownOptions options)
        {
            Assert.IsNotNull(options, "options must no be  null");

            options.Item = ContextItem;

            return(SitecoreService.GetItem(options));
        }
Beispiel #3
0
 /// <summary>
 /// Returns the Data Source Item as strongly typed
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 protected virtual T GetDataSource <T>(GetKnownOptions options = null) where T : class
 {
     if (!MvcContext.HasDataSource)
     {
         return(null);
     }
     return(MvcContext.GetDataSourceItem <T>(options ?? new GetKnownOptions()));
 }
        /// <summary>
        /// Maps the Sitecore.Context.Site.StartPath to a model
        /// </summary>
        /// <typeparam name="T">The type to return</typeparam>
        /// <param name="options">Options for how the model will be retrieved</param>
        /// <returns></returns>
        public virtual T GetHomeItem <T>(GetKnownOptions options) where T : class
        {
            Assert.IsNotNull(options, "options must no be  null");

            var item = SitecoreService.Database.GetItem(Sitecore.Context.Site.StartPath);

            options.Item = item;
            return(SitecoreService.GetItem <T>(options));
        }
        /// <summary>
        /// Maps the data source of the control to a model
        /// </summary>
        /// <typeparam name="T">The type to return</typeparam>
        /// <param name="options">Options for how the model will be mapped</param>
        /// <returns></returns>
        public T GetDataSourceItem <T>(Control control, GetKnownOptions options) where T : class
        {
            Assert.IsNotNull(options, "options must no be  null");

            var item = GetDataSourceItem(control);

            options.Item = item;
            return(SitecoreService.GetItem <T>(options));
        }
Beispiel #6
0
        /// <summary>
        /// Maps the RenderingContext.CurrentOrNull.Rendering.DataSource to a model
        /// </summary>
        /// <typeparam name="T">The type to return</typeparam>
        /// <param name="options">Options for how the model will be mapped</param>
        /// <returns></returns>
        public virtual T GetDataSourceItem <T>(GetKnownOptions options) where T : class
        {
            Assert.IsNotNull(options, "options must not be null");

            var item = DataSourceItem;

            options.Item = item;
            return(SitecoreService.GetItem <T>(options));
        }
Beispiel #7
0
        /// <summary>
        /// Maps the RenderingContext.CurrentOrNull.Rendering.Item to a model
        /// </summary>
        /// <typeparam name="T">The type to return</typeparam>
        /// <param name="options">Options for how the model will be retrieved</param>
        /// <returns></returns>
        public virtual T GetRenderingItem <T>(GetKnownOptions options) where T : class
        {
            Assert.IsNotNull(options, "options must not be null");

            var item = RenderingContext.CurrentOrNull.Rendering.Item;

            options.Item = item;
            return(SitecoreService.GetItem <T>(options));
        }
        /// <summary>
        /// Returns the DataSource item or the Context Item as strongly typed
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T GetLayoutItem <T>(GetKnownOptions options = null) where T : class
        {
            var dataSource = WebContext.GetDataSourceItem(this);

            if (dataSource != null)
            {
                return(GetDataSource <T>(options));
            }
            else
            {
                return(GetContext <T>(options));
            }
        }
Beispiel #9
0
 /// <summary>
 /// Returns the Context Item as strongly typed
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 protected virtual T GetContext <T>(GetKnownOptions options = null) where T : class
 {
     return(MvcContext.GetContextItem <T>(options ?? new GetKnownOptions()));
 }
Beispiel #10
0
 /// <summary>
 /// Returns the Layout Item as strongly typed
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 protected virtual T GetLayout <T>(GetKnownOptions options = null) where T : class
 {
     return(MvcContext.HasDataSource
         ? GetDataSource <T>(options ?? new GetKnownOptions())
         : GetContext <T>(options ?? new GetKnownOptions()));
 }
Beispiel #11
0
 public new T GetLayout <T>(GetKnownOptions options = null) where T : class
 {
     return(base.GetLayout <T>(options));
 }
Beispiel #12
0
 public new T GetDataSource <T>(GetKnownOptions options = null) where T : class
 {
     return(base.GetDataSource <T>(options));
 }
Beispiel #13
0
 /// <summary>
 /// Returns the Context Item as strongly typed
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public T GetContext <T>(GetKnownOptions options = null) where T : class
 {
     return(MvcContext.GetContextItem <T>(options ?? new GetKnownOptions()));
 }
 public T GetPageContextItem <T>(GetKnownOptions options) where T : class
 {
     return(_mvcContext.GetPageContextItem <T>(options));
 }
Beispiel #15
0
 public T GetHomeItem <T>(GetKnownOptions options) where T : class
 {
     throw new NotImplementedException();
 }
        /// <summary>
        /// Returns the Data Source Item as strongly typed
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T GetDataSource <T>(GetKnownOptions options = null) where T : class
        {
            options = options == null ? new GetKnownOptions() : options;

            return(WebContext.GetDataSourceItem <T>(this, options));
        }
        /// <summary>
        /// Returns the Context Item as strongly typed
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T GetContext <T>(GetKnownOptions options = null) where T : class
        {
            options = options == null ? new GetKnownOptions() : options;

            return(WebContext.GetContextItem <T>(options));
        }
 protected AbstractGetKnownItemBuilder(GetKnownOptions options)
     : base(options)
 {
     _options = options;
 }
Beispiel #19
0
 public T GetContext <T>(GetKnownOptions options = null) where T : class
 {
     return(base.GetContext <T>(options));
 }
 public T GetHomeItem<T>(GetKnownOptions options)
     where T : class
 {
     return _requestContext.GetHomeItem<T>(options);
 }
Beispiel #21
0
 public object GetContextItem(GetKnownOptions options)
 {
     throw new NotImplementedException();
 }
Beispiel #22
0
 public object GetCurrentItem(GetKnownOptions options)
 {
     return(_requestContext.GetContextItem(options));
 }
 public T GetDataSourceItem <T>(GetKnownOptions options) where T : class
 {
     return(_mvcContext.GetDataSourceItem <T>(options));
 }
Beispiel #24
0
 public T GetRootItem <T>(GetKnownOptions options) where T : class
 {
     return(_requestContext.GetRootItem <T>(options));
 }
 public T GetRenderingItem <T>(GetKnownOptions options) where T : class
 {
     return(_mvcContext.GetRenderingItem <T>(options));
 }
Beispiel #26
0
 protected virtual TModel GetModel(GetKnownOptions options = null)
 {
     return(GetLayout <TModel>(options ?? new GetKnownOptions()));
 }