I have a base class BLLContext:
public sealed class BLLContext : IDisposable
{
private LayersSharedObjects _layersSharedObjects = null;
internal HttpContext httpContext = HttpContext.Current;
Authorization _authorization = null;
public Authorization Authorization
{
get
{
if (_authorization == null)
{
_authorization = new Authorization(this);
}
return _authorization;
}
}
public BLLContext()
{
}
}
All of my BLL classes has a constructor that should get object of the above class. for example:
public class Authorization : BLLBase
{
public Authorization(BLLContext bLLContext) : base(bLLContext)
{
}
}
Everything was ok until i had to get some information from the Authorization class from an instance of BLLContext. So i added the this part to the BLLContext class:
public Authorization Authorization
{
get
{
if (_authorization == null)
{
_authorization = new Authorization(this);
}
return _authorization;
}
}
but because Authorization class has to get BLLContext and i am inside BLLContext, i passed "this" to the Authorization constructor.
Can someone explain if it will case to circular reference?, it seems that its not while checking with .Net Profiler.
What should i do to avoid this but still pass "this" and keep the current structure? The system is working well without any significant problems.