Пример #1
1
        // make sure we use singleton and lazy load
        public SettingsLogic(ISitecoreContext currentContext)
        {
            _currentContext = currentContext;

            _siteSettings = new Lazy<IScripts>(() =>
            {
                return _currentContext.GetItem<IScripts>(Ids.Content.SiteSettings.Id); //this is a different way to do it compared to the social settings
            });
        }
 public CommentsController(
     ISitecoreContext context,
     ISitecoreService master)
 {
     _context = context;
     _master = master;
 }
Пример #3
0
        public SitecoreSiteLogic(ISitecoreContext currentContext)
        {
            _siteContext = Sitecore.Context.Site;
            _currentContext = currentContext;

            LoadSettings();
        }
        public RateBaconController(
            ISitecoreContext context,
            ISitecoreService service

            ):base(context, new GlassHtml(context))
        {
            _service = service;
        }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AbstractGlassPage"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 public AbstractGlassPage(ISitecoreContext context)
 {
     _glassHtml       = new GlassHtml(context);
     _sitecoreContext = context;
 }
Пример #6
0
 public NavigationController(INavigationRepository navigationRepository, ISitecoreContext SitecoreContext)
 {
     this._navigationRepository = navigationRepository;
 }
 public RouteValidator(ISitecoreContext sitecoreContext)
 {
     _sitecoreContext = sitecoreContext;
 }
 /// <summary>
 /// Used for unit testing
 /// </summary>
 /// <param name="context"></param>
 /// <param name="glassHtml"></param>
 internal FeaturedNewsController(ISitecoreContext context, IGlassHtml glassHtml)
     : base(context, glassHtml)
 {
 }
 private IGlassHtml GetGlassHtml(ISitecoreContext sitecoreContext)
 {
     return sitecoreContext.GlassHtml;
 }
Пример #10
0
 public ScriptsLogic(ISitecoreContext currentContext, ISettingsLogic settings)
 {
     _currentContext = currentContext;
     _settings = settings;
 }
 public VariantDeletedTask(ISitecoreContext context)
 {
     _context = context;
 }
 public ProductColorsContextExtension(
     ISitecoreContext sitecoreContext,
     IConfigurationResolver configurationResolver) : base(configurationResolver)
 {
     this.sitecoreContext = sitecoreContext;
 }
 public StubFeaturedNewsController(ISitecoreContext sitecoreContext, IGlassHtml glassHtml )
     : base(sitecoreContext, glassHtml)
 {
 }
 public SearchController(ISitecoreContext context)
 {
     _context = context;
 }
 public BlurbController(ISitecoreContext sitecoreContext)
 {
     _sitecoreContext = sitecoreContext;
 }
 public CacheRetriever(ISiteContextRetriever siteContextRetriever, ISitecoreContext sitecoreContext, IConfigurationSettings configurationSettings)
 {
     _siteContextRetriever = siteContextRetriever;
     _sitecoreContext = sitecoreContext;
     _configurationSettings = configurationSettings;
 }
Пример #17
0
 public MetadataLogic(ISitecoreContext currentContext, ISitecoreSiteLogic sitecoreSiteLogic)
 {
     _currentContext = currentContext;
     _sitecoreSiteLogic = sitecoreSiteLogic;
 }
Пример #18
0
 public static IEnumerable <T> GetChildrenOf <T>(this ISitecoreContext sitecoreContext, [NotNull] Item item) where T : class
 {
     return(item.Children.Select(x => sitecoreContext.GetItem <T>(x.ID.ToGuid())));
 }
Пример #19
0
 public AbstractGlassWebControl(ISitecoreContext context, IGlassHtml glassHtml, IRenderingContext renderingContext)
 {
     RenderingContext = renderingContext ?? new RenderingContextUserControlWrapper(this);
     _glassHtml       = glassHtml;
     _sitecoreContext = context;
 }
Пример #20
0
 public SitecoreLanguageService(ISitecoreContext context)
 {
     _context = context;
 }
 public ArticleSearchRepository(ISitecoreContext sitecoreContext) : base(sitecoreContext)
 {
 }
Пример #22
0
 public GooglePlacesItemProcessor(
     ISitecoreContext sitecoreContext,
     string locationPathOverride = null) : base(sitecoreContext, locationPathOverride)
 {
 }
 public GlassRepository(ISitecoreContext sitecoreContext)
 {
     this.sitecoreContext = sitecoreContext;
 }
 public GenericContentController(IGenericContentRepository genericContentRepository, ISitecoreContext sitecoreContext)
 {
     m_genericContentRepository = genericContentRepository;
     m_sitecoreContext = sitecoreContext;
 }
