public static IConnection Create(IConnectionDescriptor descriptor) { switch (descriptor.Type) { case DescriptorType.JSON: ConnectionFactory.connection = new JSONConnection(descriptor); break; case DescriptorType.EnvironmentVariable: ConnectionFactory.connection = new EnvironmentVariableConnection(descriptor); break; default: ConnectionFactory.connection = null; break; } return(ConnectionFactory.connection); }
public ConnectionParameter GetParameter(IConnectionDescriptor descriptor) { throw new NotImplementedException(); }
/// <summary> /// Unable to establish a database connection. /// </summary> /// <param name="desc">Connection descriptor we were using to try to connect.</param> /// <param name="numTimes">How many times in a row have we failed to connect, if /// known. This is used in the message only if it is greater /// than 1.</param> /// <param name="e">Exception that was thrown by the database driver.</param> public UnableToConnectException(IConnectionDescriptor desc, int numTimes, Exception e) : base("Unable to connect to database" + ((numTimes > 1) ? (" (" + numTimes + " time(s) in a row).") : "."), desc, e) { }
/// <summary> /// Unable to execute SQL. /// </summary> /// <param name="message">Start of the message, if you don't want to use the default.</param> /// <param name="desc">Connection descriptor we connected with.</param> /// <param name="sql">SQL statement we were trying to execute.</param> /// <param name="sqlParams">Parameters for the sql statement (may be null).</param> /// <param name="e">Exception that was thrown by the database driver.</param> public UnableToRunSqlException(string message, IConnectionDescriptor desc, string sql, IEnumerable sqlParams, Exception e) : base(message + " " + SqlUtilities.SqlParamsToString(sql, sqlParams) + ".", desc, e) { }
/// <summary> /// This connection doesn't support transactions. /// </summary> /// <param name="desc">Connection descriptor we were using to try to connect.</param> /// <param name="message">A message describing what is wrong with the connection type.</param> public TransactionsNotSupportedException(IConnectionDescriptor desc, string message) : base(message, desc, null) { // Nothing to set here. }
/// <summary> /// An error occurred doing something with a database. /// </summary> /// <param name="message">What happened.</param> /// <param name="desc">The connection info will be appended to the message.</param> /// <param name="e">Inner exception that caused this one to be thrown.</param> public ExceptionWithConnectionInfo(string message, IConnectionDescriptor desc, Exception e) : base(message + " Connection info: " + desc, e) { }
/// <summary> /// Unable to execute SQL. /// </summary> /// <param name="desc">Connection descriptor we connected with.</param> /// <param name="sql">SQL statement we were trying to execute.</param> /// <param name="sqlParams">Parameters for the sql statement (may be null).</param> /// <param name="e">Exception that was thrown by the database driver.</param> public UnableToRunSqlException(IConnectionDescriptor desc, string sql, IEnumerable sqlParams, Exception e) : base("Database exception while trying to execute SQL statement: " + SqlUtilities.SqlParamsToString(sql, sqlParams) + ".", desc, e) { }
/// <summary> /// This connection can't do that. /// </summary> /// <param name="desc">Connection descriptor we were using to try to connect.</param> /// <param name="message">A message describing what is wrong with the connection type.</param> public BadConnectionTypeException(IConnectionDescriptor desc, string message) : base(message, desc, null) { // Nothing to set here. }
/// <summary> /// Unable to construct a SQL statement. /// </summary> /// <param name="message">Start of the message, if you don't want to use the default.</param> /// <param name="desc">Connection descriptor we would have connected with.</param> /// <param name="e">Exception that was thrown by the database driver.</param> public UnableToConstructSqlException(string message, IConnectionDescriptor desc, Exception e) : base(message, desc, e) { }
/// <summary> /// Instantiates the data access layer with the connection descriptor for the data source. /// </summary> /// <param name="connDesc">The connection descriptor that is being used by this FastDaoLayer.</param> /// <param name="supportsNumRecords">If true, methods that return numbers of records affected will be /// returning accurate numbers. If false, they will probably return /// FastDAO.UNKNOWN_NUM_ROWS.</param> protected UnqueryableDaLayer(IConnectionDescriptor connDesc, bool supportsNumRecords) : base(connDesc, supportsNumRecords) { }
/// <summary> /// Results from an operation were not correct. /// </summary> /// <param name="message">Start of the message, if you don't want to use the default.</param> /// <param name="desc">Connection descriptor we connected with.</param> /// <param name="e">Exception that was thrown by the delegate.</param> public UnexpectedResultsException(string message, IConnectionDescriptor desc, Exception e) : base(message, desc, e) { }
/// <summary> /// Instantiates the data access layer with the connection descriptor for the DB. /// </summary> /// <param name="connDesc">The connection descriptor that is being used by this FastDaoLayer.</param> /// <param name="supportsNumRecords">If true, methods that return numbers of records affected will be /// returning accurate numbers. If false, they will probably return /// FastDAO.UNKNOWN_NUM_ROWS.</param> protected AbstractDaLayer(IConnectionDescriptor connDesc, bool supportsNumRecords) { _connDesc = connDesc; _supportsNumRecords = supportsNumRecords; }
/// <summary> /// Error while processing SQL results. /// </summary> /// <param name="desc">Connection descriptor we connected with.</param> /// <param name="sql">SQL statement we were executed.</param> /// <param name="sqlParams">Parameters for the sql statement (may be null).</param> /// <param name="e">Exception that was thrown by the delegate.</param> public UnableToProcessSqlResultsException(IConnectionDescriptor desc, string sql, IEnumerable sqlParams, Exception e) : base("Exception while processing results from SQL statement: " + SqlUtilities.SqlParamsToString(sql, sqlParams) + ".", desc, e) { }
/// <summary> /// This has already been closed/terminated/etc. /// </summary> /// <param name="desc">Connection descriptor we were using.</param> /// <param name="message">What was already terminated.</param> public AlreadyTerminatedException(IConnectionDescriptor desc, string message) : base(message, desc, null) { }
public EnvironmentVariableConnection(IConnectionDescriptor descriptor) { this.descriptor = (EnvironmentVariableDescriptor)descriptor; }
/// <summary> /// Unable to begin a transaction against the database. /// </summary> /// <param name="desc">Connection descriptor we were using to try to connect.</param> /// <param name="e">Exception that was thrown by the database driver.</param> public UnableToCreateTransactionException(IConnectionDescriptor desc, Exception e) : base("Unable to begin a transaction.", desc, e) { }
public JSONConnection(IConnectionDescriptor descriptor) { this.descriptor = (JSONDescriptor)descriptor; }
/// <summary> /// Create a new memory store. /// </summary> /// <param name="connDesc">Connection descriptor to use with this layer.</param> public MemoryDaLayer(IConnectionDescriptor connDesc) : base(connDesc, true) { }