Auto wiring of Property does not work for me

Posted by Xabatcha on Stack Overflow See other posts from Stack Overflow or by Xabatcha
Published on 2010-04-01T12:00:36Z Indexed on 2010/04/01 12:03 UTC
Read the original article Hit count: 245

Hi All,
In my Asp.Net project I wanna use Property Auto-wiring, e.g. for my ILogger. Basically I placed Property into my base classes. One for Page, one for UserControl. Like below.

public class UserControlBase : UserControl
{
    public ILogger CLogger { get; set; }
    ....
}

However when calling in inherited control, logger is null. I checked the container and it'a definitely set. Below is setting which is called from Global.asax.

    public static void SetupForIoC()
    {
        Debug.WriteLine("SetupForIoC");
        ObjectFactory.Initialize(x =>
        {
            x.FillAllPropertiesOfType<ILogger>().TheDefaultIsConcreteType<EntLibLogger>().AsSingletons();
            x.FillAllPropertiesOfType<ISiteService>().TheDefaultIsConcreteType<SiteService>().AsSingletons();
        });

        Debug.WriteLine(ObjectFactory.WhatDoIHave());
    }

Thanks for any advice, tip? X.

© Stack Overflow or respective owner

Related posts about structuremap

Related posts about ASP.NET