Ejemplo n.º 1
0
        /// <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));
        }
Ejemplo n.º 2
0
        /// <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));
        }
Ejemplo n.º 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()));
 }
Ejemplo n.º 4
0
        /// <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));
        }
Ejemplo n.º 5
0
        /// <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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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()));
 }
Ejemplo n.º 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()));
 }
Ejemplo n.º 11
0
 public new T GetLayout <T>(GetKnownOptions options = null) where T : class
 {
     return(base.GetLayout <T>(options));
 }
Ejemplo n.º 12
0
 public new T GetDataSource <T>(GetKnownOptions options = null) where T : class
 {
     return(base.GetDataSource <T>(options));
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 18
0
 protected AbstractGetKnownItemBuilder(GetKnownOptions options)
     : base(options)
 {
     _options = options;
 }
Ejemplo n.º 19
0
 public T GetContext <T>(GetKnownOptions options = null) where T : class
 {
     return(base.GetContext <T>(options));
 }
Ejemplo n.º 20
0
 public T GetHomeItem<T>(GetKnownOptions options)
     where T : class
 {
     return _requestContext.GetHomeItem<T>(options);
 }
Ejemplo n.º 21
0
 public object GetContextItem(GetKnownOptions options)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 26
0
 protected virtual TModel GetModel(GetKnownOptions options = null)
 {
     return(GetLayout <TModel>(options ?? new GetKnownOptions()));
 }