public void Connect() { Yaz.ZOOM_connection_connect(ZConnection, _host, _port); var errorCode = Yaz.ZOOM_connection_errcode(ZConnection); CheckErrorCodeAndThrow(errorCode); _connected = true; }
public ScanTerm this[uint index] { get { int occ, length; var term = Yaz.ZOOM_scanset_term(_scanSet, index, out occ, out length); return(new ScanTerm(term, occ)); } }
void IDisposable.Dispose() { if (IntPtr.Zero != _package) { Yaz.ZOOM_package_destroy(_package); _connection = null; _package = IntPtr.Zero; } }
public Package Package(string type) { EnsureConnected(); var options = Yaz.ZOOM_options_create(); var yazPackage = Yaz.ZOOM_connection_package(ZConnection, options); var pack = new Package(yazPackage, this, type); return(pack); }
public void Dispose() { if (!_disposed) { Yaz.ZOOM_scanset_destroy(_scanSet); _connection = null; _scanSet = IntPtr.Zero; _disposed = true; } }
public void Dispose() { if (!_disposed) { Yaz.ZOOM_connection_destroy(ZConnection); //Yaz.yaz_log(Yaz.LogLevel.LOG, "Connection Disposed"); ZConnection = IntPtr.Zero; _disposed = true; } }
public Record this[uint index] { get { if (_records[index] == null) { var record = Yaz.ZOOM_resultset_record(_resultSet, index); _records[index] = new Record(record, this); } return(_records[index]); } }
internal ResultSet(IntPtr resultSet, Connection connection) { _resultSet = resultSet; _size = Yaz.ZOOM_resultset_size(_resultSet); if (0 == _size) { Console.Out.WriteLine("Yaz.ZOOM_resultset_size zero"); } _records = new Record[_size]; }
void IDisposable.Dispose() { if (!_disposed) { foreach (Record record in _records) { record.Dispose(); } Yaz.ZOOM_resultset_destroy(_resultSet); _resultSet = IntPtr.Zero; _disposed = true; } }
public Connection(string host, int port) { _host = host; _port = port; _options = new ConnectionOptionsCollection(); _options["mediumSetElementSetName"] = "F"; ZConnection = Yaz.ZOOM_connection_create(_options.ZoomOptions); Yaz.ZOOM_connection_option_setl(ZConnection, "mediumSetElementSetName", "F", 1); var errorCode = Yaz.ZOOM_connection_errcode(ZConnection); CheckErrorCodeAndThrow(errorCode); }
public ScanSet Scan(IQuery query) { EnsureConnected(); var yazScanSet = Yaz.ZOOM_connection_scan(ZConnection, query.QueryString); var errorCode = Yaz.ZOOM_connection_errcode(ZConnection); if (errorCode != Yaz.ZoomErrorNone) { Yaz.ZOOM_scanset_destroy(yazScanSet); } CheckErrorCodeAndThrow(errorCode); var scanSet = new ScanSet(yazScanSet, this); return(scanSet); }
public ResultSet Search(IQuery query) { EnsureConnected(); var yazQuery = Yaz.ZOOM_query_create(); ResultSet resultSet; try { // branching out to right YAZ-C call if (query is CQLQuery) { Yaz.ZOOM_query_cql(yazQuery, query.QueryString); } else if (query is PrefixQuery) { Yaz.ZOOM_query_prefix(yazQuery, query.QueryString); } else { throw new NotImplementedException(); } var yazResultSet = Yaz.ZOOM_connection_search(ZConnection, yazQuery); Yaz.ZOOM_resultset_option_set(yazResultSet, "elementSetName", "F"); // error checking C-style var errorCode = Yaz.ZOOM_connection_errcode(ZConnection); if (errorCode != Yaz.ZoomErrorNone) { Yaz.ZOOM_resultset_destroy(yazResultSet); } CheckErrorCodeAndThrow(errorCode); resultSet = new ResultSet(yazResultSet, this); } finally { Yaz.ZOOM_query_destroy(yazQuery); } return(resultSet); }
private void CheckErrorCodeAndThrow(int errorCode) { string message; switch (errorCode) { case Yaz.ZoomErrorNone: break; case Yaz.ZoomErrorConnect: message = $"Connection could not be made to {_host}:{_port}"; throw new Exception(message); case Yaz.ZoomErrorInvalidQuery: message = "The query requested is not valid or not supported"; throw new Exception(message); case Yaz.ZoomErrorInit: message = string.Format("Server {0}:{1} rejected our init request", _host, _port); throw new Exception(message); case Yaz.ZoomErrorTimeout: message = string.Format("Server {0}:{1} timed out handling our request", _host, _port); throw new Exception(message); case Yaz.ZoomErrorMemory: case Yaz.ZoomErrorEncode: case Yaz.ZoomErrorDecode: case Yaz.ZoomErrorConnectionLost: case Yaz.ZoomErrorInternal: case Yaz.ZoomErrorUnsupportedProtocol: case Yaz.ZoomErrorUnsupportedQuery: message = Yaz.ZOOM_connection_errmsg(ZConnection); throw new Exception("A fatal error occurred in Yaz: " + errorCode + " - " + message); default: throw new Exception("未经处理的异常"); } }
void Send() { Yaz.ZOOM_package_send(_package, _type); }
internal ConnectionOptionsCollection() { ZoomOptions = Yaz.ZOOM_options_create(); }
public string this[string key] { get { return(Yaz.ZOOM_options_get(ZoomOptions, key)); } set { Yaz.ZOOM_options_set(ZoomOptions, key, value); } }
internal IntPtr CreateConnection() { return(Yaz.ZOOM_connection_create(ZoomOptions)); }
public void Dispose() { Yaz.ZOOM_options_destroy(ZoomOptions); ZoomOptions = IntPtr.Zero; }
public string this[string key] { get { return(Yaz.ZOOM_package_option_get(Package, key)); } set { Yaz.ZOOM_package_option_set(Package, key, value); } }
public string this[string key] { get { return(Yaz.ZOOM_resultset_option_get(ResultSet, key)); } set { Yaz.ZOOM_resultset_option_set(ResultSet, key, value); } }