Ejemplo n.º 1
0
        internal static Application Start(StartApplicationRequest request)
        {
            var filter = new AttributeExtensionFilter(new ApplicationAttribute(request.GetType()));
            var app    = new ApplicationExtensionPoint().CreateExtension(filter) as IApplication;

            if (app == null)
            {
                throw new NotSupportedException(String.Format("No application extension exists for start request type {0}", request.GetType().FullName));
            }

            if (!(app is Application))
            {
                throw new NotSupportedException("Application class must derive from Application base class.");
            }

            #region Setup

            var application = (Application)app;
            var context     = new ApplicationContext(application);
            application._context = context;

            application._sessionPollingIntervalSeconds = TimeSpan.FromSeconds(ApplicationServiceSettings.Default.SessionPollingIntervalSeconds);

            #endregion

            //NOTE: must call start before adding to the cache; we want the app to be fully initialized before it can be accessed from outside this method.

            application.InternalStart(request);

            Cache.Instance.Add(application);

            return(application);
        }