/// <summary>
    /// Iterates through IDs of attachments that match the given <paramref name="readTime"/> and <paramref name="saveTime"/> criteria.
    /// </summary>
    public IEnumerable <string> Query(TimeRange readTime = null, TimeRange saveTime = null)
    {
        var metadataFilePaths = Directory.EnumerateFiles(_directoryPath, $"*.{MetadataFileExtension}");

        foreach (var metadataFilePath in metadataFilePaths)
        {
            string id;

            try
            {
                var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(metadataFilePath);

                id = fileNameWithoutExtension.Substring(FilePrefix.Length);

                var metadata = InnerReadMetadata(id, metadataFilePath, GetFilePath(id, DataFileExtension));

                if (!DataBusStorageQuery.IsSatisfied(metadata, readTime, saveTime))
                {
                    continue;
                }
            }
            catch (Exception)
            {
                id = null;
            }

            if (id != null)
            {
                yield return(id);
            }
        }
    }
Exemple #2
0
    public IEnumerable <string> Query(TimeRange readTime = null, TimeRange saveTime = null)
    {
        return(_dataStore
               .AttachmentIds
               .Where(id =>
        {
            var metadata = _dataStore.LoadMetadata(id);

            return DataBusStorageQuery.IsSatisfied(metadata, readTime, saveTime);
        }));
    }