public override IExternalBlobConnection GetConnection() { IExternalBlobConnection connectionFrom = _from.GetConnection(); IExternalBlobConnection connectionTo = _to.GetConnection(); return(new MigrationConnection(connectionFrom, connectionTo)); }
public override void NullSafeSet(DbCommand cmd, object value, int index, ISessionImplementor session) { if (value == null) { ((IDataParameter)cmd.Parameters[index]).Value = DBNull.Value; } else { IExternalBlobConnection conn = GetExternalBlobConnection(session); IExternalBlobConnection blobconn; byte[] payload; if (!ExtractLobData(value, out blobconn, out payload) || !conn.Equals(blobconn)) // Skip writing if an equal connection is used { using (ExternalBlobWriter writer = conn.OpenWriter()) { WriteLobTo(value, writer); payload = writer.Commit(); var persistedLob = ((IPersistedLob)value); if (!persistedLob.IsPersisted) { ((IPersistedLob)value).SetPersistedIdentifier(payload, conn); } } } ((IDataParameter)cmd.Parameters[index]).Value = payload; } }
public ExternalBlob(IExternalBlobConnection connection, byte[] identifier) { if (connection == null) throw new ArgumentNullException("connection"); if (identifier == null) throw new ArgumentNullException("identifier"); this.connection = connection; this.identifier = identifier; }
bool IExternalBlobConnection.Equals(IExternalBlobConnection connection) { if (connection is ExternalBlobDbConnectionWrapper) { connection = (connection as ExternalBlobDbConnectionWrapper)._externalConnection; } return(_externalConnection.Equals(connection)); }
public ExternalClob(IExternalBlobConnection connection, byte[] identifier, Encoding encoding) { if (connection == null) throw new ArgumentNullException("connection"); if (identifier == null) throw new ArgumentNullException("identifier"); if (encoding == null) throw new ArgumentNullException("encoding"); this.connection = connection; this.identifier = identifier; this.encoding = encoding; }
public ExternalXlob(IExternalBlobConnection connection, byte[] identifier, IXmlCompressor compression) { if (connection == null) throw new ArgumentNullException("connection"); if (identifier == null) throw new ArgumentNullException("identifier"); if (compression == null) throw new ArgumentNullException("compression"); _connection = connection; _identifier = identifier; _compression = compression; }
public override bool Equals(IExternalBlobConnection connection) { var c = connection as FileSystemCasConnection; if (c == null) { return(false); } return(_path.Equals(c._path) && _hashName == c._hashName); }
public override object NullSafeGet(DbDataReader rs, string name, ISessionImplementor session, object owner) { int index = rs.GetOrdinal(name); if (rs.IsDBNull(index)) { return(null); } IExternalBlobConnection conn = GetExternalBlobConnection(session); byte[] payload; if (conn.BlobIdentifierLength == Int32.MaxValue) { var length = (int)rs.GetBytes(index, 0L, null, 0, 0); payload = new byte[length]; // The if here makes MySql happy (See https://nhibernate.jira.com/browse/NH-2096 for details) if (length > 0) { rs.GetBytes(index, 0L, payload, 0, length); } } else { payload = new byte[conn.BlobIdentifierLength]; // The if here makes MySql happy (See https://nhibernate.jira.com/browse/NH-2096 for details) if (payload.Length > 0) { var i = (int)rs.GetBytes(index, 0, payload, 0, payload.Length); if (i != payload.Length) { if (Logger.IsErrorEnabled()) { Logger.Error("Unknown payload (identifier) length. Recieved {0} but expected {1} bytes for owner: {2}", i, payload.Length, owner); } return(null); } } else { if (Logger.IsErrorEnabled()) { Logger.Error("Unknown payload (identifier) length. Recieved 0 but expected {0} bytes for owner: {1}", payload.Length, owner); } return(null); } } return(CreateLobInstance(conn, payload)); }
public override object Assemble(object cached, ISessionImplementor session, object owner) { var payload = cached as byte[]; if (payload == null) { return(null); } IExternalBlobConnection conn = GetExternalBlobConnection(session); return(CreateLobInstance(conn, payload)); }
protected override bool ExtractLobData(object lob, out IExternalBlobConnection connection, out byte[] identifier) { ExternalClob clob = lob as ExternalClob; if (clob == null) { connection = null; identifier = null; return false; } connection = clob.Connection; identifier = clob.Identifier; return true; }
public ExternalBlob(IExternalBlobConnection connection, byte[] identifier) { if (connection == null) { throw new ArgumentNullException("connection"); } if (identifier == null) { throw new ArgumentNullException("identifier"); } _connection = connection; _identifier = identifier; }
public ExternalXlob(IExternalBlobConnection connection, byte[] identifier, IXmlCompressor compression) { if (connection == null) { throw new ArgumentNullException("connection"); } if (identifier == null) { throw new ArgumentNullException("identifier"); } if (compression == null) { throw new ArgumentNullException("compression"); } _connection = connection; _identifier = identifier; _compression = compression; }
public ExternalClob(IExternalBlobConnection connection, byte[] identifier, Encoding encoding) { if (connection == null) { throw new ArgumentNullException("connection"); } if (identifier == null) { throw new ArgumentNullException("identifier"); } if (encoding == null) { throw new ArgumentNullException("encoding"); } _connection = connection; _identifier = identifier; _encoding = encoding; }
public override object Disassemble(object value, ISessionImplementor session, object owner) { if (value == null) { return(null); } IExternalBlobConnection blobconn; byte[] payload; bool hasExternalLob = ExtractLobData(value, out blobconn, out payload); IExternalBlobConnection conn = GetExternalBlobConnection(session); if (conn.DisassembleRequiresExternalBlob && !hasExternalLob) { throw new Exception("Unable to cache an unsaved lob."); } return(payload); }
protected override bool ExtractLobData(object lob, out IExternalBlobConnection connection, out byte[] identifier) { var blob = lob as ExternalBlob; if (blob == null) { var persistedLob = lob as IPersistedLob; if (persistedLob != null && persistedLob.IsPersisted) { identifier = persistedLob.GetPersistedIdentifier(); connection = (IExternalBlobConnection) persistedLob.GetExternalStore(); return true; } connection = null; identifier = null; return false; } connection = blob.Connection; identifier = blob.Identifier; return true; }
protected override bool ExtractLobData(object lob, out IExternalBlobConnection connection, out byte[] identifier) { var xlob = lob as ExternalXlob; if (xlob == null) { var persistedLob = lob as IPersistedLob; if (persistedLob != null && persistedLob.IsPersisted) { identifier = persistedLob.GetPersistedIdentifier(); connection = (IExternalBlobConnection)persistedLob.GetExternalStore(); return(true); } connection = null; identifier = null; return(false); } connection = xlob.Connection; identifier = xlob.Identifier; return(true); }
public bool Equals(IExternalBlobConnection connection) { return(_from.Equals(connection)); }
public MigrationConnection(IExternalBlobConnection from, IExternalBlobConnection to) { _from = from; _to = to; }
public ExternalClob(IExternalBlobConnection connection, byte[] identifier, Encoding encoding, IStreamCompressor compression) : this(connection, identifier, encoding) { this.compression = compression; }
protected override object CreateLobInstance(IExternalBlobConnection connection, byte[] payload) { return(new ExternalXlob(connection, payload, _compression)); }
protected abstract object CreateLobInstance(IExternalBlobConnection connection, byte[] payload);
public override bool Equals(IExternalBlobConnection connection) { var c = connection as FileSystemCasConnection; if (c == null) return false; return _path.Equals(c._path) && _hashName == c._hashName; }
public ExternalBlobDbConnectionWrapper(DbConnection db, IExternalBlobConnection externalConnection) { _db = db; _externalConnection = externalConnection; }
protected override object CreateLobInstance(IExternalBlobConnection connection, byte[] identifier) { return new ExternalClob(connection, identifier, encoding, compression); }
public abstract bool Equals(IExternalBlobConnection connection);
public bool Equals(IExternalBlobConnection connection) { return _from.Equals(connection); }
protected override object CreateLobInstance(IExternalBlobConnection connection, byte[] payload) { return new ExternalBlob(connection, payload, _compression); }
protected abstract object CreateLobInstance(IExternalBlobConnection connection, byte[] identifier);
public ExternalBlobDbConnectionWrapper(IDbConnection db, IExternalBlobConnection externalConnection) { _db = db; _externalConnection = externalConnection; }
public override bool Equals(IExternalBlobConnection connection) { return connection is ByteArrayConnection; }
public ExternalBlob(IExternalBlobConnection connection, byte[] identifier, IStreamCompressor compression) : this(connection, identifier) { _compression = compression; }
public ExternalBlobDbConnectionWrapper(IDbConnection db, IExternalBlobConnection cas) { _db = db; _cas = cas; }
bool IExternalBlobConnection.Equals(IExternalBlobConnection connection) { if (connection is ExternalBlobDbConnectionWrapper) connection = (connection as ExternalBlobDbConnectionWrapper)._cas; return _cas.Equals(connection); }
public override bool Equals(IExternalBlobConnection connection) { return(connection is ByteArrayConnection); }
protected abstract bool ExtractLobData(object lob, out IExternalBlobConnection connection, out byte[] identifier);