Hi Maciej,
I implemented it in below fashion. Can you please let me know whether i implemented properly :
Register Windsor Container in
Global.asax :-
-----------------------------------------------------
private static WindsorContainer _container = null;
public static WindsorContainer RegisteredWinsdorContainer
{
get { return _container; }
}
protected void Application_Start(object sender, EventArgs e)
{
CreateAndRegisterMethods();
}
private static void CreateAndRegisterMethods()
{
_container = new WindsorContainer();
_container.AddComponent("UserManager", typeof (IUserManager),
typeof (UserManager));
_container.AddComponent("AddressManager", typeof (IAddressManager),
typeof (AddressManager));
}
Create a generic class to find registered interfaces
WindsorContainerDI.cs :-
public class WindsorContainerDI<T>
{
/// <summary>
///
/// </summary>
/// <param name="winsdorInterface"></param>
public static void GetWinsdorContainer(ref T winsdorInterface)
{
WindsorContainer container = Global.RegisteredWinsdorContainer;
if(container!=null)
{
winsdorInterface = container.Resolve<T>();
}
}
}
Access the methods of interface in this fashion
Default.aspx.cs
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
IUserManager userManagerContainer = null;
WindsorContainerDI<IUserManager>.GetWinsdorContainer(ref userManagerContainer);
if(userManagerContainer!=null)
{
UserObject[] userObj = userManagerContainer.GetUsers();
}
}