public PropertyDetail FindByIgdId(string county, string igdId) { try { if (string.IsNullOrEmpty(county) || string.IsNullOrEmpty(igdId)) { throw new ArgumentNullException(igdId); } var collectionName = county.ToLower() + _current; IMongoCollection <PropertyDetail> collection = CollectionProvider.GetCollection <PropertyDetail>(_database, collectionName); var filter = Builders <PropertyDetail> .Filter.Eq("igdid", igdId.ToUpper()); string query = filter.ToString(); var json = filter.RenderToBsonDocument().ToJson(); var doc = collection.Find <PropertyDetail>(filter).FirstOrDefault(); return(doc ?? null); } catch (Exception ex) { throw new RepositoryException(ex.Message, ex); } }
public void TypeOfProviderRandom() { CollectionProvider <int> provider = new CollectionProvider <int>(TestIEnumarableInt(), ProviderType.Random); Assert.Equal(typeof(int), provider.TType); Assert.Equal(ProviderType.Random, provider.Type); }
public void TypeOfProviderSequential() { CollectionProvider <int> provider = new CollectionProvider <int>(TestIEnumarableInt()); Assert.Equal(typeof(int), provider.TType); Assert.Equal(ProviderType.Sequential, provider.Type); }
public void ConstructorWithIntegerRandom() { var collection = TestIEnumarableInt(); CollectionProvider <int> provider = new CollectionProvider <int>(collection, ProviderType.Random); Assert.Contains(provider.Current, collection); }
public void ConstructorWithIntegerRandomHashCode() { var collection = TestIEnumarableInt(); CollectionProvider <int> provider = new CollectionProvider <int>(collection, ProviderType.Random); Assert.NotEqual(collection.GetHashCode(), provider.Collection.GetHashCode()); }
public void UpdateCollectionProvider(object sender = null) { StatusBarViewModel.Instance.ProcStatus = "Loading Indexing File ....."; collectionProvider = new CollectionProvider(settingsVM.CollectionPath, sender); StatusBarViewModel.Instance.ProcStatus = "Finish Loading Indexing File"; relevantProvider = new SimpleRelevantProvider(collectionProvider); }
public void ConstructorWithSequentialSameHashCode() { var collection = TestIEnumarableInt(); CollectionProvider <int> provider = new CollectionProvider <int>(collection); Assert.Equal(collection.GetHashCode(), provider.Collection.GetHashCode()); }
public IMapping Collection <P>(string field, IEnumerable <P> collection, ProviderType type = ProviderType.Sequential) { CollectionProvider <P> provider = new CollectionProvider <P>(collection, type); listOfFields.Add(field, provider); return(this); }
public SearchManager() { settingsVM = SettingsViewModel.Instance;; luceneIndexDirectory = null; collectionProvider = new CollectionProvider(settingsVM.CollectionPath); relevantProvider = new SimpleRelevantProvider(collectionProvider); trecLogger = new TrecLogger(); }
/// <summary> /// Removes an item from the cache by it's key asynchronously. /// </summary> /// <param name="key">The key for the cache item.</param> /// <param name="token">The <see cref="CancellationToken"/> for the operation.</param> public async Task RemoveAsync(string key, CancellationToken token = new CancellationToken()) { token.ThrowIfCancellationRequested(); if (key == null) { throw new ArgumentNullException(nameof(key)); } var collection = await CollectionProvider.GetCollectionAsync().ConfigureAwait(false); await collection.RemoveAsync(key).ConfigureAwait(false); }
public IrRelevantProvider(CollectionProvider cp) : base(cp) { luceneIndexDirectory = null; writer = null; analyzer = new Lucene.Net.Analysis.Standard.StandardAnalyzer(VERSION); //SimpleAnalyzer(); parser = new QueryParser(Lucene.Net.Util.Version.LUCENE_30, TEXT_FN, analyzer); CreateIndex(); AddDocuments(); CleanUpIndexer(); CreateSearcher(); }
public IMapping Collection <P>(IEnumerable <P> collection, ProviderType type = ProviderType.Sequential) where P : class { CollectionProvider <P> provider = new CollectionProvider <P>(collection, type); var ttype = typeof(P); var info = ttype.GetTypeInfo(); foreach (var prop in info.DeclaredProperties) { listOfFields.Add(prop.Name, provider); } return(this); }
public void ConstructorWithSequentialProvider() { var list = new List <int>() { 3, 5, 7 }; IDataProvider provider = new CollectionProvider <int>(list); var settings = new JsonFieldSettings("age", provider); Assert.Equal("age", settings.Fields); Assert.Equal(typeof(int).ToString(), settings.T); Assert.Equal(list, settings.Value); Assert.Equal(ProviderType.Sequential.ToString(), settings.Type); }
private void GetAllAndFillControls() { allListView.Items.Clear(); var allItems = CollectionProvider.Items().ToList(); for (var i = 0; i < allItems.Count(); i++) { AddItemTo(i, allItems[i], allListView); } AutoResizeColumnsAndHighlightChanges(); HighlightChanges(); }
public void ConstructorWithSequentialClassLoop() { var collection = TestIEnumarableData(); CollectionProvider <TestData> provider = new CollectionProvider <TestData>(collection); // go over all elements, and go back to head of list for (int i = 0; i < collection.Count(); i++) { provider.MoveNext(null); } Assert.Equal(collection.First(), provider.Current); }
public void ConstructorWithSequentialInteger() { var collection = TestIEnumarableInt(); CollectionProvider <int> provider = new CollectionProvider <int>(collection); List <int> temp = new List <int>(); for (int i = 0; i < collection.Count(); i++) { temp.Add(provider.Current); provider.MoveNext(null); } Assert.Equal(temp, collection); }
/// <summary> /// Gets a cache item by its key asynchronously, returning null if the item does not exist within the Cache. /// </summary> /// <param name="key">The key to lookup the item.</param> /// <param name="token">The <see cref="CancellationToken"/> for the operation.</param> /// <returns>The cache item if found, otherwise null.</returns> public async Task <byte[]> GetAsync(string key, CancellationToken token = new CancellationToken()) { token.ThrowIfCancellationRequested(); if (key == null) { throw new ArgumentNullException(nameof(key)); } var collection = await CollectionProvider.GetCollectionAsync().ConfigureAwait(false); var result = await collection.GetAsync(key, new GetOptions().Transcoder(_transcoder)) .ConfigureAwait(false); return(result.ContentAs <byte[]>()); }
public void TryGet() { var provider = new CollectionProvider(new MessagePackProvider(), MessagePackContext.Empty); bool result0 = provider.TryGet(typeof(int[]), out IMessagePackFormatter formatter0); bool result1 = provider.TryGet(typeof(List <int>), out IMessagePackFormatter formatter1); bool result2 = provider.TryGet(typeof(Dictionary <int, int>), out IMessagePackFormatter formatter2); Assert.True(result0); Assert.True(result1); Assert.True(result2); Assert.NotNull(formatter0); Assert.NotNull(formatter1); Assert.NotNull(formatter2); }
public HttpResponseMessage DelColletion([FromUri] int Param) { try { CollectionProvider _Provider = new CollectionProvider(); var result = _Provider.DelColletion(Param); return(Request.CreateResponse(HttpStatusCode.OK, result)); } catch (Exception ex) { LogFactory _LogFactory = new LogFactory(this.GetType()); _LogFactory.CreateLog(LogType.Error, "删除收藏", "DelColletion", ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public HttpResponseMessage GetCollectionList([FromUri] int StartRow, [FromUri] int PageSize) { try { CollectionProvider _Provider = new CollectionProvider(); var result = _Provider.GetCollectionList(StartRow, PageSize); return(Request.CreateResponse(HttpStatusCode.OK, result)); } catch (Exception ex) { LogFactory _LogFactory = new LogFactory(this.GetType()); _LogFactory.CreateLog(LogType.Error, "获取收藏列表", "GetCollectionList", ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public void ConstructorWithRandomProvider() { var list = new List <int>() { 3, 5, 7 }; IDataProvider provider = new CollectionProvider <int>(list, ProviderType.Random); var settings = new JsonFieldSettings("age", provider); Assert.Equal("age", settings.Fields); Assert.Equal(typeof(int).ToString(), settings.T); Assert.All(list, i => { Assert.Contains(i, (IEnumerable <int>)settings.Value); }); Assert.Equal(ProviderType.Random.ToString(), settings.Type); }
private void AddItemTo(int?index, object item, ListView listView) { var itemContent = CollectionProvider.ItemContent(item).ToList(); var elements = new string[itemContent.Count() + 1]; elements[0] = index == null ? string.Empty : (index + 1).ToString(); itemContent.CopyTo(elements, 1); var listViewItem = new ListViewItem(elements) { Tag = item }; listView.Items.Add(listViewItem); }
/// <summary> /// Sets a cache item using its key asynchronously. If the key exists, it will not be updated. /// </summary> /// <param name="key">The key for the cache item.</param> /// <param name="value">An array of bytes representing the item.</param> /// <param name="options">The <see cref="DistributedCacheEntryOptions"/> for the item; note that only sliding expiration is currently supported.</param> /// <param name="token">The <see cref="CancellationToken"/> for the operation.</param> public async Task SetAsync(string key, byte[] value, DistributedCacheEntryOptions?options, CancellationToken token = new CancellationToken()) { token.ThrowIfCancellationRequested(); if (key == null) { throw new ArgumentNullException(nameof(key)); } if (value == null) { throw new ArgumentNullException(nameof(value)); } var collection = await CollectionProvider.GetCollectionAsync().ConfigureAwait(false); await collection.UpsertAsync(key, value, new UpsertOptions().Transcoder(_transcoder).Expiry(GetLifetime(options))) .ConfigureAwait(false); }
private void GetPartAndFillControls() { var index = CurrentIndex; var firstPart2 = CollectionProvider.GetPartItemsAsync(index * Skip, Limit); var secondPart2 = CollectionProvider.GetPartItemsAsync((index + 1) * Skip, Limit); var thirdPart2 = CollectionProvider.GetPartItemsAsync((index + 2) * Skip, Limit); firstListView.Items.Clear(); secondListView.Items.Clear(); thirdListView.Items.Clear(); Task.WaitAll(firstPart2.AsTask(), secondPart2.AsTask(), thirdPart2.AsTask()); FillPartList(firstPart2.Result, firstListView); FillPartList(secondPart2.Result, secondListView); FillPartList(thirdPart2.Result, thirdListView); AutoResizeColumnsAndHighlightChanges(); HighlightChanges(); }
/// <summary> /// Gets a cache item by its key asynchronously, returning null if the item does not exist within the Cache. /// </summary> /// <param name="key">The key to lookup the item.</param> /// <param name="token">The <see cref="CancellationToken"/> for the operation.</param> /// <returns>The cache item if found, otherwise null.</returns> async Task <byte[]> IDistributedCache.GetAsync(string key, CancellationToken token) { token.ThrowIfCancellationRequested(); if (key == null) { throw new ArgumentNullException(nameof(key)); } var collection = await CollectionProvider.GetCollectionAsync().ConfigureAwait(false); try { var result = await collection.GetAsync(key, new GetOptions().Transcoder(_transcoder)) .ConfigureAwait(false); return(result.ContentAs <byte[]>()); } catch (DocumentNotFoundException) { return(null); } }
public PropertyDetail FindByParcelId(string state, string county, string parcelId) { try { if (string.IsNullOrEmpty(state) || string.IsNullOrEmpty(county) || string.IsNullOrEmpty(parcelId)) { throw new ArgumentNullException(parcelId); } var collectionName = county.ToLower() + _current; IMongoCollection <PropertyDetail> collection = CollectionProvider.GetCollection <PropertyDetail>(Database, _current); var filter = Builders <PropertyDetail> .Filter.Eq("parcelid", parcelId); var doc = collection.Find(filter).FirstOrDefault(); return(doc ?? null); } catch (Exception ex) { throw new RepositoryException(ex.Message, ex); } }
public ProjectFeedRepository() { Database = DatabaseProvider.GetDatabase(); _collection = CollectionProvider.GetCollection <ProjectFeed>(Database); }
public RelevantProvider(CollectionProvider cp) { collectionProvider = cp; }
public SimpleRelevantProvider(CollectionProvider cp) : base(cp) { }
public MongoRepository(IMongoDatabase database) { Collection = CollectionProvider.GetCollection <T>(database); Database = database; }