protected override System.Collections.Generic.IEnumerable <IFightResult> GenerateResults() { System.Collections.Generic.List <IFightResult> list = new System.Collections.Generic.List <IFightResult>(); list.AddRange( from entry in base.GetFightersAndLeavers() where !(entry is SummonedFighter) select entry.GetFightResult()); if (base.Map.TaxCollector != null && base.Map.TaxCollector.CanGatherLoots()) { list.Add(new TaxCollectorFightResult(base.Map.TaxCollector, this)); } FightTeam[] teams = this.m_teams; for (int i = 0; i < teams.Length; i++) { FightTeam team = teams[i]; System.Collections.Generic.IEnumerable <FightActor> enumerable = ((team == base.RedTeam) ? base.BlueTeam : base.RedTeam).GetAllFighters((FightActor entry) => entry.IsDead()).ToList <FightActor>(); IOrderedEnumerable <IFightResult> orderedEnumerable = from x in list where x.CanLoot(team) select x into entry orderby(entry is TaxCollectorFightResult) ? -1 : entry.Prospecting descending select entry; int teamPP = team.GetAllFighters().Sum((FightActor entry) => entry.Stats[PlayerFields.Prospecting].Total); int challengeSum = base.m_challenges.Sum((entry => entry.GetChallengeBonus())); long baseKamas = enumerable.Sum((FightActor entry) => (long)((ulong)entry.GetDroppedKamas())); using (System.Collections.Generic.IEnumerator <IFightResult> enumerator = orderedEnumerable.GetEnumerator()) { while (enumerator.MoveNext()) { IFightResult looter = enumerator.Current; looter.Loot.Kamas = FightFormulas.AdjustDroppedKamas(looter, teamPP, baseKamas); System.Collections.Generic.IEnumerable <FightActor> arg_1F0_0 = enumerable; Func <FightActor, System.Collections.Generic.IEnumerable <DroppedItem> > selector = (FightActor dropper) => dropper.RollLoot(looter, challengeSum); foreach (DroppedItem current in arg_1F0_0.SelectMany(selector)) { looter.Loot.AddItem(current); } if (looter is IExperienceResult) { (looter as IExperienceResult).AddEarnedExperience(FightFormulas.CalculateWinExp(looter, team.GetAllFighters(), enumerable)); } } } } return(list); }
/// <summary> /// Gets the deliveries ordered by profit. /// </summary> /// <param name="itemsForCurrentStation">The items for current station.</param> /// <param name="itemsForOtherStations">The items for other stations.</param> /// <param name="cargoSpace">The cargo space.</param> /// <param name="taxRate">The tax rate.</param> /// <returns></returns> private static System.Collections.Generic.IEnumerable <Delivery> GetDeliveriesOrderedByProfit(System.Collections.Generic.IEnumerable <Item> itemsForCurrentStation, System.Collections.Generic.IEnumerable <Item> itemsForOtherStations, ushort cargoSpace, decimal taxRate) { decimal taxRateRounded = Math.Round(taxRate, 4); var deliveries = itemsForCurrentStation.SelectMany( itemForCurrentStation => itemsForOtherStations.Where(itemForOtherStation => itemForCurrentStation.Id == itemForOtherStation.Id && !itemForCurrentStation.StationName.Equals(itemForOtherStation.StationName)).Select(itemForOtherStation => new Delivery(itemForCurrentStation, itemForOtherStation, Math.Min(cargoSpace, itemForCurrentStation.Amount), taxRateRounded))); var deliveriesOrderedByProfit = deliveries.OrderByDescending(delivery => delivery.Profit); return(deliveriesOrderedByProfit); }
private static System.Collections.Generic.IReadOnlyList <XElement> ReadAdditionalPropertyGroups(System.Collections.Generic.IEnumerable <XElement> propertyGroups) { var additionalPropertyGroups = propertyGroups.Where(x => x.Attribute("Condition") != null).ToList(); var versionControlElements = propertyGroups .SelectMany(x => x.Elements().Where(e => e.Name.LocalName.StartsWith("Scc"))) .ToArray(); if (versionControlElements != null) { additionalPropertyGroups.Add(new XElement("PropertyGroup", versionControlElements)); } return(additionalPropertyGroups); }
public static ScriptLoader GetLoader() { if (scriptLoaderCached) { return(cachedScriptLoader); } scriptLoaderCached = true; System.Collections.Generic.IEnumerable <Type> allTypes = null; try { allTypes = Assembly.Load("Assembly-CSharp").GetTypes().AsEnumerable(); } catch { } try { var typesInPlugins = Assembly.Load("Assembly-CSharp-firstpass").GetTypes(); if (allTypes != null) { allTypes = allTypes.Union(typesInPlugins); } else { allTypes = typesInPlugins; } } catch { } if (allTypes == null) { Config.LogError("ScritpLoader not found!"); return(null); } var methods = allTypes.SelectMany(t => t.GetMethods(BindingFlags.Static | BindingFlags.Public)) .Where(m => m.GetCustomAttributes(typeof(LuaScriptLoaderAttribute), false).Length > 0) .ToArray(); if (methods.Length > 0) { var m = methods[0]; cachedScriptLoader = (ScriptLoader)Delegate.CreateDelegate(typeof(ScriptLoader), m); } return(cachedScriptLoader); }
public Task <ClaimsPrincipal> TransformAsync(ClaimsPrincipal principal) { System.Collections.Generic.IEnumerable <Claim> customClaims = principal.Claims.Where(c => _sourceClaimType.Equals(c.Type, StringComparison.OrdinalIgnoreCase)); System.Collections.Generic.IEnumerable <Claim> roleClaims = customClaims.SelectMany(c => { return(c.Value.Split(' ').Select(s => new Claim(_roleType, s))); }); if (!roleClaims.Any()) { return(Task.FromResult(principal)); } ClaimsPrincipal transformed = new ClaimsPrincipal(principal); ClaimsIdentity rolesIdentity = new ClaimsIdentity(roleClaims, _authType, null, _roleType); transformed.AddIdentity(rolesIdentity); return(Task.FromResult(transformed)); }
public async ValueTask ReturnAllStudentsSpecificationWithIncludesToLoginAndSessionAndCourse() { const string dbName = "FakeDatabase"; using (TrainingDb dbContext = this.testFixture.CreateInMemoryDbContext(dbName)) { dbContext.Database.EnsureCreated(); var repo = new StudentRepository(dbContext); var specification = new AllStudentsSpecification(); System.Collections.Generic.IEnumerable <Student> allStudents = await repo.ListAsync(specification .Including(st => st.Login)); allStudents.All(student => specification.Test(student)).Should().BeTrue(); allStudents.Should().HaveCount(3); allStudents.Select(st => st.Login) .Should().NotBeNull(); allStudents.Select(st => st.Sessions) .Should().NotBeNull(); allStudents.SelectMany(st => st.Sessions) .Select(ss => ss.Session) .Select(s => s.Course).Should().NotBeNull(); foreach (Student student in allStudents) { student.Login.Should().NotBeNull(); student.Sessions.Should().NotBeNull(); foreach (StudentSession session in student.Sessions) { session.Session.Should().NotBeNull(); session.Session.Course.Should().NotBeNull(); } } } }
private async Task <Document> IncreaseVisibility(Document document, SyntaxNode node, CancellationToken cancellationToken) { DocumentEditor editor = await DocumentEditor.CreateAsync(document, cancellationToken).ConfigureAwait(false); SemanticModel model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); SyntaxNode declaration = editor.Generator.GetDeclaration(node); ISymbol symbol = editor.SemanticModel.GetDeclaredSymbol(node); System.Collections.Generic.IEnumerable <INamedTypeSymbol> ancestorTypes = symbol?.ContainingType?.GetBaseTypes() ?? Enumerable.Empty <INamedTypeSymbol>(); System.Collections.Generic.IEnumerable <ISymbol> hiddenOrOverriddenMembers = ancestorTypes.SelectMany(t => t.GetMembers(symbol.Name)); // Check if a public member was overridden if (hiddenOrOverriddenMembers.Any(s => s.DeclaredAccessibility == Accessibility.Public)) { IncreaseVisibility(editor, declaration, Accessibility.Public); return(editor.GetChangedDocument()); } // Otherwise, check if a protected or internal member was overridden if (hiddenOrOverriddenMembers.Any(s => s.DeclaredAccessibility == Accessibility.ProtectedOrInternal)) { IncreaseVisibility(editor, declaration, Accessibility.ProtectedOrInternal); return(editor.GetChangedDocument()); } // Otherwise, check if a protected member was overridden if (hiddenOrOverriddenMembers.Any(s => s.DeclaredAccessibility == Accessibility.Protected)) { IncreaseVisibility(editor, declaration, Accessibility.Protected); return(editor.GetChangedDocument()); } // Otherwise, make no change return(document); }
private void CheckForDecreasedVisibility(SymbolAnalysisContext context) { ISymbol symbol = context.Symbol; // Only look for methods hiding others (not overriding). Overriding with a different visibility is already a compiler error if (symbol.IsOverride) { return; } // Bail out if the member is publicly accessible, or sealed, or on a sealed type if (IsVisibleOutsideAssembly(symbol) || symbol.IsSealed || (symbol.ContainingType?.IsSealed ?? true)) { return; } // Event accessors cannot have visibility modifiers, so don't analyze them if ((symbol as IMethodSymbol)?.AssociatedSymbol as IEventSymbol != null) { return; } // Find members on base types that share the member's name System.Collections.Generic.IEnumerable <INamedTypeSymbol> ancestorTypes = symbol?.ContainingType?.GetBaseTypes() ?? Enumerable.Empty <INamedTypeSymbol>(); System.Collections.Generic.IEnumerable <ISymbol> hiddenOrOverriddenMembers = ancestorTypes.SelectMany(t => t.GetMembers(symbol.Name)); if (hiddenOrOverriddenMembers.Any(IsVisibleOutsideAssembly)) { context.ReportDiagnostic(symbol.CreateDiagnostic(Rule)); } }