コード例 #1
0
        /// <summary>
        /// Initialize the data context if necessary such as instantiating an Entity Framework DbContext or WCF Service Client etc.
        /// </summary>
        public virtual void InitializeDataContext(AppContextBase appContext)
        {
            this.AppContext = appContext;
            this.Data       = new T();

            IAppContextAware appContextAwareDataContext = this.Data as IAppContextAware;

            if (appContextAwareDataContext != null)
            {
                appContextAwareDataContext.InitializeFromAppContext(appContext);
            }
        }
コード例 #2
0
        /// <summary>
        /// Initialize the app service. Throws an exception if the context has already been set.
        /// </summary>
        internal void InitializeAppService(AppContextBase appContext)
        {
            if (_appContext == null)
            {
                _appContext = appContext;

                OnInitialize();
            }
            else
            {
                throw new InvalidOperationException("App service has already been initialized.");
            }
        }
コード例 #3
0
 /// <summary>
 /// Initializes the class for use by an inherited class instance. This constructor can only be called by an inherited class.
 /// </summary>
 protected AppServicesBase(AppContextBase appContext)
 {
     InitializeAppService(appContext);
 }