private int WorkLoad(int ServerID, List <int> vSlots) { int iLoad = 0; if (vSlots == null) { return(iLoad); } if (vSlots.Count == 0) { return(iLoad); } if (!StackExist(ServerID)) { return(iLoad); } foreach (int cID in vSlots) { VirtualSlot vSlot = Slots.Item(cID); if ((vSlot == null) || (vSlot.Status != SlotStatus.Downloading)) { continue; } IndexedCollection tStack = Stack(ServerID, vSlot.ID); if (tStack != null) { iLoad += tStack.Count; } } return(iLoad); }
public async Task ShopAdd(Role _, int price, [Remainder] IRole role) { var entry = new ShopEntry() { Name = "-", Price = price, Type = ShopEntryType.Role, AuthorId = Context.User.Id, RoleId = role.Id, RoleName = role.Name }; using (var uow = _db.UnitOfWork) { var entries = new IndexedCollection <ShopEntry>(uow.GuildConfigs.For(Context.Guild.Id, set => set.Include(x => x.ShopEntries) .ThenInclude(x => x.Items)).ShopEntries) { entry }; uow.GuildConfigs.For(Context.Guild.Id, set => set).ShopEntries = entries; uow.Complete(); } await Context.Channel.EmbedAsync(EntryToEmbed(entry) .WithTitle(GetText("shop_item_add"))); }
public async Task ShopAdd(List _, int price, [Remainder] string name) { var entry = new ShopEntry() { Name = name.TrimTo(100), Price = price, Type = ShopEntryType.List, AuthorId = Context.User.Id, Items = new HashSet <ShopEntryItem>(), }; using (var uow = _db.UnitOfWork) { var entries = new IndexedCollection <ShopEntry>(uow.GuildConfigs.For(Context.Guild.Id, set => set.Include(x => x.ShopEntries) .ThenInclude(x => x.Items)).ShopEntries) { entry }; uow.GuildConfigs.For(Context.Guild.Id, set => set).ShopEntries = entries; uow.Complete(); } await Context.Channel.EmbedAsync(EntryToEmbed(entry) .WithTitle(GetText("shop_item_add"))); }
public async Task Shop(int page = 1) { if (--page < 0) { return; } List <ShopEntry> entries; using (var uow = _db.UnitOfWork) { entries = new IndexedCollection <ShopEntry>(uow.GuildConfigs.For(Context.Guild.Id, set => set.Include(x => x.ShopEntries) .ThenInclude(x => x.Items)).ShopEntries); } await Context.SendPaginatedConfirmAsync(page, (curPage) => { var theseEntries = entries.Skip(curPage * 9).Take(9).ToArray(); if (!theseEntries.Any()) { return(new EmbedBuilder().WithErrorColor() .WithDescription(GetText("shop_none"))); } var embed = new EmbedBuilder().WithOkColor() .WithTitle(GetText("shop", _bc.BotConfig.CurrencySign)); for (int i = 0; i < theseEntries.Length; i++) { var entry = theseEntries[i]; embed.AddField(efb => efb.WithName($"#{curPage * 9 + i + 1} - {entry.Price}{_bc.BotConfig.CurrencySign}").WithValue(EntryToString(entry)).WithIsInline(true)); } return(embed); }, entries.Count, 9, true); }
public async Task ShopRemove(int index) { index -= 1; if (index < 0) { return; } var gc = uow.GuildConfigs.For(Context.Guild.Id, set => set.Include(x => x.ShopEntries).ThenInclude(x => x.Items)); var entries = new IndexedCollection <ShopEntry>(gc.ShopEntries); var entryToRemove = entries.ElementAtOrDefault(index); if (entryToRemove != null) { entries.Remove(entryToRemove); gc.ShopEntries = entries; await uow.SaveChangesAsync(false).ConfigureAwait(false); await Context.Channel.EmbedAsync(EntryToEmbed(entryToRemove).WithTitle(GetText("shop_item_rm"))); } else { await ReplyErrorLocalized("shop_item_not_found").ConfigureAwait(false); } }
private void BindCollectionIndex(IIndexedCollectionMapping listMapping, IndexedCollection model) { SimpleValue iv = null; if (listMapping.ListIndex != null) { iv = new SimpleValue(model.CollectionTable); new ValuePropertyBinder(iv, Mappings).BindSimpleValue(listMapping.ListIndex, IndexedCollection.DefaultIndexColumnName, model.IsOneToMany); } else if (listMapping.Index != null) { iv = new SimpleValue(model.CollectionTable); listMapping.Index.type = NHibernateUtil.Int32.Name; new ValuePropertyBinder(iv, Mappings).BindSimpleValue(listMapping.Index, IndexedCollection.DefaultIndexColumnName, model.IsOneToMany); } if (iv != null) { if (iv.ColumnSpan > 1) { log.Error("This shouldn't happen, check BindIntegerValue"); } model.Index = iv; } }
/// <summary> /// Inventory Groups. /// </summary> /// <returns><c>BagCollection</c> of Inventory Groups.</returns> private static BagCollection <InvGroups> Groups() { IndexedCollection <InvGroups> collection = new IndexedCollection <InvGroups>(); foreach (invGroups group in s_context.invGroups) { InvGroups item = new InvGroups { ID = group.groupID, Name = group.groupName, UseBasePrice = group.useBasePrice, Anchored = group.anchored, Anchorable = group.anchorable, FittableNonSingleton = group.fittableNonSingleton }; if (group.published.HasValue) { item.Published = group.published.Value; } if (group.categoryID.HasValue) { item.CategoryID = group.categoryID.Value; } collection.Items.Add(item); } return(collection.ToBag()); }
/// <summary> /// Checks whether all indices of the items are properly ordered. /// </summary> /// <typeparam name="T">An indexed, reference type.</typeparam> /// <param name="collection">The indexed collection to be checked.</param> private void CheckIndices <T>(IndexedCollection <T> collection) where T : class, IIndexed { for (var index = 0; index < collection.Count; index++) { Assert.AreEqual(index, collection[index].Index); } }
public async Task ShopRemove(int index) { index -= 1; if (index < 0) { return; } ShopEntry removed; using (var uow = _db.UnitOfWork) { var config = uow.GuildConfigs.ForId(Context.Guild.Id, set => set .Include(x => x.ShopEntries) .ThenInclude(x => x.Items)); var entries = new IndexedCollection <ShopEntry>(config.ShopEntries); removed = entries.ElementAtOrDefault(index); if (removed != null) { uow._context.RemoveRange(removed.Items); uow._context.Remove(removed); uow.Complete(); } } if (removed == null) { await ReplyErrorLocalizedAsync("shop_item_not_found").ConfigureAwait(false); } else { await Context.Channel.EmbedAsync(EntryToEmbed(removed) .WithTitle(GetText("shop_item_rm"))).ConfigureAwait(false); } }
internal IndexedCollection SwitchStack(int SlotID, VirtualConnection vConnection) { IndexedCollection iStack = null; List <int> AvailableStacks = null; while (true) { if (!SlotExist(SlotID)) { return(null); } if (vConnection.Cancelled) { return(null); } AvailableStacks = SmartStack(vConnection); if (AvailableStacks.Count == 0) { return(null); } foreach (int ServerID in AvailableStacks) { iStack = Stack(ServerID, SlotID); if (iStack != null) { return(iStack); } } } }
public async Task ShopAdd(Role _, int price, [Leftover] IRole role) { var entry = new ShopEntry() { Name = "-", Price = price, Type = ShopEntryType.Role, AuthorId = ctx.User.Id, RoleId = role.Id, RoleName = role.Name }; using (var uow = _db.GetDbContext()) { var entries = new IndexedCollection <ShopEntry>(uow.GuildConfigs.ForId(ctx.Guild.Id, set => set.Include(x => x.ShopEntries) .ThenInclude(x => x.Items)).ShopEntries) { entry }; uow.GuildConfigs.ForId(ctx.Guild.Id, set => set).ShopEntries = entries; uow.SaveChanges(); } await ctx.Channel.EmbedAsync(EntryToEmbed(entry) .WithTitle(GetText("shop_item_add"))).ConfigureAwait(false); }
public async Task ShopAdd(List _, int price, [Leftover] string name) { var entry = new ShopEntry() { Name = name.TrimTo(100), Price = price, Type = ShopEntryType.List, AuthorId = ctx.User.Id, Items = new HashSet <ShopEntryItem>(), }; using (var uow = _db.GetDbContext()) { var entries = new IndexedCollection <ShopEntry>(uow.GuildConfigs.ForId(ctx.Guild.Id, set => set.Include(x => x.ShopEntries) .ThenInclude(x => x.Items)).ShopEntries) { entry }; uow.GuildConfigs.ForId(ctx.Guild.Id, set => set).ShopEntries = entries; uow.SaveChanges(); } await ctx.Channel.EmbedAsync(EntryToEmbed(entry) .WithTitle(GetText("shop_item_add"))).ConfigureAwait(false); }
public Poll CreatePoll(ulong guildId, ulong channelId, string input) { if (string.IsNullOrWhiteSpace(input) || !input.Contains(";")) { return(null); } var data = input.Split(';'); if (data.Length < 3) { return(null); } var col = new IndexedCollection <PollAnswer>(data.Skip(1) .Select(x => new PollAnswer() { Text = x })); return(new Poll() { Answers = col, Question = data[0], ChannelId = channelId, GuildId = guildId, Votes = new System.Collections.Generic.HashSet <PollVote>() }); }
public async Task Shop(int page = 1) { if (--page < 0) { return; } var entries = new IndexedCollection <ShopEntry>(uow.GuildConfigs.For(Context.Guild.Id, set => set.Include(x => x.ShopEntries).ThenInclude(x => x.Items)).ShopEntries); const int elementsPerPage = 9; await Context.Channel.SendPaginatedConfirmAsync(Context.Client as DiscordSocketClient, page, currentPage => { var theseEntries = entries.Skip(currentPage *elementsPerPage).Take(elementsPerPage).ToArray(); if (!theseEntries.Any()) { return(new EmbedBuilder().WithErrorColor() .WithDescription(GetText("shop_none"))); } var embed = new EmbedBuilder().WithOkColor() .WithTitle(GetText("shop", _bc.BotConfig.CurrencySign)); for (var i = 0; i < theseEntries.Length; i++) { var entry = theseEntries[i]; embed.AddField(efb => efb.WithName($"#{currentPage * elementsPerPage + i + 1} - {entry.Price}{_bc.BotConfig.CurrencySign}").WithValue(EntryToString(entry)).WithIsInline(true)); } return(embed); }, (int)Math.Ceiling(entries.Count * 1d / elementsPerPage), reactUsers : new[] { Context.User as IGuildUser }); }
public void IndexedCollection_AddRange() { var collection = new IndexedCollection <int, TestObject>(t => t.Sequence); collection.AddRange(_objects); Assert.AreEqual(1000, collection.Count); }
/// <summary> /// Character Factions. /// </summary> /// <returns><c>BagCollection</c> of Character Factions.</returns> private static BagCollection <ChrFactions> Factions() { IndexedCollection <ChrFactions> collection = new IndexedCollection <ChrFactions>(); foreach (chrFactions faction in s_context.chrFactions) { ChrFactions item = new ChrFactions { ID = faction.factionID, FactionName = faction.factionName, Description = faction.description, MilitiaCorporationID = faction.militiaCorporationID, }; item.Description = item.Description.Clean(); if (faction.raceIDs.HasValue) { item.RaceID = faction.raceIDs.Value; } if (faction.solarSystemID.HasValue) { item.SolarSystemID = faction.solarSystemID.Value; } if (faction.corporationID.HasValue) { item.CorporationID = faction.corporationID.Value; } if (faction.sizeFactor.HasValue) { item.SizeFactor = faction.sizeFactor.Value; } // TODO - Fix these... if (faction.stationCount.HasValue) { item.StationCount = (short)faction.stationCount.Value; } if (faction.stationSystemCount.HasValue) { item.StationSystemCount = (short)faction.stationSystemCount.Value; } if (faction.iconID.HasValue) { item.IconID = faction.iconID.Value; } collection.Items.Add(item); } return(collection.ToBag()); }
public void IndexedCollection_Contains() { var collection = new IndexedCollection <int, TestObject>(t => t.Sequence); collection.Add(_objects[0]); Assert.AreEqual(true, collection.Contains(_objects[0])); Assert.AreEqual(false, collection.Contains(_objects[1])); }
protected override void Init_internal() { MultiIndexCollectionCellTree = new ObservableCollection <Cell>(); MultiIndexCollectionCellTreeIndex = new IndexedCollection <Cell>(MultiIndexCollectionCellTree) .IndexBy(cell => cell.MinX, true) .IndexBy(cell => cell.MaxX, true) .IndexBy(cell => cell.MinY, true) .IndexBy(cell => cell.MaxY, true); }
/// <summary> /// 已开通银行卡列表查询 /// </summary> /// <param name="customerId"></param> /// <returns></returns> public static string UnionAPI_OpenedData(string customerId) { com.ecc.emp.data.KeyedCollection input = new com.ecc.emp.data.KeyedCollection("input"); com.ecc.emp.data.KeyedCollection output = new com.ecc.emp.data.KeyedCollection("output"); input.put("masterId", SDKConfig.MasterID); //商户号,注意生产环境上要替换成商户自己的生产商户号 input.put("customerId", customerId); //会员号,商户自行生成 KeyedCollection recv = new KeyedCollection(); String businessCode = "UnionAPI_Opened"; String toOrig = input.toString().replace("\n", "").replace("\t", ""); String toUrl = SDKConfig.sdbUnionUrl + "UnionAPI_Opened.do"; output = NETExecute(businessCode, toOrig, toUrl); String errorCode = (String)output.getDataValue("errorCode"); String errorMsg = (String)output.getDataValue("errorMsg"); if ((errorCode == null || errorCode.Equals("")) && (errorMsg == null || errorMsg.Equals(""))) { //System.out.println("---订单状态---" + output.getDataValue("status")); //System.out.println("---支付完成时间---" + output.getDataValue("date")); String OpenId = null; String accNo = null; String plantBankName = null; String plantBankId = null; List <UnionBankModel> Mlist = new List <UnionBankModel>(); IndexedCollection icoll = (IndexedCollection)output.getDataElement("unionInfo"); for (int i = 0; i < icoll.size(); i++) { //取出index为i的一条记录,结构为KeyedCollection com.ecc.emp.data.KeyedCollection kcoll = (com.ecc.emp.data.KeyedCollection)icoll.getElementAt(i); OpenId = (String)kcoll.getDataValue("OpenId"); accNo = (String)kcoll.getDataValue("accNo"); plantBankName = (String)kcoll.getDataValue("plantBankName"); plantBankId = (String)kcoll.getDataValue("plantBankId"); UnionBankModel m = new UnionBankModel(); m.OpenId = OpenId; m.accNo = accNo; m.plantBankName = plantBankName; m.plantBankId = plantBankId; Mlist.Add(m); } return(DynamicJson.Serialize(Mlist)); // return output.getDataValue("status").toString(); } else { // System.out.println("---错误码---" + output.getDataValue("errorCode")); // System.out.println("---错误说明---" + output.getDataValue("errorMsg")); return(output.getDataValue("errorMsg").toString()); } return(output.toString()); }
public MultipleRecordIndex(IndexedCollection <T> sequence, Func <T, TKey> selector) : base(selector) { this.InnerDictionary = new ConcurrentDictionary <TKey, IList <T> >(); foreach (var element in sequence.InnerCollection) { this.TryAdd(element); } }
public void SetUp() { Collection = new IndexedCollection <string, int>(); Collection.SetKeyExpression((item) => { return(item.GetHashCode()); }); }
public void IndexedCollection_CopyToNullArray() { int count = 10; var collection = new IndexedCollection <int, TestObject>(t => t.Sequence); collection.AddRange(_objects.GetRange(0, count)); TestObject[] array = null; collection.CopyTo(array, 0); }
public void StringEqualityTest1() { Queries.Debug = true; Queries.TimesWasHere = 0; var collection = new IndexedCollection <StringTest>(k => k.Key) { new StringTest("1", "!"), new StringTest("2", "@"), }; }
public void IndexedCollection_Add() { var collection = new IndexedCollection <int, TestObject>(t => t.Sequence); collection.Add(_objects[0]); collection.Add(_objects[1]); Assert.AreEqual(2, collection.Count); Assert.AreEqual("Test0", collection[0].Name); Assert.AreEqual("Test1", collection[1].Name); }
public void SimpleTest2() { Queries.Debug = true; Queries.TimesWasHere = 0; var collection = new IndexedCollection<KeyValuePair<int, int>>(k => k.Key) { new KeyValuePair<int, int>(1, 3), new KeyValuePair<int, int>(5, 2), new KeyValuePair<int, int>(5, 3) }; var items = collection.Where(k => k.Key == 5 && k.Value == 3).ToArray(); Assert.AreEqual(1, Queries.TimesWasHere); Assert.AreEqual(1, items.Length); Assert.AreEqual(5, items[0].Key); Assert.AreEqual(3, items[0].Value); }
public void IndexedCollection_Remove() { int count = 10; var collection = new IndexedCollection <int, TestObject>(t => t.Sequence); collection.AddRange(_objects.GetRange(0, count)); Assert.AreEqual(true, collection.Remove(_objects[9])); Assert.AreEqual(false, collection.Remove(_objects[9])); Assert.AreEqual(count - 1, collection.Count); }
public void IndexedCollection_CopyToNotEnoughSpace() { int count = 10; var collection = new IndexedCollection <int, TestObject>(t => t.Sequence); collection.AddRange(_objects.GetRange(0, count)); var array = new TestObject[count]; collection.CopyTo(array, 1); }
public void TestMain() { var arr = new string[] { "three", "one", "two" }; var indices = new int[] { 1, 2, 0 }; var indexedCollection = new IndexedCollection<string>(arr, indices); Assert.IsTrue(indexedCollection[0] == "one"); Assert.IsTrue(indexedCollection[1] == "two"); Assert.IsTrue(indexedCollection[2] == "three"); }
public void TestMain() { var arr = new string[] { "three", "one", "two" }; var indices = new int[] { 1, 2, 0 }; var indexedCollection = new IndexedCollection <string>(arr, indices); Assert.IsTrue(indexedCollection[0] == "one"); Assert.IsTrue(indexedCollection[1] == "two"); Assert.IsTrue(indexedCollection[2] == "three"); }
public void IndexedCollection_Clear() { var collection = new IndexedCollection <int, TestObject>(t => t.Sequence); collection.Add(_objects[0]); collection.Add(_objects[1]); Assert.AreEqual(2, collection.Count); collection.Clear(); Assert.AreEqual(0, collection.Count); }
private void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { _collection = null; } _disposed = true; }
public void SimpleTest1() { Queries.Debug = true; Queries.TimesWasHere = 0; var collection = new IndexedCollection <KeyValuePair <int, int> >(k => k.Key) { new KeyValuePair <int, int>(1, 3), new KeyValuePair <int, int>(5, 2) }; var items = collection.Where(k => k.Key == 5).ToArray(); Assert.AreEqual(1, Queries.TimesWasHere); Assert.AreEqual(1, items.Length); Assert.AreEqual(2, items[0].Value); }
public void Should_use_indices_to_improve_query_performance() { IndexedCollection<IndexedClass> collection = new IndexedCollection<IndexedClass>(); collection.Add(new IndexedClass {Name = "Chris"}); collection.Add(new IndexedClass {Name = "David"}); collection.Add(new IndexedClass {Name = "Jason"}); collection.Add(new IndexedClass {Name = "Matt"}); collection.Add(new IndexedClass {Name = "Terry"}); collection.Add(new IndexedClass {Name = "Zach"}); var result = collection.Where(x => x.Name == "Matt").First(); Assert.AreEqual("Matt", result.Name); }
public void SimpleTest5() { Queries.Debug = true; Queries.TimesWasHere = 0; var collection = new IndexedCollection<KeyValuePair<object, int>>(k => k.Key) { new KeyValuePair<object, int>(0, 3), new KeyValuePair<object, int>(null, 2), new KeyValuePair<object, int>(5, 3) }; int v = 5; var items = collection.Where(k => k.Key != null && (int)k.Key == v && k.Value == 3).ToArray(); // Assert.AreEqual(1, Queries.TimesWasHere); Assert.AreEqual(1, items.Length); Assert.AreEqual(5, items[0].Key); Assert.AreEqual(3, items[0].Value); // Assert.Fail("Пока не проходит"); }
/// <summary> /// Certificate Classes. /// </summary> /// <returns><c>BagCollection</c> of Classes of Certificate.</returns> private static BagCollection<CrtClasses> CertificateClasses() { IndexedCollection<CrtClasses> collection = new IndexedCollection<CrtClasses>(); foreach (CrtClasses item in s_context.crtClasses.Select( crtClass => new CrtClasses { ID = crtClass.classID, ClassName = crtClass.className, Description = crtClass.description })) { item.Description = item.Description.Clean(); collection.Items.Add(item); } CertificatesTotalCount *= collection.Items.Count(); return collection.ToBag(); }
/// <summary> /// Map Regions. /// </summary> /// <returns><c>BagCollection</c> of Map Regions.</returns> /// <remarks>Regions in the EVE Universe.</remarks> private static BagCollection<MapRegions> Regions() { IndexedCollection<MapRegions> collection = new IndexedCollection<MapRegions>(); foreach (MapRegions item in s_context.mapRegions.Select( region => new MapRegions { ID = region.regionID, Name = region.regionName, FactionID = region.factionID })) { collection.Items.Add(item); } GeographyTotalCount = collection.Items.Count; return collection.ToBag(); }
/// <summary> /// Inventory Types. /// </summary> /// <returns><c>BagCollection</c> of items from the Inventory.</returns> private static BagCollection<InvTypes> Types() { IndexedCollection<InvTypes> collection = new IndexedCollection<InvTypes>(); foreach (invTypes type in s_context.invTypes) { InvTypes item = new InvTypes { ID = type.typeID, Description = type.description, MarketGroupID = type.marketGroupID, Name = type.typeName, RaceID = type.raceID }; item.Description = item.Description.Clean(); if (type.basePrice.HasValue) item.BasePrice = type.basePrice.Value; if (type.capacity.HasValue) item.Capacity = type.capacity.Value; if (type.groupID.HasValue) item.GroupID = type.groupID.Value; if (type.mass.HasValue) item.Mass = type.mass.Value; if (type.published.HasValue) item.Published = type.published.Value; if (type.volume.HasValue) item.Volume = type.volume.Value; if (type.portionSize.HasValue) item.PortionSize = type.portionSize.Value; collection.Items.Add(item); } // Set items total count ItemsTotalCount = ReprocessingTotalCount = collection.Items.Count; // Set skills total count SkillsTotalCount = collection.Items.Count( item => item.GroupID != DBConstants.FakeSkillsGroupID && InvGroupsTable[item.GroupID].CategoryID == DBConstants.SkillCategoryID); return collection.ToBag(); }
/// <summary> /// Agent Agent Types. /// </summary> /// <returns><c>BagCollection</c> of Agent Agent Types.</returns> private static BagCollection<AgtAgentTypes> AgentTypes() { IndexedCollection<AgtAgentTypes> collection = new IndexedCollection<AgtAgentTypes>(); foreach (AgtAgentTypes item in s_context.agtAgentTypes.Select( agentType => new AgtAgentTypes { ID = agentType.agentTypeID, AgentType = agentType.agentType })) { collection.Items.Add(item); } return collection.ToBag(); }
/// <summary> /// Station Stations. /// </summary> /// <returns><c>BagCollection</c> of Station Stations.</returns> /// <remarks>Stations in the EVE Universe.</remarks> private static BagCollection<StaStations> Stations() { IndexedCollection<StaStations> collection = new IndexedCollection<StaStations>(); foreach (staStations station in s_context.staStations) { StaStations item = new StaStations { ID = station.stationID, Name = station.stationName, }; if (station.reprocessingEfficiency.HasValue) item.ReprocessingEfficiency = (float)station.reprocessingEfficiency.Value; if (station.reprocessingStationsTake.HasValue) item.ReprocessingStationsTake = (float)station.reprocessingStationsTake.Value; if (station.security.HasValue) item.SecurityLevel = station.security.Value; if (station.solarSystemID.HasValue) item.SolarSystemID = station.solarSystemID.Value; if (station.corporationID.HasValue) item.CorporationID = station.corporationID.Value; collection.Items.Add(item); } return collection.ToBag(); }
/// <summary> /// EVE Icons. /// </summary> /// <returns><c>BagCollection</c> of EVE icons.</returns> private static BagCollection<EveIcons> Icons() { IndexedCollection<EveIcons> collection = new IndexedCollection<EveIcons>(); foreach (EveIcons item in s_context.eveIcons.Select( icon => new EveIcons { ID = icon.iconID, Icon = icon.iconFile })) { collection.Items.Add(item); } return collection.ToBag(); }
/// <summary> /// Character Factions. /// </summary> /// <returns><c>BagCollection</c> of Character Factions.</returns> private static BagCollection<ChrFactions> Factions() { IndexedCollection<ChrFactions> collection = new IndexedCollection<ChrFactions>(); foreach (chrFactions faction in s_context.chrFactions) { ChrFactions item = new ChrFactions { ID = faction.factionID, FactionName = faction.factionName, Description = faction.description, MilitiaCorporationID = faction.militiaCorporationID, }; item.Description = item.Description.Clean(); if (faction.raceIDs.HasValue) item.RaceID = faction.raceIDs.Value; if (faction.solarSystemID.HasValue) item.SolarSystemID = faction.solarSystemID.Value; if (faction.corporationID.HasValue) item.CorporationID = faction.corporationID.Value; if (faction.sizeFactor.HasValue) item.SizeFactor = faction.sizeFactor.Value; if (faction.stationCount.HasValue) item.StationCount = faction.stationCount.Value; if (faction.stationSystemCount.HasValue) item.StationSystemCount = faction.stationSystemCount.Value; if (faction.iconID.HasValue) item.IconID = faction.iconID.Value; collection.Items.Add(item); } return collection.ToBag(); }
internal void Initialize(IEnumerable<ResourceQuerier> queriers) { _cachedQueries = new IndexedCollection<Query>(k => k.ResourceKey, k => k.Namespace, k => k.ArgCount, k=>k.Arguments); _baseQueries = new IndexedCollection<Query>(k => k.ResourceKey, k => k.Namespace, k => k.ArgCount, k => k.Arguments); _baseQueries.AddRange(queriers.SelectMany(q => q.ReturnQueries())); }
/// <summary> /// EVE Units. /// </summary> /// <returns><c>BagCollection</c> of EVE Units.</returns> private static BagCollection<EveUnits> Units() { IndexedCollection<EveUnits> collection = new IndexedCollection<EveUnits>(); foreach (EveUnits item in s_context.eveUnits.Select( unit => new EveUnits { Description = unit.description, DisplayName = unit.displayName, ID = unit.unitID, Name = unit.unitName })) { item.Description = item.Description.Clean(); item.DisplayName = item.DisplayName.Clean(); collection.Items.Add(item); } return collection.ToBag(); }
/// <summary> /// Inventory Blueprint Types. /// </summary> /// <returns><c>BagCollection</c> of Inventory Blueprint Types.</returns> private static BagCollection<InvBlueprintTypes> BlueprintTypes() { IndexedCollection<InvBlueprintTypes> collection = new IndexedCollection<InvBlueprintTypes>(); foreach (invBlueprintTypes blueprint in s_context.invBlueprintTypes) { InvBlueprintTypes item = new InvBlueprintTypes { ID = blueprint.blueprintTypeID, ParentID = blueprint.parentBlueprintTypeID, }; if (blueprint.productTypeID.HasValue) item.ProductTypeID = blueprint.productTypeID.Value; if (blueprint.productionTime.HasValue) item.ProductionTime = blueprint.productionTime.Value; if (blueprint.techLevel.HasValue) item.TechLevel = blueprint.techLevel.Value; if (blueprint.researchProductivityTime.HasValue) item.ResearchProductivityTime = blueprint.researchProductivityTime.Value; if (blueprint.researchMaterialTime.HasValue) item.ResearchMaterialTime = blueprint.researchMaterialTime.Value; if (blueprint.researchCopyTime.HasValue) item.ResearchCopyTime = blueprint.researchCopyTime.Value; if (blueprint.researchTechTime.HasValue) item.ResearchTechTime = blueprint.researchTechTime.Value; if (blueprint.duplicatingTime.HasValue) item.DuplicatingTime = blueprint.duplicatingTime.Value; if (blueprint.reverseEngineeringTime.HasValue) item.ReverseEngineeringTime = blueprint.reverseEngineeringTime.Value; if (blueprint.inventionTime.HasValue) item.InventionTime = blueprint.inventionTime.Value; if (blueprint.productivityModifier.HasValue) item.ProductivityModifier = blueprint.productivityModifier.Value; if (blueprint.wasteFactor.HasValue) item.WasteFactor = blueprint.wasteFactor.Value; if (blueprint.maxProductionLimit.HasValue) item.MaxProductionLimit = blueprint.maxProductionLimit.Value; collection.Items.Add(item); } BlueprintsTotalCount = collection.Items.Count; return collection.ToBag(); }
public void AdvancedTest1() { Queries.Debug = true; Queries.TimesWasHere = 0; var collection = new IndexedCollection<TimeRange>(k => k.Value,k=>k.EndTime - k.StartTime) { new TimeRange(new DateTime(2012,2,1),new DateTime(2012,2,2), 4 ), new TimeRange(new DateTime(2012,2,3),new DateTime(2012,2,4), 5 ), new TimeRange(new DateTime(2012,2,4),new DateTime(2012,2,5), 6 ), new TimeRange(new DateTime(2012,2,2),new DateTime(2012,2,6), 7 ), new TimeRange(new DateTime(2012,2,2),new DateTime(2012,2,8), 8 ), new TimeRange(new DateTime(2012,2,5),new DateTime(2012,2,10),9 ), new TimeRange(new DateTime(2012,2,4),new DateTime(2012,2,9), 10 ), new TimeRange(new DateTime(2012,2,2),new DateTime(2012,2,3), 11 ), new TimeRange(new DateTime(2012,2,8),new DateTime(2012,2,10), 12 ), }; var items = collection.Where( k => k.Value == 4 || k.StartTime == new DateTime(2012, 2, 2)).ToArray(); Assert.AreEqual(0, Queries.TimesWasHere); Assert.AreEqual(4, items.Length); Queries.TimesWasHere = 0; items = collection.Where( k => k.Value == 4 && k.EndTime == new DateTime(2012, 2, 2)).ToArray(); Assert.AreEqual(1, Queries.TimesWasHere); Assert.AreEqual(1, items.Length); Assert.AreEqual(4, items[0].Value); Queries.TimesWasHere = 0; items = collection.Where( k => k.Value == 5 && k.StartTime != new DateTime(2012, 2, 3)).ToArray(); Assert.AreEqual(1, Queries.TimesWasHere); Assert.AreEqual(1, items.Length); Queries.TimesWasHere = 0; items = collection.Where( k => k.EndTime - k.StartTime == TimeSpan.FromDays(1)).ToArray(); Assert.AreEqual(1, Queries.TimesWasHere); Assert.AreEqual(4, items.Length); }
public void StringEqualityTest1() { Queries.Debug = true; Queries.TimesWasHere = 0; var collection = new IndexedCollection<StringTest>(k => k.Key) { new StringTest("1", "!"), new StringTest("2", "@"), }; }
/// <summary> /// Certificate Certificates. /// </summary> /// <returns><c>BagCollection</c> of Certificates.</returns> private static BagCollection<CrtCertificates> Certificates() { IndexedCollection<CrtCertificates> collection = new IndexedCollection<CrtCertificates>(); foreach (crtCertificates certificate in s_context.crtCertificates) { CrtCertificates item = new CrtCertificates { ID = certificate.certificateID, Description = certificate.description }; item.Description = item.Description.Clean(); if (certificate.groupID.HasValue) item.GroupID = certificate.groupID.Value; if (certificate.classID.HasValue) item.ClassID = certificate.classID.Value; if (certificate.grade.HasValue) item.Grade = certificate.grade.Value; collection.Items.Add(item); } CertificatesTotalCount = collection.Items.Select(x => x.GroupID).Distinct().Count(); return collection.ToBag(); }
/// <summary> /// Dogma Traits. /// </summary> /// <returns></returns> private static BagCollection<DgmTraits> Traits() { IndexedCollection<DgmTraits> collection = new IndexedCollection<DgmTraits>(); foreach (DgmTraits item in s_context.dgmTraits.Select( trait => new DgmTraits { ID = trait.traitID, BonusText = trait.bonusText, UnitID = trait.unitID })) { item.BonusText = item.BonusText.Clean(); collection.Items.Add(item); } return collection.ToBag(); }
/// <summary> /// Corporation NPC Divisions. /// </summary> /// <returns><c>BagCollection</c> of Corporation NPC Divisions.</returns> private static BagCollection<CrpNPCDivisions> NPCDivisions() { IndexedCollection<CrpNPCDivisions> collection = new IndexedCollection<CrpNPCDivisions>(); foreach (CrpNPCDivisions item in s_context.crpNPCDivisions.Select( npcDivision => new CrpNPCDivisions { ID = npcDivision.divisionID, DivisionName = npcDivision.divisionName })) { collection.Items.Add(item); } return collection.ToBag(); }
/// <summary> /// Dogma Masteries. /// </summary> /// <returns></returns> private static BagCollection<DgmMasteries> Masteries() { IndexedCollection<DgmMasteries> collection = new IndexedCollection<DgmMasteries>(); foreach (DgmMasteries item in s_context.dgmMasteries.Select( mastery => new DgmMasteries { ID = mastery.masteryID, CertificateID = mastery.certificateID, Grade = mastery.grade, })) { collection.Items.Add(item); } return collection.ToBag(); }
/// <summary> /// Agent Research Agents. /// </summary> /// <returns><c>BagCollection</c> of Agent Research Agents.</returns> private static BagCollection<AgtResearchAgents> ResearchAgents() { IndexedCollection<AgtResearchAgents> collection = new IndexedCollection<AgtResearchAgents>(); foreach (AgtResearchAgents item in s_context.agtResearchAgents.Select( researchAgent => new AgtResearchAgents { ID = researchAgent.agentID, ResearchSkillID = researchAgent.typeID })) { collection.Items.Add(item); } return collection.ToBag(); }
/// <summary> /// Dogma Attribute Types. /// </summary> /// <returns><c>BagCollection</c> of Dogma Attribute Types.</returns> private static BagCollection<DgmAttributeTypes> AttributeTypes() { IndexedCollection<DgmAttributeTypes> collection = new IndexedCollection<DgmAttributeTypes>(); foreach (dgmAttributeTypes attribute in s_context.dgmAttributeTypes) { DgmAttributeTypes item = new DgmAttributeTypes { ID = attribute.attributeID, CategoryID = attribute.categoryID, Description = attribute.description, DisplayName = attribute.displayName, IconID = attribute.iconID, Name = attribute.attributeName, UnitID = attribute.unitID, }; item.Description = item.Description.Clean(); item.DisplayName = item.DisplayName.Clean(); item.Name = item.Name.Clean(); if (attribute.defaultValue.HasValue) item.DefaultValue = attribute.defaultValue.Value.ToString(CultureInfo.InvariantCulture); if (attribute.published.HasValue) item.Published = attribute.published.Value; if (attribute.highIsGood.HasValue) item.HigherIsBetter = attribute.highIsGood.Value; collection.Items.Add(item); } // Set properties total count PropertiesTotalCount = collection.Items.Count; return collection.ToBag(); }
/// <summary> /// Agent Agents. /// </summary> /// <returns><c>BagCollection</c> of Agent Agents.</returns> private static BagCollection<AgtAgents> Agents() { IndexedCollection<AgtAgents> collection = new IndexedCollection<AgtAgents>(); foreach (agtAgents agent in s_context.agtAgents) { AgtAgents item = new AgtAgents { ID = agent.agentID, }; if (agent.divisionID.HasValue) item.DivisionID = agent.divisionID.Value; if (agent.locationID.HasValue) item.LocationID = agent.locationID.Value; if (agent.level.HasValue) item.Level = agent.level.Value; if (agent.quality.HasValue) item.Quality = agent.quality.Value; if (agent.agentTypeID.HasValue) item.AgentTypeID = agent.agentTypeID.Value; if (agent.isLocator.HasValue) item.IsLocator = agent.isLocator.Value; collection.Items.Add(item); } return collection.ToBag(); }
/// <summary> /// Dogma Attribute categories. /// </summary> /// <returns><c>BagCollection</c> of Dogma Attribute Categories.</returns> private static BagCollection<DgmAttributeCategories> AttributeCategories() { IndexedCollection<DgmAttributeCategories> collection = new IndexedCollection<DgmAttributeCategories>(); foreach (DgmAttributeCategories item in s_context.dgmAttributeCategories.Select( category => new DgmAttributeCategories { ID = category.categoryID, Description = category.categoryDescription, Name = category.categoryName })) { item.Description = item.Description.Clean(); item.Name = item.Name.Clean(); collection.Items.Add(item); } return collection.ToBag(); }
/// <summary> /// Map Solar Systems. /// </summary> /// <returns><c>BagCollection</c> of Map Solar Systems.</returns> private static BagCollection<MapSolarSystems> SolarSystems() { IndexedCollection<MapSolarSystems> collection = new IndexedCollection<MapSolarSystems>(); foreach (mapSolarSystems solarsystem in s_context.mapSolarSystems) { MapSolarSystems item = new MapSolarSystems { ID = solarsystem.solarSystemID, Name = solarsystem.solarSystemName }; if (solarsystem.constellationID.HasValue) item.ConstellationID = solarsystem.constellationID.Value; if (solarsystem.security.HasValue) item.SecurityLevel = (float)solarsystem.security.Value; if (solarsystem.x.HasValue) item.X = solarsystem.x.Value; if (solarsystem.y.HasValue) item.Y = solarsystem.y.Value; if (solarsystem.z.HasValue) item.Z = solarsystem.z.Value; collection.Items.Add(item); } return collection.ToBag(); }
/// <summary> /// Certificate Relationships. /// </summary> /// <returns><c>BagCollection</c> of parent-child relationships between certificates.</returns> private static BagCollection<CrtRelationships> CertificateRelationships() { IndexedCollection<CrtRelationships> collection = new IndexedCollection<CrtRelationships>(); foreach (crtRelationships relationship in s_context.crtRelationships) { CrtRelationships item = new CrtRelationships { ID = relationship.relationshipID, ParentID = relationship.parentID, }; if (relationship.parentLevel.HasValue) item.ParentLevel = relationship.parentLevel.Value; if (relationship.parentTypeID.HasValue) item.ParentTypeID = relationship.parentTypeID.Value; if (relationship.childID.HasValue) item.ChildID = relationship.childID.Value; if (relationship.grade.HasValue) item.Grade = relationship.grade.Value; collection.Items.Add(item); } return collection.ToBag(); }
/// <summary> /// Map Constellations. /// </summary> /// <returns><c>BagCollection</c> of Map Constellations.</returns> /// <remarks>Constallations in the EVE Universe.</remarks> private static BagCollection<MapConstellations> Constellations() { IndexedCollection<MapConstellations> collection = new IndexedCollection<MapConstellations>(); foreach (mapConstellations constellation in s_context.mapConstellations) { MapConstellations item = new MapConstellations { ID = constellation.constellationID, Name = constellation.constellationName, }; if (constellation.regionID.HasValue) item.RegionID = constellation.regionID.Value; collection.Items.Add(item); } return collection.ToBag(); }
/// <summary> /// Certificate Recommendations. /// </summary> /// <returns><c>BagCollection</c> of Certificate Recommendations.</returns> private static BagCollection<CrtRecommendations> CertificateRecommendations() { IndexedCollection<CrtRecommendations> collection = new IndexedCollection<CrtRecommendations>(); foreach (crtRecommendations recommendation in s_context.crtRecommendations) { CrtRecommendations item = new CrtRecommendations { ID = recommendation.recommendationID, Level = recommendation.recommendationLevel, }; if (recommendation.certificateID.HasValue) item.CertificateID = recommendation.certificateID.Value; if (recommendation.shipTypeID.HasValue) item.ShipTypeID = recommendation.shipTypeID.Value; collection.Items.Add(item); } return collection.ToBag(); }
public void SimpleTest6() { Queries.Debug = true; Queries.TimesWasHere = 0; Func<KeyValuePair<int, int>, int> counter = k => k.Key + k.Value; var collection = new IndexedCollection<KeyValuePair<int, int>>(k=>counter(k)) { new KeyValuePair<int, int>(0, 3), new KeyValuePair<int, int>(2, 2), new KeyValuePair<int, int>(5, 3) }; var items = collection.Where(k => counter(k) == 4).ToArray(); Assert.AreEqual(1, Queries.TimesWasHere); Assert.AreEqual(1, items.Length); Assert.AreEqual(2, items[0].Key); Assert.AreEqual(2, items[0].Value); }
/// <summary> /// Inventory Names. /// </summary> /// <returns><c>BagCollection</c> of Inventory Names.</returns> private static BagCollection<InvNames> Names() { IndexedCollection<InvNames> collection = new IndexedCollection<InvNames>(); foreach (InvNames item in s_context.invNames.Select( name => new InvNames { ID = (int)name.itemID, Name = name.itemName })) { collection.Items.Add(item); } return collection.ToBag(); }