Пример #25
0
 public SecurityFieldValueBuilder(ISitecoreContext sitecoreContext, ISecurityService securityService, IUserService userService)
 {
     _sitecoreContext = sitecoreContext;
     _securityService = securityService;
     _userService     = userService;
 }
 public override BasePageModel GetModel()
 {
     _context = new SitecoreContext();
     return(_context.GetCurrentItem <BasePageModel>());
 }
 public ProductDeletedTask(ISitecoreContext context)
 {
     _context = context;
 }
 public StubController(ISitecoreContext sitecoreContext) : base(sitecoreContext, new RenderingContextMvcWrapper())
 {
 }
 public StorefrontContext(ISitecoreContext sitecoreContext)
 {
     this.sitecoreContext = sitecoreContext;
 }
 public StubController(
     ISitecoreContext sitecoreContext,
     IRenderingContext renderingContextWrapper) : base(sitecoreContext, renderingContextWrapper)
 {
 }
Пример #31
0
 public IgnitionControllerContext GetInstance(ControllerContext controllerContext, ISitecoreContext context)
 {
     return(new IgnitionControllerContext(controllerContext, context));
 }
Пример #32
0
 public SitecoreImageNodeConverter(IImageService imageService, ISitecoreContext sitecoreContext)
 {
     _imageService    = imageService;
     _sitecoreContext = sitecoreContext;
 }
Пример #33
0
        public override void Process(GetModelArgs args)
        {
            if (!IsValidForProcessing(args))
            {
                return;
            }

            string path = GetViewPath(args);

            if (string.IsNullOrWhiteSpace(path))
            {
                return;
            }

            string cacheKey  = modelCacheManager.GetKey(path);
            Type   modelType = modelCacheManager.Get(cacheKey);

            if (modelType == typeof(NullModel))
            {
                // The model has been attempted before and is not useful
                return;
            }

            // The model type hasn't been found before or has been cleared.
            if (modelType == null)
            {
                modelType = GetModel(args, path);

                modelCacheManager.Add(cacheKey, modelType);

                if (modelType == typeof(NullModel))
                {
                    // This is not the type we are looking for
                    return;
                }
            }

            ISitecoreContext scContext = SitecoreContext.GetFromHttpContext(ContextName);

            Rendering renderingItem = args.Rendering;

            object model = null;

            if (renderingItem.DataSource.HasValue())
            {
                var item = scContext.Database.GetItem(renderingItem.DataSource);
                model = scContext.CreateType(modelType, item, false, false, null);
            }
            else if (renderingItem.RenderingItem.DataSource.HasValue())
            {
                var item = scContext.Database.GetItem(renderingItem.RenderingItem.DataSource);
                model = scContext.CreateType(modelType, item, false, false, null);
            }
            else if (renderingItem.Item != null)
            {
                /**
                 * Issues #82:
                 * Check Item before defaulting to the current item.
                 */
                model = scContext.CreateType(modelType, renderingItem.Item, false, false, null);
            }
            else
            {
                model = scContext.GetCurrentItem(modelType);
            }

            args.Result = model;
        }
Пример #34
0
 public SubnavigationViewModel(ISitecoreContext sitecoreContext)
 {
     SitecoreContext = sitecoreContext;
 }
Пример #35
0
 public MvpGlassUserControl(ISitecoreContext context, IGlassHtml glassHtml, IRenderingContext renderingContext) : base(context, glassHtml, renderingContext)
 {
 }
Пример #36
0
 public EnquiryRepository(ISitecoreContext sitecoreContext)
 {
     this.sitecoreContext = sitecoreContext;
 }
Пример #37
0
        public BreadcrumbRepository(ISitecoreContext sitecoreContext)
        {
            Assert.ArgumentNotNull(sitecoreContext, nameof(sitecoreContext));

            this.sitecoreContext = sitecoreContext;
        }
 public DefaultLayoutPresenter(IDefaultLayoutView view, ISitecoreContext sitecoreContext) : base(view)
 {
     this.View.Load      += Load;
     this.sitecoreContext = sitecoreContext;
 }
Пример #39
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="AbstractGlassUserControl" /> class.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="glassHtml"></param>
 public AbstractGlassWebControl(ISitecoreContext context, IGlassHtml glassHtml)
     : this(context, glassHtml, null)
 {
 }
 public CommentsSearchController(ISitecoreContext context)
 {
     _context = context;
 }
Пример #41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GlassUserControl{T}"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 public GlassUserControl(ISitecoreContext context) : base(context)
 {
 }
Пример #42
0
 public ArticleController(IArticleSearch searcher, ISitecoreContext context)
 {
     ArticleSearcher = searcher;
     SitecoreContext = context;
 }
Пример #43
0
 public ContentRepository(ISitecoreContextFactory sitecoreContextFactory)
 {
     _sitecoreContextFactory = sitecoreContextFactory;
     _sitecoreContext = sitecoreContextFactory.GetSitecoreContext();
 }
Пример #44
0
 public CanonicalLink(ISitecoreContext currentContext, ISitecoreSiteLogic sitecoreSiteLogic)
 {
     _currentContext = currentContext;
     _sitecoreSiteLogic = sitecoreSiteLogic;
 }
