Example #1
0
        internal void OnStartup(StartupEventArgs e)
        {
            // FIXME: should we be sharing the
            // Dictionary<string,string> for each call to
            // the lifetime objects?  or should we be
            // creating a new one for each call?
            ApplicationServiceContext ctx = new ApplicationServiceContext(e.InitParams as Dictionary <string, string>);

            lifetime_objects.Close();              // it's now too late to add items to this collection

            for (int i = 0; i < ApplicationLifetimeObjects.Count; i++)
            {
                IApplicationService svc = ApplicationLifetimeObjects[i] as IApplicationService;
                if (svc != null)
                {
                    svc.StartService(ctx);
                }
            }

            for (int i = 0; i < ApplicationLifetimeObjects.Count; i++)
            {
                IApplicationLifetimeAware asvc = ApplicationLifetimeObjects[i] as IApplicationLifetimeAware;
                if (asvc != null)
                {
                    asvc.Starting();
                }
            }

            if (Startup != null)
            {
                Startup(this, e);
            }

            for (int i = 0; i < ApplicationLifetimeObjects.Count; i++)
            {
                IApplicationLifetimeAware asvc = ApplicationLifetimeObjects[i] as IApplicationLifetimeAware;
                if (asvc != null)
                {
                    asvc.Started();
                }
            }
        }