//-------------------------------------------------------------------------- public bool GetContents(Tuple <LocationDetail, LocationDetail> phrase, GetContentsCallback callback) { return(_workerThread.PostTask(_ => { try { // we extract sorrounding lines/sentences based only on the first // word of the phrase (simplifies our code) Tuple <long, long> surroundingOffsets = ContainsService.Instance.GetSurroundingOffsets( phrase.Item1.Location, _useLinesForContentRetreival, _contentRetreivalDelta); long contentsWordOffsetBegin = 0; long contentsWordOffsetEnd = 0; string contents = DocumentsService.Instance.GetContents( phrase, surroundingOffsets.Item1, surroundingOffsets.Item2, out contentsWordOffsetBegin, out contentsWordOffsetEnd); callback(contents, contentsWordOffsetBegin, contentsWordOffsetEnd, true, null); } catch (Exception e) { callback(null, 0, 0, false, e.Message); } })); }
//-------------------------------------------------------------------------- public bool GetContents(LocationDetail locationDetail, GetContentsCallback callback) { return(_workerThread.PostTask(_ => { try { Tuple <long, long> surroundingOffsets = ContainsService.Instance.GetSurroundingOffsets( locationDetail.Location, _useLinesForContentRetreival, _contentRetreivalDelta); long contentsWordOffsetBegin = 0; long contentsWordOffsetEnd = 0; string contents = DocumentsService.Instance.GetContents( locationDetail, surroundingOffsets.Item1, surroundingOffsets.Item2, out contentsWordOffsetBegin, out contentsWordOffsetEnd); callback(contents, contentsWordOffsetBegin, contentsWordOffsetEnd, true, null); } catch (Exception e) { callback(null, 0, 0, false, e.Message); } })); }