public static void SetNsNetworks(string[] networks) { Host.NsNetworks.StoredValues["$value"] = EnumerableExtensions.JoinToString(networks, "\n"); Host.NsNetworksContent = networks; Export(Host); }
public void At_FromEnumerableExtensions_GivenNullSource_ThrowsArgumentNullException() { Assert.Throws <ArgumentNullException>(() => EnumerableExtensions.At <int>(null, 0)); }
public void JoinTest() { Tuple <int, string, int>[] products = new Tuple <int, string, int>[] { new Tuple <int, string, int>(1, "aa", 1), new Tuple <int, string, int>(2, "bb", 1), new Tuple <int, string, int>(3, "cc", 2), new Tuple <int, string, int>(4, "dd", 2), new Tuple <int, string, int>(5, "ee", 2), }; Tuple <int, string>[] categories = new Tuple <int, string>[] { new Tuple <int, string>(1, "A"), new Tuple <int, string>(2, "B"), new Tuple <int, string>(3, "C"), }; Tuple <string, string>[] expected = Enumerable.ToArray(Enumerable.Join( products, categories, product => product.Item3, category => category.Item1, (product, category) => new Tuple <string, string>(category.Item2, product.Item2))); Tuple <string, string>[] actual = Enumerable.ToArray(EnumerableExtensions.Join( products, categories, product => product.Item3, category => category.Item1, (product, category) => new Tuple <string, string>(category.Item2, product.Item2), EqualityComparer <int> .Default)); Assert.AreEqual(Enumerable.Count(expected), Enumerable.Count(actual)); expected.ForEach((product, index) => { Assert.AreEqual(product.Item1, actual[index].Item1); Assert.AreEqual(product.Item2, actual[index].Item2); }); products = new Tuple <int, string, int>[] { new Tuple <int, string, int>(1, "aa", 1), new Tuple <int, string, int>(2, "bb", 1), new Tuple <int, string, int>(3, "cc", 2), new Tuple <int, string, int>(4, "dd", 2), new Tuple <int, string, int>(5, "ee", 2), }; categories = new Tuple <int, string>[] { }; expected = Enumerable.ToArray(Enumerable.Join( products, categories, product => product.Item3, category => category.Item1, (product, category) => new Tuple <string, string>(category.Item2, product.Item2))); actual = Enumerable.ToArray(EnumerableExtensions.Join( products, categories, product => product.Item3, category => category.Item1, (product, category) => new Tuple <string, string>(category.Item2, product.Item2), EqualityComparer <int> .Default)); Assert.AreEqual(Enumerable.Count(expected), Enumerable.Count(actual)); expected.ForEach((product, index) => { Assert.AreEqual(product.Item1, actual[index].Item1); Assert.AreEqual(product.Item2, actual[index].Item2); }); products = new Tuple <int, string, int>[] { }; categories = new Tuple <int, string>[] { new Tuple <int, string>(1, "A"), new Tuple <int, string>(1, "B"), new Tuple <int, string>(1, "C"), }; expected = Enumerable.ToArray(Enumerable.Join( products, categories, product => product.Item3, category => category.Item1, (product, category) => new Tuple <string, string>(category.Item2, product.Item2))); actual = Enumerable.ToArray(EnumerableExtensions.Join( products, categories, product => product.Item3, category => category.Item1, (product, category) => new Tuple <string, string>(category.Item2, product.Item2), EqualityComparer <int> .Default)); Assert.AreEqual(Enumerable.Count(expected), Enumerable.Count(actual)); expected.ForEach((product, index) => { Assert.AreEqual(product.Item1, actual[index].Item1); Assert.AreEqual(product.Item2, actual[index].Item2); }); }
// GET: Organizations public async Task <IActionResult> Index(Guid?id) { ViewData["NextController"] = "Groups"; ViewData["ParentController"] = "Organizations"; ViewData["ParentId"] = id; //Get logged USER Organization Guid?userOrganizationId = (await _userManager.GetUserAsync(HttpContext.User))?.OrganizationId; if (userOrganizationId == null) { return(NotFound()); } //Get Logged User Organization var organization = await _context.Organizations .SingleOrDefaultAsync(o => o.OrganizationId == userOrganizationId); if (organization == null) { return(NotFound()); } //If USER Organization is not an Organization Unit redirect to Groups Controller if (organization.IsOrganizationUnit != true) { return(RedirectToAction(nameof(Index), "Groups", new { id = organization.OrganizationId })); } else { //If id parameter is null, return USER Organization if (id == null) { var applicationDbContext = _context.Organizations .Include(o => o.Locations) .Include(o => o.OrganizationTypes) .Include(o => o.ParentOrganization) .Where(o => o.ParentOrganizationId == organization.OrganizationId); ViewData["ParentId"] = organization.OrganizationId; return(View(await applicationDbContext.OrderBy(o => o.OrganizationName).ToListAsync())); } // return selected id Organization else { //Get Organizations that are Organization Units var OUOrganizations = _context.Organizations .Where(x => x.IsOrganizationUnit == true); //Get List of Parents var parents = EnumerableExtensions.ListParents(OUOrganizations, id).ToList(); if (!parents.Contains(organization)) { //Parent return(NotFound()); } //Return selected Organization ID Child organizations var applicationDbContext = _context.Organizations .Include(o => o.Locations).ThenInclude(o => o.ParentLocations) .Include(o => o.OrganizationTypes) .Include(o => o.ParentOrganization) .Where(o => o.ParentOrganizationId == id); return(View(await applicationDbContext.OrderBy(o => o.OrganizationName).ToListAsync())); } } }
public void SkipLast_NegativeN_Throws() { var source = Enumerable.Range(0, 3); Assert.Throws <ArgumentOutOfRangeException>(() => EnumerableExtensions.SkipLast(source, -1).ToArray()); }
public void AtOrDefault_FromEnumerableExtensions_GivenIndexOurOfRange_ReturnsNull_WhenExecutedOnReferenceCollection(int index, int collectionLength) { var source = Enumerable.Range(0, collectionLength).Select(x => x.ToString()); Assert.Equal(null, EnumerableExtensions.AtOrDefault(source, index)); }
public void CopyTo(KeyValuePair <TKey, TValue>[] array, int arrayIndex) { EnumerableExtensions.CopyTo(this, this.Count, array, arrayIndex); }
public static object?[] EvalParameters(string paramString, DependencyObject target, object?arg) { return(EnumerableExtensions.Concat(NamedParameters(paramString, target, arg), arg) .OfType <object>() .ToArray()); }
public void ConcatenateThrowsIfSequencesAreNull() { Assert.Throws <ArgumentNullException>(() => EnumerableExtensions.Concatenate <TestItem>(null)); }
public void TableShouldGetCreated() { Assert.False(EnumerableExtensions.Any(DbContext.Agents)); }
public bool UpdateProject(IEnumerable <ProjectItemAction> actions) { if (!EnumerableExtensions.CountIsMoreThan <ProjectItemAction>(actions, 0)) { return(true); } IEnumerable <ProjectItemAction> enumerable1 = Enumerable.Where <ProjectItemAction>(actions, (Func <ProjectItemAction, bool>)(action => { if (action.Operation != ProjectItemOperation.Add) { return(action.Operation == ProjectItemOperation.Update); } return(true); })); IEnumerable <DocumentCreationInfo> creationInfo = Enumerable.Select <ProjectItemAction, DocumentCreationInfo>(enumerable1, (Func <ProjectItemAction, DocumentCreationInfo>)(item => new DocumentCreationInfo() { TargetFolder = Path.GetDirectoryName(item.ProjectItemPath), SourcePath = item.SourceFilePath, CreationOptions = CreationOptions.SilentlyOverwrite | CreationOptions.SilentlyOverwriteReadOnly | CreationOptions.DoNotSelectCreatedItems | CreationOptions.DoNotSetDefaultImportPath | CreationOptions.AlwaysUseDefaultBuildTask })); IEnumerable <IProjectItem> source = Enumerable.Where <IProjectItem>(Enumerable.Select <ProjectItemAction, IProjectItem>(Enumerable.Where <ProjectItemAction>(actions, (Func <ProjectItemAction, bool>)(action => action.Operation == ProjectItemOperation.Delete)), (Func <ProjectItemAction, IProjectItem>)(action => this.project.FindItem(DocumentReference.Create(action.ProjectItemPath)))), (Func <IProjectItem, bool>)(item => item != null)); IEnumerable <IProjectItem> completedActions = this.project.AddItems(creationInfo); if (!MSBuildProject.UpdateCompletedActions(enumerable1, completedActions) || !this.project.RemoveItems(true, Enumerable.ToArray <IProjectItem>(source))) { return(false); } IEnumerable <ProjectItemAction> enumerable2 = Enumerable.Where <ProjectItemAction>(actions, (Func <ProjectItemAction, bool>)(action => action.Operation != ProjectItemOperation.Delete)); bool flag1 = false; foreach (ProjectItemAction projectItemAction in enumerable2) { IProjectItem projectItem = this.project.FindItem(DocumentReference.Create(projectItemAction.ProjectItemPath)); if (projectItem != null) { string buildTask = projectItem.DocumentType.DefaultBuildTaskInfo.BuildTask; bool flag2 = projectItem.Properties["BuildAction"] == buildTask; if (projectItemAction.IsEnabled == flag2) { projectItemAction.OnActionCompleted(); } else if (buildTask == SampleDataSet.DesignTimeBuildType) { projectItemAction.OnActionCompleted(); } else { if (!flag1) { flag1 = true; if (!((KnownProjectBase)this.project).AttemptToMakeProjectWritable()) { return(false); } } projectItem.Properties["BuildAction"] = !projectItemAction.IsEnabled ? SampleDataSet.DesignTimeBuildType : buildTask; projectItemAction.OnActionCompleted(); } } } return(true); }
public List <int> Hyperlinq_Enumerable_Value() => EnumerableExtensions.AsValueEnumerable <TestEnumerable.Enumerable, TestEnumerable.Enumerable.Enumerator, int>(enumerableValue, enumerable => enumerable.GetEnumerator()) .ToList();
public static void SetNsSwitch(string[] @switch) { Host.NsSwitchContent = @switch; Host.NsSwitch.StoredValues["$value"] = EnumerableExtensions.JoinToString(@switch, "\n"); Export(Host); }
public static void SetNsResolv(string[] resolv) { Host.NsResolvContent = resolv; Host.NsResolv.StoredValues["$value"] = EnumerableExtensions.JoinToString(resolv, "\n"); Export(Host); }
public static SqlPreCommand?ImportRulesScript(XDocument doc, bool interactive) { Replacements replacements = new Replacements { Interactive = interactive }; Dictionary <string, Lite <RoleEntity> > rolesDic = roles.Value.ToDictionary(a => a.ToString() !); Dictionary <string, XElement> rolesXml = doc.Root.Element("Roles").Elements("Role").ToDictionary(x => x.Attribute("Name").Value); replacements.AskForReplacements(rolesXml.Keys.ToHashSet(), rolesDic.Keys.ToHashSet(), "Roles"); rolesDic = replacements.ApplyReplacementsToNew(rolesDic, "Roles"); try { var xmlOnly = rolesXml.Keys.Except(rolesDic.Keys).ToList(); if (xmlOnly.Any()) { throw new InvalidOperationException("roles {0} not found on the database".FormatWith(xmlOnly.ToString(", "))); } foreach (var kvp in rolesXml) { var r = rolesDic[kvp.Key]; var current = GetMergeStrategy(r); var should = kvp.Value.Attribute("MergeStrategy")?.Let(t => t.Value.ToEnum <MergeStrategy>()) ?? MergeStrategy.Union; if (current != should) { throw new InvalidOperationException("Merge strategy of {0} is {1} in the database but is {2} in the file".FormatWith(r, current, should)); } EnumerableExtensions.JoinStrict( roles.Value.RelatedTo(r), kvp.Value.Attribute("Contains").Value.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries), sr => sr.ToString(), s => rolesDic[s].ToString(), (sr, s) => 0, "subRoles of {0}".FormatWith(r)); } } catch (InvalidOperationException ex) { throw new InvalidRoleGraphException("The role graph does not match:\r\n" + ex.Message); } var dbOnlyWarnings = rolesDic.Keys.Except(rolesXml.Keys).Select(n => new SqlPreCommandSimple("-- Alien role {0} not configured!!".FormatWith(n)) ).Combine(Spacing.Simple); SqlPreCommand?result = ImportFromXml.GetInvocationListTyped() .Select(inv => inv(doc.Root, rolesDic, replacements)).Combine(Spacing.Triple); if (replacements.Values.Any(a => a.Any())) { SafeConsole.WriteLineColor(ConsoleColor.Red, "There are renames! Remember to export after executing the script"); } if (result == null && dbOnlyWarnings == null) { return(null); } return(SqlPreCommand.Combine(Spacing.Triple, new SqlPreCommandSimple("-- BEGIN AUTH SYNC SCRIPT"), new SqlPreCommandSimple("use {0}".FormatWith(Connector.Current.DatabaseName())), dbOnlyWarnings, result, new SqlPreCommandSimple("-- END AUTH SYNC SCRIPT"))); }
public void EnumerableToConcurrentHashSetThrowsIfSourceCollectionIsNull() { List <int> list = null; Assert.Throws <ArgumentNullException>(() => EnumerableExtensions.ToConcurrentHashSet(list)); }
public void AtOrDefault_FromEnumerableExtensions_GivenIndexOurOfRange_ReturnsDefaultValue_WhenExecutedOnValueCollection(int index, int length) { var source = Enumerable.Range(0, length); Assert.Equal(default(int), EnumerableExtensions.AtOrDefault(source, index)); }
public void AdjustWidths_EmptyList() { var actual = AccessibleListView.AdjustWidths(EmptyWidthList, 0); EnumerableExtensions.EnumerateSame(EmptyWidthList, actual); }
/// <inheritdoc/> protected override void OnFrameApply(ImageFrame <TPixel> source) { if (this.Size <= 0 || this.Size > source.Height || this.Size > source.Width) { throw new ArgumentOutOfRangeException(nameof(this.Size)); } int startY = this.SourceRectangle.Y; int endY = this.SourceRectangle.Bottom; int startX = this.SourceRectangle.X; int endX = this.SourceRectangle.Right; int size = this.Size; int offset = this.Size / 2; // Align start/end positions. int minX = Math.Max(0, startX); int maxX = Math.Min(source.Width, endX); int minY = Math.Max(0, startY); int maxY = Math.Min(source.Height, endY); // Reset offset if necessary. if (minX > 0) { startX = 0; } if (minY > 0) { startY = 0; } // Get the range on the y-plane to choose from. IEnumerable <int> range = EnumerableExtensions.SteppedRange(minY, i => i < maxY, size); Parallel.ForEach( range, this.Configuration.GetParallelOptions(), y => { int offsetY = y - startY; int offsetPy = offset; // Make sure that the offset is within the boundary of the image. while (offsetY + offsetPy >= maxY) { offsetPy--; } Span <TPixel> row = source.GetPixelRowSpan(offsetY + offsetPy); for (int x = minX; x < maxX; x += size) { int offsetX = x - startX; int offsetPx = offset; while (x + offsetPx >= maxX) { offsetPx--; } // Get the pixel color in the centre of the soon to be pixelated area. TPixel pixel = row[offsetX + offsetPx]; // For each pixel in the pixelate size, set it to the centre color. for (int l = offsetY; l < offsetY + size && l < maxY; l++) { for (int k = offsetX; k < offsetX + size && k < maxX; k++) { source[k, l] = pixel; } } } }); }
public int[] Hyperlinq_Enumerable_Value() => EnumerableExtensions.AsValueEnumerable <TestEnumerable.Enumerable, TestEnumerable.Enumerable.Enumerator, int>(enumerableValue, enumerable => enumerable.GetEnumerator()) .Select(item => item) .ToArray();
public async Task <IActionResult> Edit(Guid id, [Bind("OrganizationId,RegistrationDate,OrganizationCode,OrganizationName,RefOrganizationTypeId,ParentOrganizationId,Contact,Phone,RefLocationId,Address,Latitude,Longitude,IsOrganizationUnit,IsTenant")] Organization organization, string[] RefLocationId) { if (id != organization.OrganizationId) { return(NotFound()); } if (ModelState.IsValid) { try { // Gets the last non-null item in RefLocationId array, // the array might have null values for locations left empty // and this assigns the last non-null location to RefLocationId if (RefLocationId.Length != 0) { var location = (from r in RefLocationId where !string.IsNullOrEmpty(r) select r) .OrderByDescending(r => r).Count(); organization.RefLocationId = RefLocationId[location - 1]; } _context.Update(organization); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrganizationExists(organization.OrganizationId)) { return(NotFound()); } else { throw; } } TempData["messageType"] = "success"; TempData["messageTitle"] = "RECORD UPDATED"; TempData["message"] = "Record successfully updated"; return(RedirectToAction(nameof(Index), new { id = organization.ParentOrganizationId })); } ViewData["ParentId"] = organization.ParentOrganizationId; var locationTypes = _context.LocationTypes; ViewData["RefLocationTypes"] = locationTypes; ViewData["RefLocationTypesCount"] = locationTypes.Count(); ViewData["RefLocationId"] = new SelectList(_context .Locations .Include(x => x.LocationTypes) .Where(x => x.LocationTypes.LocationLevel == 1 && x.ParentLocationId == null) .Select(x => new { x.RefLocationId, x.LocationName }), "RefLocationId", "LocationName"); //parents for location h var allLocations = _context.Locations; var locations = EnumerableExtensions.ListLocations(allLocations, organization.RefLocationId); ViewData["RefLocationParents"] = locations.OrderBy(x => x.RefLocationTypeId); ViewData["ParentOrganizationId"] = new SelectList(_context.Organizations.Where(x => x.IsOrganizationUnit == true), "OrganizationId", "OrganizationName", organization.ParentOrganizationId); ViewData["RefOrganizationTypeId"] = new SelectList(_context.OrganizationTypes, "RefOrganizationTypeId", "OrganizationType", organization.RefOrganizationTypeId); return(View(organization)); }
public int Hyperlinq_Enumerable_Value() => EnumerableExtensions.AsValueEnumerable <TestEnumerable.Enumerable, TestEnumerable.Enumerable.Enumerator, int>(enumerableValue, enumerable => enumerable.GetEnumerator()) .Count();
/// <inheritdoc/> protected override void OnApply(ImageBase <TColor> source, Rectangle sourceRectangle) { int startY = sourceRectangle.Y; int endY = sourceRectangle.Bottom; int startX = sourceRectangle.X; int endX = sourceRectangle.Right; int size = this.Value; int offset = this.Value / 2; // Align start/end positions. int minX = Math.Max(0, startX); int maxX = Math.Min(source.Width, endX); int minY = Math.Max(0, startY); int maxY = Math.Min(source.Height, endY); // Reset offset if necessary. if (minX > 0) { startX = 0; } if (minY > 0) { startY = 0; } // Get the range on the y-plane to choose from. IEnumerable <int> range = EnumerableExtensions.SteppedRange(minY, i => i < maxY, size); TColor[] target = new TColor[source.Width * source.Height]; using (PixelAccessor <TColor> sourcePixels = source.Lock()) using (PixelAccessor <TColor> targetPixels = target.Lock <TColor>(source.Width, source.Height)) { Parallel.ForEach( range, this.ParallelOptions, y => { int offsetY = y - startY; int offsetPy = offset; for (int x = minX; x < maxX; x += size) { int offsetX = x - startX; int offsetPx = offset; // Make sure that the offset is within the boundary of the image. while (offsetY + offsetPy >= maxY) { offsetPy--; } while (x + offsetPx >= maxX) { offsetPx--; } // Get the pixel color in the centre of the soon to be pixelated area. // ReSharper disable AccessToDisposedClosure TColor pixel = sourcePixels[offsetX + offsetPx, offsetY + offsetPy]; // For each pixel in the pixelate size, set it to the centre color. for (int l = offsetY; l < offsetY + size && l < maxY; l++) { for (int k = offsetX; k < offsetX + size && k < maxX; k++) { targetPixels[k, l] = pixel; } } } }); source.SetPixels(source.Width, source.Height, target); } }
private static void ScheduleInfo(IEnumerable <ClassSchedule> schedules) { var placements = schedules .Select(x => x.CoursesPlacements.Values) .ToList(); var timesPerCourse = placements .Select(x => x.Select(y => { var classTimes = new List <ClassTime>(); IEnumerable <IClassActivity> classActivities = EnumerableExtensions.AsEnumerable(y.Lecture, y.PracticeClass, y.Lab); foreach (IClassActivity classActivity in classActivities) { if (classActivity != null) { classTimes.AddRange(classActivity.Times); } } return(Course: y.Course, Times: classTimes); })) .Select(x => x.ToDictionary(y => y.Course, y => y.Times)) .ToList(); var times = timesPerCourse .Select(x => x.Values.SelectMany(y => y)) .Select(x => x .OrderBy(y => y.Day) .ThenBy(y => y.Start) .ToList() ) .ToList(); var zipped = schedules .Zip(placements) .Zip(timesPerCourse, (tuple, second) => (tuple.First, tuple.Second, second)) .Zip(times, (tuple, second) => (tuple.First, tuple.Second, tuple.second, second)) .Select(x => new { Schedule = x.First, Placements = x.Second, TimesPerCourse = x.Item3, Times = x.Item4, Weight = x.First.Weight, PermutationIndex = x.First.PermutationIndex, }) .ToList(); var orderedSchedulesInfos = zipped .OrderBy(x => x.Weight) .ToList(); //var free = orderedSchedulesInfos // .Select(schedule => // { // int freeDaysCount = 0; // for (DayOfWeek day = DayOfWeek.Sunday; day <= DayOfWeek.Thursday; day++) // { // bool found = false; // foreach (ClassTime time in schedule.Times) // { // if (time.Day == day) // { // found = true; // break; // } // } // if (!found) // { // freeDaysCount++; // } // } // return new // { // Schedule = schedule, // FreeDaysCount = freeDaysCount, // Weight = schedule.Weight, // PermutationIndex = schedule.PermutationIndex, // }; // }) // .OrderByDescending(x => x.FreeDaysCount) // .ThenBy(x => x.Weight) // .ToList(); }
public void SkipLast_NullSource_Throws() { Assert.Throws <ArgumentNullException>(() => EnumerableExtensions.SkipLast <object>(null, 0).ToArray()); }
private Task InitializeMoods() { return(Task.Factory .StartNew(() => { var moods = new List <MoodTerm>(); IEnumerable <MoodTerm> result; using (var session = _documentStore.OpenSession()) { result = session .Query <MoodTerm>() .ToArray(); } if (!result.Any()) { var allMoods = GetItems(ListTermsType.Mood); using (var session = _documentStore.OpenSession()) { int i = 0; foreach (var listTermsItem in allMoods) { MoodTerm term = new MoodTerm(); term.Name = listTermsItem.Name; term.Index = i; moods.Add(term); session.Store(term); i++; } session.SaveChanges(); } } else { moods.AddRange(result.OrderBy(m => m.Id)); } return moods; }) .ContinueWith(task => { if (task.Exception != null) { return new TermModel[0]; } // Load stuff from db, such as number of times its been used etc return EnumerableExtensions.Select(task.Result, t => new TermModel(t.Id, WebUtility.HtmlDecode(t.Name), ListTermsType.Mood) { Count = t.Count }); }) .ContinueWith(task => { foreach (var termModel in task.Result) { termModel.PropertyChanged += TermModelOnPropertyChanged; _moods.Add(termModel); } }, _scheduler)); }
public void At_FromEnumerableExtensions_GivenIndexOurOfRange_ThrowsIndexOurOfRangeException(int index, int length) { var source = Enumerable.Range(0, length); Assert.Throws <IndexOutOfRangeException>(() => EnumerableExtensions.At(source, index)); }
private Task InitializeStyles() { return(Task.Factory .StartNew(() => { var styles = new List <StyleTerm>(); IEnumerable <StyleTerm> result; using (var session = _documentStore.OpenSession()) { result = session .Query <StyleTerm>() .ToArray(); } if (!result.Any()) { var allStyles = GetItems(ListTermsType.Style); using (var session = _documentStore.OpenSession()) { int i = 0; foreach (var listTermsItem in allStyles) { StyleTerm term = new StyleTerm(); term.Name = listTermsItem.Name; term.Index = i; styles.Add(term); session.Store(term); i++; } string[] additionalStyles = new[] { "dubstep", "british metal", "doom metal", "industrial metal", "metalcore", "post-rock", "post-metal" }; foreach (var additionalStyle in additionalStyles) { var term = new StyleTerm { Name = additionalStyle, Index = i }; styles.Add(term); session.Store(term); i++; } session.SaveChanges(); } } else { styles.AddRange(result.OrderBy(s => s.Index)); } return styles.OrderBy(s => s.Name); }) .ContinueWith(task => { if (task.Exception != null) { return new TermModel[0]; } // Load stuff from db, such as number of times its been used etc return EnumerableExtensions.Select(task.Result, t => new TermModel(t.Id, WebUtility.HtmlDecode(t.Name), ListTermsType.Style) { Count = t.Count }); }) .ContinueWith(task => { foreach (var termModel in task.Result) { termModel.PropertyChanged += TermModelOnPropertyChanged; _styles.Add(termModel); } }, _scheduler)); }
public TestType Test_SingleOrDefault_Method() => EnumerableExtensions.FirstOrDefault(new OptimizedEnumerable <TestType>());
public void EnumerableExtensions_ConcatMany_Null_ThrowsException() { Assert.Throws <ArgumentNullException>(() => EnumerableExtensions.ConcatMany((IEnumerable <object>)null).ToArray()); }