Breaking Change in InstanceActivator?

Nov 21, 2010 at 8:31 PM

I've been using the SimpleContainer approach for my WP7 app. I just got latest and had an issue with my PhoneContainer. It appears that InstanceActivator now takes two arguments instead of one. The new parameter is the first and is an instance of PhoneBootstrapper.

Code that worked before today's Pull/Update:

    public class PhoneContainer : SimpleContainer
    {
        public PhoneContainer()
        {
            Activator = new InstanceActivator(type => GetInstance(type, null));
        }

        public InstanceActivator Activator { getprivate set; }

        protected override object ActivateInstance(Type type, object[] args)
        {
            return Activator.ActivateInstance(base.ActivateInstance(type, args));
        }
    }

My fix:
        public PhoneContainer(WP7Bootstrapper bootStrapper)
        {
            Activator = new InstanceActivator(bootStrapper, type => GetInstance(type, null));
        }

        public InstanceActivator Activator { getprivate set; }

        protected override object ActivateInstance(Type type, object[] args)
        {
            return Activator.ActivateInstance(base.ActivateInstance(type, args));
        }
    }
And then in the first line of the WP7Bootstrapper.cs Configure method, I do this:
container = new PhoneContainer(this);

It builds and runs. Comments?
Coordinator
Nov 22, 2010 at 2:42 AM

Looks good.

Nov 24, 2010 at 5:19 PM
Edited Nov 24, 2010 at 5:20 PM

Any chance you could update the WP7 article in the Documentation to reflect this change (for the newcomers that I keep pointing here :))? I'd do it myself, but you know...

I should probably update my template on the Gallery as well, as it continues to get some traffic.

Coordinator
Nov 25, 2010 at 1:20 AM

I'll create a ticket to remind me.