Exemplo n.º 1
0
        /// <summary>
        /// Initializes the context by applying the builder config, registering the entities and opening the database connection
        /// </summary>
        /// <param name="options">The DataContextBuilder which will be used to configure the context</param>
        private void OnInit(DataContextBuilder options)
        {
            // Run the builder through OnConfigure incase it is implemented
            OnConfigure(options);

            // Apply all the options from the builder
            dbDriver     = options.DbDriver;
            deserializer = options.Deserializer;
            logger       = options.Logger;
            isLogging    = options.Logging;
            IsConfigured = true;

            OnEntityRegister();
            dbDriver.OpenConnection(logger);
            if (isLogging)
            {
                logger.Log($"{this.GetType().Name} has been initialized with driver: {dbDriver.DriverName} ({dbDriver.GetType().FullName})");
            }
        }
Exemplo n.º 2
0
 public DataContext(DataContextBuilder options)
 {
     IsConfigured = true;
     OnInit(options);
 }
Exemplo n.º 3
0
 /// <summary>
 /// This method is optionally used to configure the context. It is meant to be overriden by subclasses that inherit this base class.
 /// </summary>
 /// <param name="builder">The builder instance which is used to configure the context</param>
 protected virtual void OnConfigure(DataContextBuilder builder)
 {
 }