public StubController(
     ISitecoreContext sitecoreContext,
     IGlassHtml glassHtml,
     IRenderingContext renderingContextWrapper,
     HttpContextBase httpContext) : base(sitecoreContext, glassHtml, renderingContextWrapper, httpContext)
 {
 }
Пример #2
0
        public static string BrowserTitle(this IGlassHtml glassHtml)
        {
            IRequestContext requestContext = new RequestContext(glassHtml.SitecoreService);
            IMetaRoot       rootItem       = requestContext.GetRootItem <IMetaRoot>();

            return(rootItem?.BrowserTitle);
        }
Пример #3
0
        /// <summary>
        /// Makes a field editable via the Page Editor. Use the Model property as the target item, e.g. model =&gt; model.Title where Title is field name.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="glassHtml">The glass HTML.</param>
        /// <param name="model">The model.</param>
        /// <param name="field">The field.</param>
        /// <param name="standardOutput">The standard output.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns>System.String.</returns>
        /// <exception cref="System.NullReferenceException">
        /// No field set
        /// or
        /// No standardoutput set
        /// or
        /// No model set
        /// </exception>
        public static string Editable <T>(IGlassHtml glassHtml, T model, Expression <Func <T, object> > field, Expression <Func <T, string> > standardOutput, AbstractParameters parameters)
        {
            if (field == null)
            {
                throw new NullReferenceException("No field set");
            }

            if (standardOutput == null)
            {
                throw new NullReferenceException("No standardoutput set");
            }

            if (model == null)
            {
                throw new NullReferenceException("No model set");
            }

            try
            {
                var result = glassHtml.Editable <T>(model, field, standardOutput, parameters);
                return(result);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GlassHtmlFacade" /> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="writer">The writer.</param>
        public GlassHtmlFacade(ISitecoreContext context, HtmlTextWriter writer, ITemplateBase templateBase)

        {
            _writer      = writer;
            _glassHtml   = new GlassHtml(context);
            TemplateBase = templateBase;
        }
Пример #5
0
        protected AbstractGlassPage(ISitecoreContextFactory sitecoreContextFactory, ISitecoreContext context)
        {
            if (context == null)
            {
                context = sitecoreContextFactory.GetSitecoreContext();
            }

            _sitecoreContext = context;
            _glassHtml       = context.GlassHtml;
        }
Пример #6
0
 public SampleController(
     ISettingsWrapper settings,
     RenderingContextWrapperBase renderingContext,
     ISitecoreContext sitecoreContext,
     IGlassHtml glassHtml)
     : base(sitecoreContext, glassHtml)
 {
     this.settings         = settings;
     this.renderingContext = renderingContext;
 }
Пример #7
0
        /// <summary>
        /// Assemblies the version for front end.
        /// </summary>
        /// <param name="glassHtml"></param>
        /// <param name="assemblyName">Name of the assembly.</param>
        /// <returns>System.String object.</returns>
        public static string AssemblyVersion(this IGlassHtml glassHtml, string assemblyName)
        {
            try {
                AssemblyName assembly = AssemblyName.GetAssemblyName(AppDomain.CurrentDomain.BaseDirectory + "bin\\" + assemblyName + ".dll");

                return(assembly == null ? "1.0.0.1" : assembly.Version.ToString());
            } catch (Exception e) {
                LogRepository.Error($"HelperExtensions/AssemblyVersionForFrontEnd: {e.Message}", e);
            }

            return("1.0.0.1");
        }
        protected override void OnInit(EventArgs e)
        {
            //we have to activate it here because of
            //some weird lifecycle stuff in the page editor
            if (_sitecoreContext == null)
            {
                _sitecoreContext = new SitecoreContext();
                _glassHtml       = new GlassHtml(_sitecoreContext);
            }

            base.OnInit(e);
        }
Пример #9
0
 public GlassController()
 {
     try
     {
         SitecoreContext = new SitecoreContext(Sitecore.Context.Database);
         GlassHtml       = new GlassHtml(SitecoreContext);
     }
     catch (Exception ex)
     {
         Sitecore.Diagnostics.Log.Error("Failed to create SitecoreContext", ex, this);
     }
 }
Пример #10
0
 public GlassController()
 {
     try
     {
         SitecoreContext = Sc.SitecoreContext.GetFromHttpContext();
         GlassHtml       = new GlassHtml(SitecoreContext);
     }
     catch (Exception ex)
     {
         Sitecore.Diagnostics.Log.Error("Failed to create SitecoreContext", ex, this);
     }
 }
Пример #11
0
 public GlassController()
 {
     try
     {
         SitecoreContext = new SitecoreContext(Sitecore.Mvc.Presentation.RenderingContext.Current.ContextItem.Database);
         GlassHtml       = new GlassHtml(SitecoreContext);
     }
     catch (Exception ex)
     {
         Sitecore.Diagnostics.Log.Error("Failed to create SitecoreContext", ex, this);
     }
 }
 public RenderingContextService(IGlassHtml glassHtml, ISitecoreContext context)
 {
     if (glassHtml == null)
     {
         throw new ArgumentNullException(nameof(glassHtml));
     }
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     _glassHtml = glassHtml;
     _context   = context;
 }
Пример #13
0
        [Test] // Most DI frameworks use property injection since the construction is done via the webforms framework
        public void Can_set_values_using_property_injection_successfully()
        {
            // Arrange
            ISitecoreContext  sitecoreContext  = Substitute.For <ISitecoreContext>();
            IRenderingContext renderingContext = Substitute.For <IRenderingContext>();
            IGlassHtml        glassHtml        = Substitute.For <IGlassHtml>();
            var glassUserControl = new GlassUserControl <StubClass>();

            glassUserControl.SitecoreContext  = sitecoreContext;
            glassUserControl.RenderingContext = renderingContext;
            glassUserControl.GlassHtml        = glassHtml;

            // Act - no actions to perform

            // Assert
            glassUserControl.SitecoreContext.Should().Be(sitecoreContext);
            glassUserControl.RenderingContext.Should().Be(renderingContext);
            glassUserControl.GlassHtml.Should().Be(glassHtml);
        }
Пример #14
0
        /// <summary>
        /// Makes a field editable via the Page Editor. Use the Model property as the target item, e.g. model =&gt; model.Title where Title is field name.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="glassHtml">The glass HTML.</param>
        /// <param name="model">The model.</param>
        /// <param name="field">The field.</param>
        /// <returns>System.String.</returns>
        /// <exception cref="System.NullReferenceException">
        /// No field set
        /// or
        /// No model set
        /// </exception>
        public static string Editable <T>(IGlassHtml glassHtml, T model, Expression <Func <T, object> > field)
        {
            if (field == null)
            {
                throw new NullReferenceException("No field set");
            }

            if (model == null)
            {
                throw new NullReferenceException("No model set");
            }

            try
            {
                var result = glassHtml.Editable <T>(model, field);
                return(result);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Пример #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AbstractRazorControl{T}"/> class.
 /// </summary>
 public AbstractRazorControl()
 {
     ViewData    = new ViewDataDictionary();
     ViewManager = new ViewManager();
     GlassHtml   = new GlassHtml(new SitecoreContext());
 }
Пример #16
0
 public ControllerSCContext(IGlassHtml glassHtml)
 {
     _glassHtml = glassHtml;
 }
Пример #17
0
 protected GlassHtmlFacade(ISitecoreContext context)
 {
     _glassHtml = context.GlassHtml;
 }
Пример #18
0
 protected GlassController(ISitecoreContext sitecoreContext, IGlassHtml glassHtml)
 {
     SitecoreContext = sitecoreContext;
     GlassHtml       = glassHtml;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AbstractGlassUserControl"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 public AbstractGlassUserControl(ISitecoreContext context, IGlassHtml glassHtml)
 {
     _glassHtml       = glassHtml;
     _sitecoreContext = context;
 }
Пример #20
0
 public GlassUserControl(ISitecoreContext context, IGlassHtml glassHtml, IRenderingContext renderingContext)
     : base(context, glassHtml, renderingContext)
 {
 }
Пример #21
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="GlassWebControl{T}" /> class.
 /// </summary>
 /// <param name="context">The context.</param>
 public GlassWebControl(ISitecoreContext context, IGlassHtml glassHtml)
     : base(context, glassHtml)
 {
 }
 public HeaderViewModelFactory(IGlassHtml glassHtml)
 {
     _glassHtml = glassHtml;
 }
 /// <summary>
 /// Used for unit testing
 /// </summary>
 /// <param name="context"></param>
 /// <param name="glassHtml"></param>
 internal FeaturedNewsController(ISitecoreContext context, IGlassHtml glassHtml)
     : base(context, glassHtml)
 {
 }
Пример #24
0
 public GlassHtmlMvc(IGlassHtml glassHtml, TextWriter output, TK model)
 {
     Output    = output;
     Model     = model;
     GlassHtml = glassHtml;
 }
Пример #25
0
 public MvcContext(ISitecoreService sitecoreService, IGlassHtml glassHtml) : base(sitecoreService)
 {
     GlassHtml = glassHtml;
 }
Пример #26
0
 public PropertyBuilder(IGlassHtml glassHtml)
 {
     this.GlassHtml = glassHtml;
 }
 public StubFeaturedNewsController(ISitecoreContext sitecoreContext, IGlassHtml glassHtml )
     : base(sitecoreContext, glassHtml)
 {
 }
Пример #28
0
 protected MvpAbstractGlassUserControl(ISitecoreContext context, IGlassHtml glassHtml) : this(context, glassHtml, null)
 {
 }
Пример #29
0
 protected MvpAbstractGlassUserControl(ISitecoreContext context, IGlassHtml glassHtml, IRenderingContext renderingContext) : this(Glass.Mapper.Sc.IoC.SitecoreContextFactory.Default)
 {
     this.renderingContext = renderingContext;
     this.glassHtml        = glassHtml;
     this.sitecoreContext  = context;
 }
Пример #30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GlassHtmlFacade" /> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="writer">The writer.</param>
        public GlassHtmlFacade(ISitecoreContext context, HtmlTextWriter writer)

        {
            _writer    = writer;
            _glassHtml = new GlassHtml(context);
        }
Пример #31
0
 public MediaController(IContextWrapper contextWrapper, IMediaContentService mediaContentService, IGlassHtml glassHtml)
 {
     _contextWrapper      = contextWrapper;
     _mediaContentService = mediaContentService;
     _glassHtml           = glassHtml;
 }
Пример #32
0
 public RecommendedMediator(IGlassHtml glassHtml, IRecommendedService recommendedService, IMediatorService mediatorService)
 {
     _glassHtml          = glassHtml;
     _recommendedService = recommendedService;
     _mediatorService    = mediatorService;
 }
 public GlassParametersModelBinder(IGlassHtml glassHtml)
 {
     Assert.ArgumentNotNull(glassHtml, "glassHtml");
     _glassHtml = glassHtml;
 }