/// <summary> /// Generates a message saying that the constructor is ambiguous. /// </summary> /// <param name="context">The context.</param> /// <param name="bestDirectives">The best constructor directives.</param> /// <returns>The exception message.</returns> public static string ConstructorsAmbiguous(IContext context, IGrouping<int, ConstructorInjectionDirective> bestDirectives) { using (var sw = new StringWriter()) { sw.WriteLine("Error activating {0} using {1}", context.Request.Service.Format(), context.Binding.Format(context)); sw.WriteLine("Several constructors have the same priority. Please specify the constructor using ToConstructor syntax or add an Inject attribute."); sw.WriteLine(); sw.WriteLine("Constructors:"); foreach (var constructorInjectionDirective in bestDirectives) { FormatConstructor(constructorInjectionDirective.Constructor, sw); } sw.WriteLine(); sw.WriteLine("Activation path:"); sw.WriteLine(context.Request.FormatActivationPath()); sw.WriteLine("Suggestions:"); sw.WriteLine(" 1) Ensure that the implementation type has a public constructor."); sw.WriteLine(" 2) If you have implemented the Singleton pattern, use a binding with InSingletonScope() instead."); return sw.ToString(); } }
/// <summary> /// Create a machine with the given SSAM Group /// </summary> /// <param name="machine"></param> public MachineEditorVm(IGrouping<Model.Machine, Model.StateStationActivityMachine> machine) { _group = machine; MachineId = machine.Key.Id; Name = machine.Key.Name; Code = machine.Key.Code; }
public ConvertEndsFacade(IGrouping<double, PanelBlRefExport> itemLefEndsByY, bool isLeftSide, ConvertPanelService cps) { this.itemLefEndsByY = itemLefEndsByY; this.sideName = isLeftSide ? "левый" : "правый"; this.isLeftSide = isLeftSide; CPS = cps; }
private static DeptWiseAttendanceDTO CreateAttendanceDTO(IGrouping<int, ActivityLogDTO> grp, IEnumerable<Employee> allEmployees) { var deptMembers = allEmployees.Where(e => e.Deprtment.Id == grp.First().Department.Id); var dto = new DeptWiseAttendanceDTO { DepartmentName = grp.First().Department.Name, Attendance = grp.GroupBy(gd => gd.Employee.Id) .Select(empGroup => new AttendanceDTO { EmployeeName = empGroup.First().Employee.Name, EmployeeId = empGroup.First().Employee.Id, Attended = true, Date = empGroup.First().TimeStamp.ToString("yyyy-MM-dd") }) .ToList() }; var absents = deptMembers.Where(m => !dto.Attendance.Any(a => a.EmployeeId == m.Id)); var date = dto.Attendance.First().Date; dto.Attendance.AddRange(absents.Select(a => new AttendanceDTO { EmployeeName = a.Name, EmployeeId = a.Id, Attended = false, Date = date })); return dto; }
public void TestData() { var customers = new List<Company> { // Dupe 1 contains matches of type A and C new Company(1, "Company A", "123 London Street", "WN1 0PG", "phone1"), // new Company(2, "Company A", "123, London St", "WN1 0PG", "phone5"), // ------------------------------------------------------ new Company(3, "Company A", "123, London St", "Different Postcode", "phone1"), // Dupe 2 contains a D match new Company(4, "Ej Snell & Sons Ltd", "80 London Street", "WN1 0PG", "phone2"), new Company(5, "E J Snell & Son Ltd", "88 London Street", "WN1 0PG", "phone3"), // ------------------------------------------------------ new Company(6, "Company C", "123 London Street", "WN1 0PG", "phone4"), // ------------------------------------------------------ new Company(7, "Stratfords Tools Ltd", "80 London Street", "WN1 0PG", "phone6"), new Company(8, "Stratfords Tools Ltd", "80 London Street", "WN1 0PG", "phone7"), // ------------------------------------------------------ //Dupe 4 contains a Name and Postcode match and also matches Dupe 3 as an Truncated Name and Postcode match, this should be ignored new Company(9,"Stratfords Ltd", "80 Hewit Street", "WN1 0PG", "00000000005"), new Company(10,"Stratfords Ltd", "88 Hewit Street", "WN1 0PG", "00000000006"), }; _deduped = _deduper.Dedupe(customers).ToArray(); }
/// <summary> /// Creates XML element containing the information on the specified pending changes group. /// </summary> public static XElement ExportPendingChangesGroup(IGrouping<IUserInfo, PendingChange> changesGroup) { return new XElement( "group", ExportUserInfo(changesGroup.Key), from change in changesGroup select ExportPendingChange(change)); }
//internal TableInfo(DB2Connection connection, DB2DataReader reader) //{ // _connection = connection; // Name = Convert.ToString(reader.GetValue(reader.GetOrdinal("NAME"))); // Remarks = Convert.ToString(reader.GetValue(reader.GetOrdinal("REMARKS"))); //} internal TableInfo(IGrouping<string, DataRow> data) { _data = data; Name = data.First().Field<string>("TBNAME"); Remarks = data.First().Field<string>("TBREMARKS"); }
public static PageRequest GetEventFromGroup(IGrouping<Guid, PageRequest> group) { var element = group.First(); var other = group.Skip(1).ToList(); if (other.Count == 0) return element; else return new RequestSessionGroup(element, other); }
public PackageFoundResult(IGrouping<string, IPackageInfo> packageInfos, PackageListOptions options, IEnumerable<IPackageInfo> currentPackages) { Options = options; CurrentPackages = currentPackages; Name = packageInfos.Key; Packages = packageInfos.ToList(); }
private static IEnumerable<KeyValuePair<IndexedName, RealNode>> ReduceGroup( IEnumerable<KeyValuePair<IndexedName, RealNode>> aggr, IGrouping<XName, RealNode> items) { var addition = items.Select((elem, i) => new KeyValuePair<IndexedName, RealNode>(new IndexedName(items.Key, i), elem)); return aggr.Concat(addition); }
public static string FormatCanonicalizedValues(IGrouping<string, string> headerOrParameter) { return headerOrParameter.Key.ToLowerInvariant() + ":" + String.Join(",", headerOrParameter .Select(value => value.TrimStart().Replace("\r\n", String.Empty)) .OrderBy(value => value, StringComparer.OrdinalIgnoreCase)); }
/// <summary> /// Exports the masteries. /// </summary> /// <param name="typeMasteries">The type masteries.</param> /// <returns></returns> private static IEnumerable<SerializableMastery> ExportMasteries(IGrouping<int, DgmTypeMasteries> typeMasteries) { List<SerializableMastery> listOfMasteries = new List<SerializableMastery>(); foreach (DgmMasteries typeMastery in typeMasteries.Select(x => Database.DgmMasteriesTable[x.MasteryID])) { Util.UpdatePercentDone(Database.MasteriesTotalCount); int grade = typeMastery.Grade + 1; SerializableMastery mastery; if (listOfMasteries.All(x=> x.Grade != grade)) { mastery = new SerializableMastery { Grade = grade }; listOfMasteries.Add(mastery); } else mastery = listOfMasteries.First(x => x.Grade == grade); SerializableMasteryCertificate masteryCertificate = new SerializableMasteryCertificate { ID = typeMastery.CertificateID, ClassName = Database.CrtClassesTable[Database.CrtCertificatesTable[typeMastery.CertificateID].ClassID].ClassName }; mastery.Certificates.Add(masteryCertificate); } return listOfMasteries; }
public TSDepartmentSource (TSDepartmentsVC tvc,TSSettingsView _settingView, List<TSSettingsItems> data) { controller = tvc; Data = data; settingView = _settingView; GroupedData = GetEntriesBySectionName (); }
public GroupedOrderTagViewModel(Order selectedItem, IGrouping<string, OrderTagGroup> orderTagGroups) { Name = orderTagGroups.Key; OrderTags = orderTagGroups.Select(x => new GroupedOrderTagButtonViewModel(selectedItem, x)).ToList(); ColumnCount = orderTagGroups.First().ColumnCount; ButtonHeight = orderTagGroups.First().ButtonHeight; }
private static MemberDeclarationSyntax CreateOneNamespaceDeclaration(IGrouping<string, NamespaceDeclarationSyntax> ns) { var nameSyntax = SyntaxFactory.ParseName(ns.Key); return SyntaxFactory .NamespaceDeclaration(nameSyntax) .AddMembers(ns.SelectMany(x => x.Members) .ToArray()); }
private FilterGroupModel CreateFilterGroupModel(IGrouping<int, FilterDTO> filterDTOGroup, string locationID, string database) { return new FilterGroupModel() { FilterGroupItems = filterDTOGroup.OrderBy(f => f.ViewOrder).Select(f => CreateBaseFilter(f, locationID, database)).ToList(), Index = filterDTOGroup.Key }; }
private void PerformJobs(IGrouping<ISynchronizeInvoke, UpdateUIJob> jobGroup) { var firstJob = jobGroup.First(); jobGroup.Where(job => job != firstJob).ForEach(firstJob.MergeWith); firstJob.Perform(); }
private void ShowItemGroup(IGrouping<string, LootItem> lootItemGroup) { GameObject lootItemGameObject = LootItemGroupTemplate.Clone(); lootItemGameObjects.Add(lootItemGameObject); LootItemSelectionGroupController lootItemSelectionGroupController = lootItemGameObject.GetComponent<LootItemSelectionGroupController>(); lootItemSelectionGroupController.OnLootItemGroupSelected += LootItemGroupSelectedEventHandler; lootItemSelectionGroupController.ShowItemGroup(lootItemGroup); }
IGrouping<char, Speaker>[] grouping; // sub-group of speakers in each index public SpeakersTableSource (List<Speaker> speakers) { data = speakers; // TODO: Step 2b: get the filtered data indices = SpeakerIndicies (); grouping = GetSpeakersGrouped(); }
private HtmlButtonGroup( HtmlForm form, IGrouping<string, IHtmlElement> inputGroup ) { _form = form; name = inputGroup.Key; items = inputGroup.Select( e => new HtmlInputItem( this, e ) ).ToArray(); }
private static IEnumerable<IAutoCompleteListItem> parseClientGroup(IGrouping<ulong, Toggl.TogglAutocompleteView> c) { var projectItems = c.GroupBy(p => p.ProjectID).Select(parseProjectGroup); if (c.Key == 0) return projectItems; var clientName = c.First().ClientLabel; return new ClientCategory(clientName, projectItems.ToList()).Yield<IAutoCompleteListItem>(); }
private IEnumerable<Action<ISimpleDbService>> CollectDeleteOperations(IGrouping<ISimpleDbDomain, ISessionItem> domainSet) { var deleteBatches = domainSet.Where(i => i.State == SessionItemState.Delete).GroupsOf(25); foreach (var deleteBatch in deleteBatches) { yield return service => service.BatchDeleteAttributes(domainSet.Key.Name, deleteBatch.Cast<object>().ToArray()); } }
public void ShowItem(IGrouping<string, LootItem> lootItemGroup) { ItemCountText.text = String.Format("{0}X", lootItemGroup.Count().ToString()); LootItem lootItemSample = lootItemGroup.FirstElement(); ItemGroupNameText.text = lootItemSample.Name; ItemGroupIcon.sprite = lootItemSample.IconSprite; this.gameObject.SetActive(true); }
protected virtual ResourceVirtualDirectory CreateVirtualDirectory(IGrouping<string, string[]> subResources) { var remainingResourceNames = subResources.Select(g => g[1]); var subDir = new ResourceVirtualDirectory( VirtualPathProvider, this, backingAssembly, subResources.Key, remainingResourceNames); return subDir; }
private ModuleRouteSummary CreateModuleRouteSummary(IGrouping<Type, RouteInfo> moduleRouteInfos) { var moduleRouteSummary = new ModuleRouteSummary(moduleRouteInfos.Key.Name, _helpModulePath); foreach (var routeInfo in moduleRouteInfos) moduleRouteSummary.Routes.Add(new RouteSummary(routeInfo, _helpModulePath)); return moduleRouteSummary; }
private IEnumerable<Action<ISimpleDbService>> CollectUpsertOperations(IGrouping<ISimpleDbDomain, ISessionItem> domainSet) { var putBatches = domainSet.Where(i => i.State == SessionItemState.Create || i.State == SessionItemState.Update).GroupsOf(25); foreach (var putBatch in putBatches) { yield return service => service.BatchPutAttributes(domainSet.Key.Name, putBatch.Cast<object>().ToArray()); } }
public MenuItemGroupedPropertyViewModel(TicketItemViewModel selectedItem, IGrouping<string, MenuItemPropertyGroup> menuItemPropertyGroups) { Name = menuItemPropertyGroups.Key; Properties = menuItemPropertyGroups.Select(x => new MenuItemGroupedPropertyItemViewModel(selectedItem, x)).ToList(); ColumnCount = menuItemPropertyGroups.First().ColumnCount; ButtonHeight = menuItemPropertyGroups.First().ButtonHeight; TerminalButtonHeight = menuItemPropertyGroups.First().TerminalButtonHeight; TerminalColumnCount = menuItemPropertyGroups.First().TerminalColumnCount; }
private ICategory GetCategory(string phase, IGrouping<string, ICategory> group) { return group.FirstOrDefault(x => { if (x.Name.Length < phase.Length) return false; var part = x.Name.Substring(0, phase.Length); return string.Equals(part, phase, StringComparison.OrdinalIgnoreCase); }); }
static List<AlbumTrack> BuildTracks(IGrouping<string, Track> gt) { var tracks = new List<AlbumTrack>(); gt.ToList().ForEach(t => { var track = new AlbumTrack { Name = t.Name, PlayingTime = t.PlayingTime, TrackNumber = t.TrackNumber ?? 0, }; tracks.Add(track); }); return tracks; }
private DebuggerViewItem OnSelector(IGrouping<IHandler, Burden> lookup) { var handler = lookup.Key; var objects = lookup.Select(g => g.Instance).ToArray(); var view = ComponentDebuggerView.BuildFor(handler); return new DebuggerViewItem(handler.GetComponentName(), "Count = " + objects.Length, new ReleasePolicyTrackedObjectsDebuggerViewItem(view, objects)); }
private IEnumerable <QuizInfoForDb> CreateQuizInfoForDb(OrderingBlock orderingBlock, IGrouping <string, QuizAnswer> answers) { var ans = answers.Select(x => x.ItemId).ToList() .Select(x => new QuizInfoForDb { BlockId = orderingBlock.Id, IsRightAnswer = true, ItemId = x, Text = null, BlockType = typeof(OrderingBlock), QuizBlockScore = 0, QuizBlockMaxScore = orderingBlock.MaxScore }).ToList(); var isRightQuizBlock = answers.Count() == orderingBlock.Items.Length && answers.Zip(orderingBlock.Items, (answer, item) => answer.ItemId == item.GetHash()).All(x => x); var blockScore = isRightQuizBlock ? orderingBlock.MaxScore : 0; foreach (var info in ans) { info.QuizBlockScore = blockScore; } return(ans); }
private IEnumerable <QuizInfoForDb> CreateQuizInfoForDb(MatchingBlock matchingBlock, IGrouping <string, QuizAnswer> answers) { var ans = answers.ToList() .Select(x => new QuizInfoForDb { BlockId = matchingBlock.Id, IsRightAnswer = matchingBlock.Matches.FirstOrDefault(m => m.GetHashForFixedItem() == x.ItemId)?. GetHashForMovableItem() == x.Text, ItemId = x.ItemId, Text = x.Text, BlockType = typeof(MatchingBlock), QuizBlockScore = 0, QuizBlockMaxScore = matchingBlock.MaxScore }).ToList(); var isRightQuizBlock = ans.All(x => x.IsRightAnswer); var blockScore = isRightQuizBlock ? matchingBlock.MaxScore : 0; foreach (var info in ans) { info.QuizBlockScore = blockScore; } return(ans); }
public static dynamic Last(this IGrouping <dynamic, dynamic> self) { return(DynamicEnumerable.Last(self)); }
public void ProjectionSkipped( IGrouping <StreamId, IEvent> events) { // Ignore }
public static dynamic SingleOrDefault(this IGrouping <dynamic, dynamic> self) { return(DynamicEnumerable.SingleOrDefault(self)); }
public static dynamic ElementAtOrDefault(this IGrouping <dynamic, dynamic> self, int index) { return(DynamicEnumerable.ElementAtOrDefault(self, index)); }
void EvaluateExpressionsInGroups(ExportContainer sectionContainer, IGrouping <object, object> grouping) { ExpressionRunner.Visitor.SetCurrentDataSource(grouping); ExpressionRunner.Visitor.Visit(sectionContainer); }
internal static bool FightBattleAndOwnerSurvived(PlanetTurn lastCalculatedTurn, IGrouping <int, Fleet> turn) { Dictionary <int, int> participants = new Dictionary <int, int>(); participants.Add(lastCalculatedTurn.Owner, lastCalculatedTurn.NumShips); foreach (Fleet fl in turn) { int attackForce; if (participants.TryGetValue(fl.Owner, out attackForce)) { participants[fl.Owner] = attackForce + fl.NumShips; } else { participants.Add(fl.Owner, fl.NumShips); } } Fleet winner = new Fleet(0, 0, null, null, 0, 0); Fleet second = new Fleet(0, 0, null, null, 0, 0); foreach (var fleet in participants) { if (fleet.Value > second.NumShips) { if (fleet.Value > winner.NumShips) { second = winner; winner = new Fleet(fleet.Key, fleet.Value, null, null, 0, 0); } else { second = new Fleet(fleet.Key, fleet.Value, null, null, 0, 0); } } } bool survived; if (winner.NumShips > second.NumShips) { survived = lastCalculatedTurn.Owner == winner.Owner; lastCalculatedTurn.SetValues(winner.Owner, winner.NumShips - second.NumShips); } else { survived = true; lastCalculatedTurn.SetValues(lastCalculatedTurn.Owner, 0); } return(survived); }
public GroupInfo(IGrouping <TKey, object> source) : base(source) { Key = source.Key; }
private async Task Run(IGrouping <string, Series> group, bool addNewItems, CancellationToken cancellationToken) { var seriesList = group.ToList(); var tvdbId = seriesList .Select(i => i.GetProviderId(MetadataProviders.Tvdb)) .FirstOrDefault(i => !string.IsNullOrWhiteSpace(i)); // Todo: Support series by imdb id var seriesProviderIds = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); seriesProviderIds[MetadataProviders.Tvdb.ToString()] = tvdbId; var seriesDataPath = TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds); // Doesn't have required provider id's if (string.IsNullOrWhiteSpace(seriesDataPath)) { return; } // Check this in order to avoid logging an exception due to directory not existing if (!_fileSystem.DirectoryExists(seriesDataPath)) { return; } var episodeFiles = _fileSystem.GetFilePaths(seriesDataPath) .Where(i => string.Equals(Path.GetExtension(i), ".xml", StringComparison.OrdinalIgnoreCase)) .Select(Path.GetFileNameWithoutExtension) .Where(i => i.StartsWith("episode-", StringComparison.OrdinalIgnoreCase)) .ToList(); var episodeLookup = episodeFiles .Select(i => { var parts = i.Split('-'); if (parts.Length == 3) { int seasonNumber; if (int.TryParse(parts[1], NumberStyles.Integer, _usCulture, out seasonNumber)) { int episodeNumber; if (int.TryParse(parts[2], NumberStyles.Integer, _usCulture, out episodeNumber)) { return(new Tuple <int, int>(seasonNumber, episodeNumber)); } } } return(new Tuple <int, int>(-1, -1)); }) .Where(i => i.Item1 != -1 && i.Item2 != -1) .ToList(); var hasBadData = HasInvalidContent(seriesList); // Be conservative here to avoid creating missing episodes for ones they already have var addMissingEpisodes = !hasBadData && seriesList.All(i => _libraryManager.GetLibraryOptions(i).ImportMissingEpisodes); var anySeasonsRemoved = await RemoveObsoleteOrMissingSeasons(seriesList, episodeLookup) .ConfigureAwait(false); var anyEpisodesRemoved = await RemoveObsoleteOrMissingEpisodes(seriesList, episodeLookup, addMissingEpisodes) .ConfigureAwait(false); var hasNewEpisodes = false; if (addNewItems && seriesList.All(i => i.IsInternetMetadataEnabled())) { var seriesConfig = _config.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, typeof(Series).Name, StringComparison.OrdinalIgnoreCase)); if (seriesConfig == null || !seriesConfig.DisabledMetadataFetchers.Contains(TvdbSeriesProvider.Current.Name, StringComparer.OrdinalIgnoreCase)) { hasNewEpisodes = await AddMissingEpisodes(seriesList, addMissingEpisodes, seriesDataPath, episodeLookup, cancellationToken) .ConfigureAwait(false); } } if (hasNewEpisodes || anySeasonsRemoved || anyEpisodesRemoved) { foreach (var series in seriesList) { var directoryService = new DirectoryService(_logger, _fileSystem); await series.RefreshMetadata(new MetadataRefreshOptions(directoryService), cancellationToken).ConfigureAwait(false); await series.ValidateChildren(new SimpleProgress <double>(), cancellationToken, new MetadataRefreshOptions(directoryService), true) .ConfigureAwait(false); } } }
private void AppendFolder(IGrouping <string, FileEntry> group) { _sb.AppendLine(); _sb.AppendLine(); _sb.Append($"### {WebUtility.HtmlEncode(group.Key)} `files: {group.Count()}"); if (Configuration.IncludeSize) { _sb.Append($"({Utils.ReadableSize(group.Sum(x => x.Size))})"); } _sb.AppendLine("`"); _sb.AppendLine(); foreach (var entry in group) { _sb.Append($"* {entry.Filename}"); if (Configuration.IncludeSize) { _sb.Append($" `{entry.ReadableSize}`"); } if (Configuration.IncludeFileDates) { _sb.Append( $" `Created: {entry.Created.ToLocalTime().ToString(Configuration.DateFormat)}, modified: {entry.Modified.ToLocalTime().ToString(Configuration.DateFormat)}`"); } if (Configuration.IncludeMediaInfo && entry.MediaInfo != null) { _sb.Append($" `{entry.MediaInfo.MediaType}"); if (entry.MediaInfo.Duration != TimeSpan.Zero) { _sb.Append($" {FormatDuration(entry.MediaInfo.Duration)}"); } if (entry.MediaInfo.Height > 0) { _sb.Append($" {entry.MediaInfo.Height}x{entry.MediaInfo.Width},"); } _sb.Append(GetMediaInfo("bpp", entry.MediaInfo.BitsPerPixel)); if (entry.MediaInfo.AudioBitRate != 0 || entry.MediaInfo.AudioSampleRate != 0 || entry.MediaInfo.AudioChannels != 0) { _sb.Remove(_sb.Length - 1, 1); _sb.Append(" :: audio"); _sb.Append(GetMediaInfo("bitrate", entry.MediaInfo.AudioBitRate)); _sb.Append(GetMediaInfo("channels", entry.MediaInfo.AudioChannels)); if (entry.MediaInfo.AudioSampleRate > 0) { _sb.Append(GetMediaInfo("sample rate", entry.MediaInfo.AudioSampleRate / 1000f)); } } _sb.Remove(_sb.Length - 1, 1); //remove trailing comma _sb.Append("`"); } _sb.AppendLine(); } }
private string DeletionsAuthor(IGrouping <string, Deletion> grouping) { return(grouping.Key); }
/// <summary> /// Initializes a new instance of the <see cref="ObservableGroup{TKey, TValue}"/> class. /// </summary> /// <param name="grouping">The grouping to fill the group.</param> public ObservableGroup(IGrouping <TKey, TValue> grouping) : base(grouping) { Key = grouping.Key; }
public static dynamic Min(this IGrouping <dynamic, dynamic> self) { return(DynamicEnumerable.Min(self)); }
private IEnumerable <QuizInfoForDb> CreateQuizInfoForDb(ChoiceBlock choiceBlock, IGrouping <string, QuizAnswer> answers) { int blockScore; if (!choiceBlock.Multiple) { var answerItemId = answers.First().ItemId; var isCorrect = choiceBlock.Items.First(x => x.Id == answerItemId).IsCorrect.IsTrueOrMaybe(); blockScore = isCorrect ? choiceBlock.MaxScore : 0; return(new List <QuizInfoForDb> { new QuizInfoForDb { BlockId = choiceBlock.Id, ItemId = answerItemId, IsRightAnswer = isCorrect, Text = null, BlockType = typeof(ChoiceBlock), QuizBlockScore = blockScore, QuizBlockMaxScore = choiceBlock.MaxScore } }); } var ans = answers.Select(x => x.ItemId).ToList() .Select(x => new QuizInfoForDb { BlockId = choiceBlock.Id, IsRightAnswer = choiceBlock.Items.Where(y => y.IsCorrect.IsTrueOrMaybe()).Any(y => y.Id == x), ItemId = x, Text = null, BlockType = typeof(ChoiceBlock), QuizBlockScore = 0, QuizBlockMaxScore = choiceBlock.MaxScore }).ToList(); var mistakesCount = GetChoiceBlockMistakesCount(choiceBlock, ans); var isRightQuizBlock = mistakesCount.HasNotMoreThatAllowed(choiceBlock.AllowedMistakesCount); blockScore = isRightQuizBlock ? choiceBlock.MaxScore : 0; foreach (var info in ans) { info.QuizBlockScore = blockScore; } return(ans); }
private IEnumerable <QuizInfoForDb> CreateQuizInfoForDb(IsTrueBlock isTrueBlock, IGrouping <string, QuizAnswer> data) { var isTrue = isTrueBlock.IsRight(data.First().ItemId); var blockScore = isTrue ? isTrueBlock.MaxScore : 0; return(new List <QuizInfoForDb> { new QuizInfoForDb { BlockId = isTrueBlock.Id, ItemId = null, IsRightAnswer = isTrue, Text = data.First().ItemId, BlockType = typeof(IsTrueBlock), QuizBlockScore = blockScore, QuizBlockMaxScore = isTrueBlock.MaxScore } }); }
protected abstract Dictionary <string, List <ISpecElement> > GroupsFirstForNumbering(IGrouping <GroupType, ISpecElement> indexTypeGroup);
public static dynamic SingleOrDefault(this IGrouping <dynamic, dynamic> self, Func <dynamic, bool> predicate) { return(DynamicEnumerable.SingleOrDefault(self, predicate)); }
private static TestSuite CreateFixture(IGrouping <string, TestResultInfo> resultsByType) { var element = new XElement("test-suite"); int total = 0; int passed = 0; int failed = 0; int skipped = 0; int inconclusive = 0; int error = 0; var time = TimeSpan.Zero; DateTime?startTime = null; DateTime?endTime = null; foreach (var result in resultsByType) { switch (result.Outcome) { case TestOutcome.Failed: failed++; break; case TestOutcome.Passed: passed++; break; case TestOutcome.Skipped: skipped++; break; case TestOutcome.None: inconclusive++; break; } total++; time += result.Duration; if (!startTime.HasValue || result.StartTime < startTime) { startTime = result.StartTime; } if (!endTime.HasValue || result.EndTime > endTime) { endTime = result.EndTime; } // Create test-case elements element.Add(CreateTestCaseElement(result)); } // Create test-suite element for the TestFixture var name = resultsByType.Key.SubstringAfterDot(); element.SetAttributeValue("type", "TestFixture"); element.SetAttributeValue("name", name); element.SetAttributeValue("fullname", resultsByType.Key); element.SetAttributeValue("total", total); element.SetAttributeValue("passed", passed); element.SetAttributeValue("failed", failed); element.SetAttributeValue("inconclusive", inconclusive); element.SetAttributeValue("skipped", skipped); var resultString = failed > 0 ? ResultStatusFailed : ResultStatusPassed; element.SetAttributeValue("result", resultString); if (startTime.HasValue) { element.SetAttributeValue("start-time", startTime.Value.ToString(DateFormat, CultureInfo.InvariantCulture)); } if (endTime.HasValue) { element.SetAttributeValue("end-time", endTime.Value.ToString(DateFormat, CultureInfo.InvariantCulture)); } element.SetAttributeValue("duration", time.TotalSeconds); return(new TestSuite { Element = element, Name = name, FullName = resultsByType.Key, Total = total, Passed = passed, Failed = failed, Inconclusive = inconclusive, Skipped = skipped, Error = error, StartTime = startTime, EndTime = endTime, Time = time }); }
public ObservableGroupCollection(IGrouping <GroupKey, GroupItems> group) : base(group) { Key = group.Key; }
private Func <dynamic, IGrouping <string, DbParameter>[]> CreateEnumerableDbParameters(Type t, IGrouping <bool, PropertyInfo> pis) { if (pis == null) { return(d => new IGrouping <string, DbParameter> [0]); } var o = Expression.Parameter(TypeHelper.ObjectType, "o"); var p = Expression.Variable(t, "p"); var passign = Expression.Assign(p, Expression.Convert(o, t)); var vs = Expression.Variable(TypeHelper.SqlParameterListType, "vs"); var vsAssign = Expression.Assign(vs, Expression.New(TypeHelper.SqlParameterListType)); var v = Expression.Variable(GetParameterType(), "v"); var vAssign = Expression.Assign(v, Expression.New(GetParameterType())); var index = Expression.Variable(typeof(int), "i"); var enumeratorVar = Expression.Variable(typeof(IEnumerator), "enumerator"); var ps = pis.Select(i => { var pt = i.PropertyType; var realType = pt.HasElementType ? pt.GetElementType() : pt.GenericTypeArguments.FirstOrDefault(); var moveNext = Expression.Call(enumeratorVar, typeof(IEnumerator).GetMethod("MoveNext")); var breakLabel = Expression.Label("LoopBreak"); var loop = Expression.Block(new[] { v }, new Expression[] { Expression.Assign(enumeratorVar, Expression.Call(Expression.Property(p, i), typeof(IEnumerable).GetMethod("GetEnumerator"))), Expression.Assign(index, Expression.Constant(0)), Expression.Loop(Expression.IfThenElse(moveNext, Expression.Block(new[] { v }, new Expression[] { vAssign, Expression.Assign(Expression.Property(v, "SourceColumn"), Expression.Constant(DataParameter.ParameterNamePrefix + i.Name)), Expression.Assign(Expression.Property(v, "ParameterName"), Expression.Call(concat, Expression.Constant(DataParameter.ParameterNamePrefix + i.Name), Expression.Call(index, toStr))), Expression.Assign(Expression.Property(v, "DbType"), Expression.Constant(_DC.Convert(realType))), Expression.Assign(Expression.Property(v, "Value"), Expression.Condition(Expression.Equal(Expression.Constant(null), Expression.Property(enumeratorVar, "Current")), Expression.Constant(DBNull.Value, TypeHelper.ObjectType), Expression.Property(enumeratorVar, "Current"))), Expression.Assign(Expression.Property(v, "IsNullable"), Expression.Constant(true)), Expression.Assign(Expression.Property(v, "Direction"), Expression.Constant(ParameterDirection.Input)), Expression.Call(vs, "Add", new Type[0], v), Expression.AddAssign(index, Expression.Constant(1)) }), Expression.Break(breakLabel)), breakLabel) }); return(loop); }).ToList <Expression>(); ps.Insert(0, vsAssign); ps.Insert(0, passign); ps.Add(vs); var bb = Expression.Block(new ParameterExpression[] { vs, p, enumeratorVar, index }, ps); var dd = Expression.Lambda <Func <dynamic, List <DbParameter> > >(bb, o); var f = dd.Compile(); return(d => { List <DbParameter> result = f(d); return result.GroupBy(i => i.SourceColumn).ToArray(); }); }
public static dynamic Last(this IGrouping <dynamic, dynamic> self, Func <dynamic, bool> predicate) { return(DynamicEnumerable.Last(self, predicate)); }
public MultiSelectObservableGroupCollection(IGrouping <S, T> group) : base(group) { _key = group.Key; }
public static IEnumerable <dynamic> SelectMany(this IGrouping <dynamic, dynamic> source, Func <dynamic, IEnumerable <dynamic> > collectionSelector, Func <dynamic, dynamic, dynamic> resultSelector) { return(new DynamicArray(Enumerable.SelectMany(Select(source), collectionSelector, resultSelector))); }
public void ProjectionCompleted( IGrouping <StreamId, IEvent> events) { // Ignore }
private static AnnotatedListPart CreateListPart(IGrouping <Tuple <string, string>, PropertyInfo> listProperties) => AnnotatedListPart.Create(listProperties.Key.Item1, listProperties.Key.Item2, listProperties);
public DynamicGrouping(IGrouping <dynamic, dynamic> grouping) : base(grouping) { _grouping = grouping; }
public static IEnumerable <dynamic> SelectMany(this IGrouping <dynamic, dynamic> source, Func <dynamic, IEnumerable <dynamic> > selector) { return(new DynamicArray(Select(source).SelectMany <object, object>(selector))); }
public PackageFoundResult(IGrouping <string, IPackageInfo> packageInfos) { Name = packageInfos.Key; Packages = packageInfos.ToList(); }
public PublicGrouping(IGrouping <TKey, TElement> internalGrouping) { _internalGrouping = internalGrouping; }