protected virtual void InjectDependencies() { HttpContext context = HttpContext.Current; if (context == null) { return; } IContainerAccessor accessor = context.ApplicationInstance as IContainerAccessor; if (accessor == null) { return; } IUnityContainer container = accessor.Container; if (container == null) { throw new InvalidOperationException( "Container on Global Application Class " + "is Null. Cannot perform BuildUp."); } container.BuildUp(this as T); }
public void Init(HttpApplication context) { application = context; containerAccessor = (IContainerAccessor)context; application.BeginRequest += ApplicationBeginRequest; application.EndRequest += ApplicationEndRequest; }
protected virtual void InjectDependencies() { var context = HttpContext.Current; if (context == null) { return; } IContainerAccessor accessor = context.ApplicationInstance as IContainerAccessor; if (accessor == null) { return; } IUnityContainer container = accessor.Container; if (container == null) { throw new InvalidOperationException("No Unity container found"); } container.BuildUp(this as T); }
public void Init(HttpApplication context) { application = context; containerAccessor = (IContainerAccessor) context; application.BeginRequest += ApplicationBeginRequest; application.EndRequest += ApplicationEndRequest; }
public void Init(HttpApplication context) { containerAccessor = (IContainerAccessor)context; context.BeginRequest += new EventHandler(OpenSession); context.EndRequest += new EventHandler(CloseSession); }
protected override void OnInit(EventArgs e) { // IContainerAccessor accessor = Context.ApplicationInstance as IContainerAccessor; if (accessor == null || accessor.Container == null) throw new InvalidOperationException("Castle not configured properly"); Session.Add("Container", accessor); }
protected override void OnInit(EventArgs e) { // IContainerAccessor accessor = Context.ApplicationInstance as IContainerAccessor; if (accessor == null || accessor.Container == null) throw new InvalidOperationException("Castle not configured properly"); svcAdddress = accessor.Container.Resolve<IAddressBookService>(); // get around dynamic control issues...set the controls HERE before the postback stuff // check below as to get into the viewstate in tact. // credit: http://codebetter.com/jefferypalermo/2004/11/25/key-to-ensuring-dynamic-asp-net-controls-save-viewstate-level-300/ LoadAddressUC(); }
/// <summary> /// ObtainContainer /// </summary> /// <returns></returns> public IWindsorContainer ObtainContainer() { IContainerAccessor containerAccessor = HttpContext.Current.ApplicationInstance as IContainerAccessor; if (containerAccessor == null) { throw new ApplicationException("你必须在HttpApplication中实现接口 IContainerAccessor 暴露容器的属性"); } IWindsorContainer container = containerAccessor.Container; if (container == null) { throw new ApplicationException("HttpApplication 得不到容器的实例"); } return(container); }
/// <summary> /// get an instance of windsor container from HTTP application /// </summary> /// <returns>return IWindsorContainer</returns> public static IWindsorContainer ObtainContainer() { IContainerAccessor containerAccessor = HttpContext.Current.ApplicationInstance as IContainerAccessor; if (containerAccessor == null) { throw new ApplicationException("HttpApplication doesn't implement the interface IContainerAccessor..."); } IWindsorContainer container = containerAccessor.Container; if (container == null) { throw new ApplicationException("Can not find windsor container from HttpApplication..."); } return(container); }
private static IWindsorContainer ObtainContainer() { IContainerAccessor containerAccessor = HttpContext.Current.ApplicationInstance as IContainerAccessor; if (containerAccessor == null) { throw new FacilityException("You must extend the HttpApplication in your web project " + "and implement the IContainerAccessor to properly expose your container instance"); } IWindsorContainer container = containerAccessor.Container; if (container == null) { throw new FacilityException("The container seems to be unavailable (null) in " + "your HttpApplication subclass"); } return(container); }
/// <summary> /// Obtain the Cuyahoga container. /// </summary> /// <returns></returns> public static CuyahogaContainer GetContainer() { IContainerAccessor containerAccessor = HttpContext.Current.ApplicationInstance as IContainerAccessor; if (containerAccessor == null) { throw new Exception("You must extend the HttpApplication in your web project " + "and implement the IContainerAccessor to properly expose your container instance"); } CuyahogaContainer container = containerAccessor.Container as CuyahogaContainer; if (container == null) { throw new Exception("The container seems to be unavailable in " + "your HttpApplication subclass"); } return(container); }
public UniversalFormatter(IContainerAccessor container) { _container = container.Container; }
protected override void OnInit(EventArgs e) { // IContainerAccessor accessor = Context.ApplicationInstance as IContainerAccessor; if (accessor == null || accessor.Container == null) throw new InvalidOperationException("Castle not configured properly"); svcAdddress = accessor.Container.Resolve<IAddressBookService>(); }
/// <summary> /// Register the container accessor. /// </summary> public static void Register(IWindsorContainer container) { ContainerAccessor accessor = new ContainerAccessor(container); Accessor = accessor; }
public WindsorControllerActivator(IContainerAccessor containerAccessor) { this.container = containerAccessor.Container; }