// Only methods with a non-trivial implementation are here, the rest are in the DataAccessWrapper abstract class.
        #region DataAccessWrapper interface
        /// <summary>
        /// Creates a new DbConnection. You do not normally need to call this! (MightyOrm normally manages its own
        /// connections. Create a connection here and pass it on to other MightyOrm commands only in non-standard use
        /// cases where you need to explicitly manage transactions or share connections, e.g. when using explicit cursors.)
        /// </summary>
        /// <returns></returns>
        override public DbConnection OpenConnection()
        {
            var connection = Factory.CreateConnection();

            connection = DataProfiler.ConnectionWrapping(connection);
            connection.ConnectionString = ConnectionString;
            connection.Open();
            return(connection);
        }
Exemple #2
0
        /// <summary>
        /// Creates a new DbConnection. You do not normally need to call this! (MightyOrm normally manages its own
        /// connections. Create a connection here and pass it on to other MightyOrm commands only in non-standard use
        /// cases where you need to explicitly manage transactions or share connections, e.g. when using explicit cursors.)
        /// </summary>
        /// <param name="cancellationToken">Async <see cref="CancellationToken"/></param>
        /// <returns></returns>
        override public async Task <DbConnection> OpenConnectionAsync(CancellationToken cancellationToken)
        {
            var connection = Factory.CreateConnection();

            connection = DataProfiler.ConnectionWrapping(connection);
            connection.ConnectionString = ConnectionString;
            await connection.OpenAsync(cancellationToken).ConfigureAwait(false);

            return(connection);
        }
Exemple #3
0
        /// <summary>
        /// Internal usage only, creates a new DbConnection.
        /// </summary>
        /// <param name="isInternal"><cref>true</cref> if called internally</param>
        /// <param name="connectionString">Connection string to use</param>
        /// <returns></returns>
        internal DbConnection OpenConnection(bool isInternal, string connectionString = null)
        {
            if (string.IsNullOrEmpty(ConnectionString) && string.IsNullOrEmpty(connectionString))
            {
                if (isInternal)
                {
                    throw new InvalidOperationException("Connection needed to proceed, but no DbConnection object and no per-instance or global connection string available");
                }
                else
                {
                    throw new InvalidOperationException("No connection string provided, and no per-instance or global connection string available");
                }
            }
            var connection = Factory.CreateConnection();

            connection = DataProfiler.ConnectionWrapping(connection);
            connection.ConnectionString = string.IsNullOrEmpty(connectionString) ? ConnectionString : connectionString;
            connection.Open();
            return(connection);
        }
        public void StartServices()
        {
            // DI ready
            IServiceLocator locator = ServiceLocator.Current;

            IDataProfiler      profiler          = new DataProfiler();
            IDataConfiguration dataConfiguration = new DataConfiguration();
            IDataLocalizer     dataLocalizer     = new DataLocalizer();
            IApplicationHost   host      = new WebApplicationHost(profiler);
            IDbContext         dbContext = new SqlDbContext(profiler, dataConfiguration, dataLocalizer);

            //IRenderer renderer = new XamlRenderer();
            //IWorkflowEngine workflowEngine = new WorkflowEngine(host, dbContext);


            locator.RegisterService <IDataProfiler>(profiler);
            locator.RegisterService <IDataConfiguration>(dataConfiguration);
            locator.RegisterService <IDataLocalizer>(dataLocalizer);
            locator.RegisterService <IApplicationHost>(host);
            locator.RegisterService <IDbContext>(dbContext);

            //locator.RegisterService<IRenderer>(renderer);
            //locator.RegisterService<IWorkflowEngine>(workflowEngine);
        }