Пример #1
0
 /// <summary>
 /// Libera a memória dos componentes
 /// </summary>
 /// <param name="disposing">indica chamada fora do destrutor</param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_queryContext != null)
         {
             _queryContext.Dispose();
             _queryContext = null;
         }
         if (_persistenceContext != null)
         {
             _persistenceContext.Dispose();
             _persistenceContext = null;
         }
     }
 }
Пример #2
0
        protected virtual void Initialize()
        {
            var serviceLocator = Microsoft.Practices.ServiceLocation.ServiceLocator.Current;
            IQueryDataSourceSelector _selector = null;

            try
            {
                var selectors = serviceLocator.GetAllInstances <IQueryDataSourceSelector>();
                _selector = selectors.FirstOrDefault();
            }
            catch (Exception)
            {
            }
            if (_selector == null)
            {
                try
                {
                    _queryContext = serviceLocator.GetInstance <Colosoft.Query.ISourceContext>();
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException(Properties.Resources.Exception_FailOnLoadQueryContext, ex);
                }
            }
            else
            {
                _queryContext = new QuerySourceContextWrapper(new QueryDataSourceWrapper(_selector));
            }
            try
            {
                _persistenceContext = PersistenceContextManager.PersitenceContext;
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException(Properties.Resources.Exception_LoadPersistenceContextError, ex);
            }
        }