Пример #45
0
 private IGlassHtml GetGlassHtml(ISitecoreContext sitecoreContext)
 {
     return new GlassHtml(sitecoreContext);
 }
Пример #46
0
        public override void Process(GetModelArgs args)
        {
            var key   = "GetModelFromView";
            var watch = Stopwatch.StartNew();

            try
            {
                if (!IsValidForProcessing(args))
                {
                    return;
                }

                string path = GetViewPath(args);

                if (string.IsNullOrWhiteSpace(path))
                {
                    return;
                }

                string cacheKey  = modelCacheManager.GetKey(path);
                Type   modelType = modelCacheManager.Get(cacheKey);

                if (modelType == typeof(NullModel) || modelType == typeof(RenderingModel))
                {
                    // The model has been attempted before and is not useful
                    return;
                }

                // The model type hasn't been found before or has been cleared.
                if (modelType == null)
                {
                    modelType = GetModel(args, path);

                    modelCacheManager.Add(cacheKey, modelType);

                    if (modelType == typeof(NullModel) || modelType == typeof(RenderingModel))
                    {
                        // This is not the type we are looking for
                        return;
                    }
                }

                ISitecoreContext scContext = SitecoreContextFactory.GetSitecoreContext();

                Rendering renderingItem = args.Rendering;

                object model = null;

                if (renderingItem.DataSource.HasValue())
                {
                    var item = scContext.Database.GetItem(renderingItem.DataSource);
                    model = scContext.CreateType(modelType, item, false, false, null);
                }
                else if (renderingItem.RenderingItem.DataSource.HasValue())
                {
                    var item = scContext.Database.GetItem(renderingItem.RenderingItem.DataSource);
                    model = scContext.CreateType(modelType, item, false, false, null);
                }
                else if (renderingItem.Item != null)
                {
                    /**
                     * Issues #82:
                     * Check Item before defaulting to the current item.
                     */
                    model = scContext.CreateType(modelType, renderingItem.Item, false, false, null);
                }
                else
                {
                    model = scContext.GetCurrentItem(modelType);
                }

                args.Result = model;
            }
            finally
            {
                Sitecore.Diagnostics.Log.Debug("GetModelFromView {0} {1}".Formatted(watch.ElapsedMilliseconds, args.Rendering.RenderingItem.ID), this);
            }
        }
 public GlassExampleController(ISitecoreContext context)
 {
     _context = context;
 }
 public CategorySavedTask(ISitecoreContext context)
 {
     _context = context;
 }
Пример #49
0
 public IGlassHtml GetGlassHtml(ISitecoreContext sitecoreContext)
 {
     return new GlassHtml(sitecoreContext);
 }
Пример #50
0
 public MenuLogic(ISitecoreContext context)
 {
     _context = context;
 }
Пример #51
0
        /// <summary>
        /// Gets the object.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="db">The db.</param>
        /// <returns></returns>
        /// <exception cref="Glass.Mapper.MapperException">Failed to find context {0}.Formatted(ContextName)</exception>
        public object GetObject(string model, Database db, Rendering renderingItem)
        {
            if (model.IsNullOrEmpty())
            {
                return(null);
            }

            //must be a path to a Model item
            if (model.StartsWith("/sitecore"))
            {
                var target = db.GetItem(model);
                if (target == null)
                {
                    return(null);
                }

                string newModel = target[ModelTypeField];
                return(GetObject(newModel, db, renderingItem));
            }
            //if guid must be that to Model item
            Guid targetId;

            if (Guid.TryParse(model, out targetId))
            {
                var target = db.GetItem(new ID(targetId));
                if (target == null)
                {
                    return(null);
                }

                string newModel = target[ModelTypeField];
                return(GetObject(newModel, db, renderingItem));
            }


            var type = Type.GetType(model, false);

            if (type == null || IRenderingModelType.IsAssignableFrom(type))
            {
                return(null);
            }

            ISitecoreContext scContext = SitecoreContext.GetFromHttpContext(ContextName);


            //this is really aggressive
            if (!scContext.GlassContext.TypeConfigurations.ContainsKey(type))
            {
                //if the config is null then it is probably an ondemand mapping so we have to load the ondemand part

                IConfigurationLoader loader =
                    new OnDemandLoader <SitecoreTypeConfiguration>(type);
                scContext.GlassContext.Load(loader);
            }

            if (renderingItem.DataSource.IsNotNullOrEmpty())
            {
                var item = scContext.Database.GetItem(renderingItem.DataSource);
                return(scContext.CreateType(type, item, false, false, null));
            }

            /**
             * Issues #82:
             * Check Item before defaulting to the current item.
             */
            if (renderingItem.Item != null)
            {
                return(scContext.CreateType(type, renderingItem.Item, false, false, null));
            }

            return(scContext.GetCurrentItem(type));
        }
 public GlassItemModelBinder(ISitecoreContext sitecoreContext)
 {
     Assert.ArgumentNotNull(sitecoreContext, "sitecoreContext");
     _sitecoreContext = sitecoreContext;
 }