Ejemplo n.º 1
0
        void IDisposable.Dispose()
        {
            //Console.Out.WriteLine("IDisposable.Dispose {0} {1}",
            //                       this, this.GetHashCode());

            if (!_disposed)
            {
                foreach (Record record in _records)
                {
                    if (record != null)
                    {
                        record.Dispose();
                    }
                }
                Yaz.ZOOM_resultset_destroy(_resultSet);
                //Yaz.yaz_log(Yaz.LogLevel.LOG, "ResultSet Disposed");
                _connection = null;
                _resultSet  = IntPtr.Zero;
                _disposed   = true;
            }
        }
Ejemplo n.º 2
0
        public IResultSet Search(IQuery query)
        {
            EnsureConnected();
            IntPtr    yazQuery  = Yaz.ZOOM_query_create();
            ResultSet resultSet = null;

            try {
                // branching out to right YAZ-C call
                if (query is ICQLQuery)
                {
                    Yaz.ZOOM_query_cql(yazQuery, query.QueryString);
                }
                else if (query is IPrefixQuery)
                {
                    Yaz.ZOOM_query_prefix(yazQuery, query.QueryString);
                }
                else
                {
                    throw new NotImplementedException();
                }

                IntPtr yazResultSet = Yaz.ZOOM_connection_search(_zoomConnection, yazQuery);
                // error checking C-style
                int errorCode = Yaz.ZOOM_connection_errcode(_zoomConnection);
                if (errorCode != Yaz.ZOOM_ERROR_NONE)
                {
                    Yaz.ZOOM_resultset_destroy(yazResultSet);
                }
                CheckErrorCodeAndThrow(errorCode);

                // everything ok, create result set
                resultSet = new ResultSet(yazResultSet, this);
            }
            finally {
                // deallocate yazQuery also when exceptions
                Yaz.ZOOM_query_destroy(yazQuery);
                yazQuery = IntPtr.Zero;
            }
            return(resultSet);
        }