-
-
Save saulovenancio/7567676 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="disublayout.ascx.cs" Inherits="Website.sublayouts.disublayout" %> | |
<%@ Register TagPrefix="sc" Namespace="Sitecore.Web.UI.WebControls" Assembly="Sitecore.Kernel" %> | |
<asp:Label runat="server" ID="demo" Text="initial text" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using App.Abstract; | |
namespace Website.sublayouts | |
{ | |
public partial class disublayout : System.Web.UI.UserControl | |
{ | |
public IFooService SomeDependency { get; set; } | |
protected void Page_Load(object sender, EventArgs e) | |
{ | |
demo.Text = SomeDependency.GetData(); | |
} | |
} | |
} | |
namespace App.Abstract | |
{ | |
public interface IFooService | |
{ | |
string GetData(); | |
} | |
} | |
namespace App.Concrete | |
{ | |
public class FooService : IFooService | |
{ | |
public string GetData() | |
{ | |
return "Modified at " + DateTime.Now.ToLongTimeString(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@Application Language='C#' Inherits="Website.Global" CodeBehind="Global.asax.cs" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Autofac.Integration.Web; | |
using Sitecore.Web; | |
namespace Website | |
{ | |
public class Global : Application, IContainerProviderAccessor | |
{ | |
static IContainerProvider _containerProvider; | |
public IContainerProvider ContainerProvider | |
{ | |
get { return _containerProvider; } | |
} | |
public void Application_Start() | |
{ | |
_containerProvider = new ContainerProvider(ObjectBuilder.Register()); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Autofac; | |
using App.Abstract; | |
using App.Concrete; | |
namespace Website | |
{ | |
public static class ObjectBuilder | |
{ | |
public static IContainer Register() | |
{ | |
var builder = new ContainerBuilder(); | |
builder.Register<IFooService>(c => new FooService()); | |
return builder.Build(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment