public Announcement(string description, string type, string operatorName, DateTime? startDate, DateTime? endDate, Coordinate location, IEnumerable<string> modes) { this.OperatorName = operatorName; this.Description = description; this.StartDate = startDate; this.EndDate = endDate; this.Location = location; this.Type = type; this.Modes.AddRange(modes); this.RelativeDateString = TimeConverter.ToRelativeDateString(StartDate, true); if (modes != null) { if (modes.Select(x => x.ToLower()).Contains("bus")) this.ModeImages.Add("/Images/64/W/ModeBus.png"); if (modes.Select(x => x.ToLower()).Contains("rail")) this.ModeImages.Add("/Images/64/W/ModeRail.png"); if (modes.Select(x => x.ToLower()).Contains("taxi")) this.ModeImages.Add("/Images/64/W/ModeTaxi.png"); if (modes.Select(x => x.ToLower()).Contains("boat")) this.ModeImages.Add("/Images/64/W/ModeBoat.png"); if (!this.ModeImages.Any()) this.ModeImages.Add("/Images/64/W/ModeBus.png"); } else { this.Modes.Add("bus"); this.ModeImages.Add("/Images/64/W/ModeBus.png"); } }
internal static IEnumerable<Document> GetDocumentsAffectedByRename(ISymbol symbol, Solution solution, IEnumerable<RenameLocation> renameLocations) { if (IsSymbolDefinedInsideMethod(symbol)) { // if the symbol was declared inside of a method, don't check for conflicts in non-renamed documents. return renameLocations.Select(l => solution.GetDocument(l.DocumentId)); } else { var documentIdOfRenameSymbolDeclaration = solution.GetDocument(symbol.Locations.First(l => l.IsInSource).SourceTree); if (symbol.DeclaredAccessibility == Accessibility.Private) { // private members or classes cannot be used outside of the project, so we should only scan documents of this project. Contract.ThrowIfFalse(renameLocations.Select(l => l.DocumentId.ProjectId).Distinct().Count() == 1); return documentIdOfRenameSymbolDeclaration.Project.Documents; } else { // We are trying to figure out the projects that directly depend on the project that contains the declaration for // the rename symbol. Other projects should not be affected by the rename. var symbolProjectId = documentIdOfRenameSymbolDeclaration.Project.Id; var relevantProjects = SpecializedCollections.SingletonEnumerable(symbolProjectId).Concat( solution.GetProjectDependencyGraph().GetProjectsThatDirectlyDependOnThisProject(symbolProjectId)); return relevantProjects.SelectMany(p => solution.GetProject(p).Documents); } } }
public void Add(IEnumerable<Interaction> interactions) { var keys = interactions.Select(i => i.Key); Supercede(keys); IList<BsonDocument> documents = interactions.Select(SparkBsonHelper.ToBsonDocument).ToList(); collection.InsertBatch(documents); }
private static XElement GenerateExtensionList(string name, IEnumerable<XmlExtension> extensions, bool includeUtf) { if (includeUtf) return new XElement(name, extensions.Select(x => new XElement("ext", x.FileExtension, new XAttribute("utf", ConvertXmlBoolean(x.UseUtf8Encoding))))); else return new XElement(name, extensions.Select(x => new XElement("ext", x.FileExtension))); }
public void LoadGroups(IEnumerable<PreviewGroup> previewGroups) { GroupControls.Clear(); xtraTabControlGroups.TabPages.Clear(); foreach (var groupControl in previewGroups.Select(previewGroup => new PreviewGroupControl(previewGroup))) GroupControls.Add(groupControl); xtraTabControlGroups.TabPages.AddRange(GroupControls.ToArray()); if (GroupControls.Count > 1) { xtraTabControlGroups.ShowTabHeader = DefaultBoolean.True; _mergedGroup = new PreviewGroup { Name = "Merged Slides", PresentationSourcePath = Path.Combine(ResourceManager.Instance.TempFolder.LocalPath, Path.GetFileName(Path.GetTempFileName())) }; FormProgress.SetTitle("Chill-Out for a few seconds...\nLoading slides..."); FormProgress.ShowProgress(); var thread = new Thread(() => _powerPointHelper.MergeFiles(_mergedGroup.PresentationSourcePath, previewGroups.Select(pg => pg.PresentationSourcePath).ToArray())); thread.Start(); while (thread.IsAlive) Application.DoEvents(); FormProgress.CloseProgress(); } else { xtraTabControlGroups.ShowTabHeader = DefaultBoolean.False; _mergedGroup = previewGroups.FirstOrDefault(); } }
public IEnumerable<CoefficientValue> CalculateCoefficientValues(IEnumerable<IndicatorValue> indicatorValues, IEnumerable<Dossier> dossiers, IEnumerable<Coefficient> coefficients) { var coefficientValues = new List<CoefficientValue>(); if (dossiers.Select(o => o.FieldsetId).Distinct().Count() > 1) throw new AsmsEx("in luna respectiva sunt dosare inregistrate la diferite seturi de campuri"); if (dossiers.Select(o => o.MeasuresetId).Distinct().Count() > 1) throw new AsmsEx("in luna respectiva sunt dosare inregistrate la diferite seturi de masuri"); //calculate each coefficient for all dossiers foreach (var coefficient in coefficients) { EvalSums(coefficient, indicatorValues); var calc = new CalcContext<decimal>(); foreach (var dossier in dossiers) { calc.Constants.Clear(); foreach (var indicatorValue in indicatorValues.Where(o => o.DossierId == dossier.Id)) { calc.Constants.Add("i" + indicatorValue.IndicatorId, indicatorValue.Value); } coefficientValues.Add(new CoefficientValue { CoefficientId = coefficient.Id, DossierId = dossier.Id, Value = Zero(() => calc.Evaluate(coefficient.Formula)), }); } } return coefficientValues; }
public static PackageQueryResult GetUpdates(ContextName context, string nuGetSite, PackageStability stability, IEnumerable<IPackageId> ids) { if (context == null) throw new ArgumentNullException("context"); if (nuGetSite == null) throw new ArgumentNullException("nuGetSite"); if (ids == null) throw new ArgumentNullException("ids"); using (var contextKey = PackageRegistry.OpenRegistryRoot(false, context)) { var service = new FeedContext_x0060_1(new Uri(nuGetSite)); var query = service.CreateQuery<V2FeedPackage>("GetUpdates") .AddQueryOption("packageIds", "'" + String.Join("|", ids.Select(p => p.Id)) + "'") .AddQueryOption("versions", "'" + String.Join("|", ids.Select(p => p.Version)) + "'") .AddQueryOption("includePrerelease", (stability == PackageStability.IncludePrerelease) ? "true" : "false") .AddQueryOption("includeAllVersions", "false"); var response = (QueryOperationResponse<V2FeedPackage>)query.Execute(); var packageMetadatas = response.Select(p => Deserialize(p, context, contextKey, nuGetSite)).ToArray(); return new PackageQueryResult( GetTotalCount(response, packageMetadatas), 0, 1, packageMetadatas ); } }
public Tuple<IEnumerable<string>, int> FindShortestRoute(IEnumerable<Route> routes, string from, string to) { Dijkstra.Dijkstra dijkstra; //Form adjacency matrix var stations = routes.Select(x => x.From) .Intersect(routes.Select(x => x.To)) .Distinct() .OrderBy(x => x) .ToList(); var numberOfStations = stations.Count(); var adjacencyMatrix = new double[numberOfStations,numberOfStations]; foreach (var route in routes) { adjacencyMatrix[stations.IndexOf(route.From), stations.IndexOf(route.To)] = route.TimeTaken; } var fromStationIndex = stations.IndexOf(from); var toStationIndex = stations.IndexOf(to); dijkstra = new Dijkstra.Dijkstra(adjacencyMatrix, fromStationIndex); var routeToDestination = new List<string>(); for (var currentNode = toStationIndex; currentNode != -1; currentNode = dijkstra.path[currentNode]) { routeToDestination.Add(stations[currentNode]); } routeToDestination.Reverse(); return Tuple.Create<IEnumerable<string>, int>(routeToDestination, (int)dijkstra.dist[toStationIndex]); }
/// <summary> /// Initializes a new instance of the <see cref="ManagedEigenObjectRecognizer"/> class. /// </summary> public ManagedEigenObjectRecognizer(IEnumerable<TargetFace> targetFaces, double eigenDistanceThreshold, int maxIter, double eps) { Debug.Assert(eigenDistanceThreshold >= 0.0, "Eigen-distance threshold should always >= 0.0"); Bitmap[] images = targetFaces.Select(x => x.Image).ToArray(); FloatImage[] eigenImages; FloatImage averageImage; CalcEigenObjects(images, maxIter, eps, out eigenImages, out averageImage); this.EigenValues = images.Select(x => EigenDecomposite(x, eigenImages, averageImage)).ToArray(); this.EigenImages = eigenImages; this.AverageImage = averageImage; this.Labels = targetFaces.Select(x => x.Key).ToArray(); this.EigenDistanceThreshold = eigenDistanceThreshold; nameLookup = new Dictionary<int, string>(); foreach (var face in targetFaces) { nameLookup[RecognitionUtility.Shorten(face.ID)] = face.Key; } try { forest = new ERTreesClassifier(); forest.Train(targetFaces); } catch (NullReferenceException) { // will occur if there is no 3d face points } }
void mainIn_OnNewDataEnabled(IEnumerable<CHDSample> data) { m_mainChartSeriesCh1.SetData(data.Select(s => s.x).ToArray()); m_mainChartSeriesCh2.SetData(data.Select(s => s.y).ToArray()); //m_mainChartSeriesCh3.SetData(data.Select(s => s.hall[2]).ToArray()); m_mainChartPanel.Chart.AutoFit(); }
public static IEnumerable<Token> Normalize( IEnumerable<Token> tokens, Func<string, bool> nameLookup) { var indexes = from i in tokens.Select( (t, i) => { var prev = tokens.ElementAtOrDefault(i - 1).ToMaybe(); return t.IsValue() && ((Value)t).ExplicitlyAssigned && prev.MapValueOrDefault(p => p.IsName() && !nameLookup(p.Text), false) ? Maybe.Just(i) : Maybe.Nothing<int>(); }).Where(i => i.IsJust()) select i.FromJustOrFail(); var toExclude = from t in tokens.Select((t, i) => indexes.Contains(i) ? Maybe.Just(t) : Maybe.Nothing<Token>()) .Where(t => t.IsJust()) select t.FromJustOrFail(); var normalized = tokens.Except(toExclude); return normalized; }
internal static void ValidateUniqueConstraint(ISaveRequestHandler handler, IEnumerable<Field> fields, string errorMessage = null, BaseCriteria groupCriteria = null) { if (handler.IsUpdate && !fields.Any(x => x.IndexCompare(handler.Old, handler.Row) != 0)) return; var criteria = groupCriteria ?? Criteria.Empty; foreach (var field in fields) if (field.IsNull(handler.Row)) criteria &= field.IsNull(); else criteria &= field == new ValueCriteria(field.AsObject(handler.Row)); var idField = (Field)((IIdRow)handler.Row).IdField; if (handler.IsUpdate) criteria &= (Field)idField != new ValueCriteria(idField.AsObject(handler.Old)); var row = handler.Row.CreateNew(); if (new SqlQuery() .Dialect(handler.Connection.GetDialect()) .From(row) .Select("1") .Where(criteria) .Exists(handler.UnitOfWork.Connection)) { throw new ValidationError("UniqueViolation", String.Join(", ", fields.Select(x => x.PropertyName ?? x.Name)), String.Format(!string.IsNullOrEmpty(errorMessage) ? (LocalText.TryGet(errorMessage) ?? errorMessage) : LocalText.Get("Validation.UniqueConstraint"), String.Join(", ", fields.Select(x => x.Title)))); } }
public dynamic RenderLayout(LayoutContext context, IEnumerable<LayoutComponentResult> layoutComponentResults) { string containerTag = context.State.ContainerTag; string containerId = context.State.ContainerId; string containerClass = context.State.ContainerClass; string itemTag = context.State.ItemTag; string itemClass = context.State.ItemClass; string prepend = context.State.Prepend; string append = context.State.Append; string separator = context.State.Separator; IEnumerable<dynamic> shapes = context.LayoutRecord.Display == (int)LayoutRecord.Displays.Content ? layoutComponentResults.Select(x => _contentManager.BuildDisplay(x.ContentItem, context.LayoutRecord.DisplayType)) : layoutComponentResults.Select(x => x.Properties); return Shape.Raw( Id: containerId, Items: shapes, Tag: containerTag, Classes: new [] { containerClass }, ItemTag: itemTag, ItemClasses: new [] { itemClass }, Prepend: prepend, Append: append, Separator: separator ); }
static List<MenuViewModel> GenerateMenu(IEnumerable<MenuItem> menuItems, int parentId) { var menuTree = new List<MenuViewModel>(); IEnumerable<MenuItem> upperLevelMenus; if (parentId == 0) { upperLevelMenus = menuItems.Where(m => m.ParentID == null).OrderBy(o=>o.Order).ThenBy(o=>o.Text); } else { upperLevelMenus = menuItems.Where(m => m.ParentID == parentId).OrderBy(o => o.Order).ThenBy(o => o.Text); } foreach (var menuItem in upperLevelMenus) { menuTree.Add(new MenuViewModel(menuItem)); } foreach (var menu in menuTree) { var children = menuItems.Select(m => m.ParentID == menu.MenuItemID); if (menuItems.Select(m => m.ParentID == menu.MenuItemID).Any()) menu.SubMenus = GenerateMenu(menuItems, menu.MenuItemID); } return menuTree; }
private static IEnumerable<IDictionary<string, object>> InsertRowsWithSeparateStatements(AdoAdapter adapter, IEnumerable<IDictionary<string, object>> data, IDbTransaction transaction, Table table, List<Column> columns, string insertSql, string selectSql) { if (transaction != null) { var insertCommand = new CommandHelper(adapter.SchemaProvider).Create(transaction.Connection, insertSql); var selectCommand = transaction.Connection.CreateCommand(); selectCommand.CommandText = selectSql; insertCommand.Transaction = transaction; selectCommand.Transaction = transaction; return data.Select(row => InsertRow(row, columns, table, insertCommand, selectCommand)).ToList(); } using (var connection = adapter.CreateConnection()) { using (var insertCommand = new CommandHelper(adapter.SchemaProvider).Create(connection, insertSql)) using (var selectCommand = connection.CreateCommand()) { selectCommand.CommandText = selectSql; connection.Open(); return data.Select(row => InsertRow(row, columns, table, insertCommand, selectCommand)).ToList(); } } }
public Tuple<double,double> CalculateValue(IEnumerable<Tuple<ITyreTemperature,ITyreTemperature>> tyreTemperatures) { var leftTyreTemperature = tyreTemperatures.Select(x => x.Item1.Value); var rightTyreTemperature = tyreTemperatures.Select(x => x.Item2.Value); return new Tuple<double, double>(leftTyreTemperature.Max(),rightTyreTemperature.Max()); }
public Announcement(string description, string type, string operatorName, DateTime? startDate, Coordinate location, IEnumerable<string> modes) { if (modes == null) throw new ArgumentNullException("modes"); this.OperatorName = operatorName; this.Description = description; this.StartDate = new Time(startDate.Value); this.Location = location; this.Kind = type; foreach (string mode in modes) this.Modes.Add(mode); if (modes != null) { if (modes.Select(x => x.ToLower()).Contains("bus")) this.ModeImages.Add("/Images/64/W/ModeBus.png"); if (modes.Select(x => x.ToLower()).Contains("rail")) this.ModeImages.Add("/Images/64/W/ModeRail.png"); if (modes.Select(x => x.ToLower()).Contains("taxi")) this.ModeImages.Add("/Images/64/W/ModeTaxi.png"); if (modes.Select(x => x.ToLower()).Contains("boat")) this.ModeImages.Add("/Images/64/W/ModeBoat.png"); if (!this.ModeImages.Any()) this.ModeImages.Add("/Images/64/W/ModeBus.png"); } else { this.Modes.Add("bus"); this.ModeImages.Add("/Images/64/W/ModeBus.png"); } }
protected override void ProcessRenderings(Item item, LayoutDefinition layout, DeviceDefinition device, IEnumerable<RenderingDefinition> renderings) { if (renderings.Any()) { if (!ShouldProcess(item.GetProviderPath(), $"Remove rendering(s) '{renderings.Select(r => r.ItemID.ToString()).Aggregate((seed, curr) => seed + ", " + curr)}' from device {Device.Name}")) return; foreach ( var instanceRendering in renderings.Select(rendering => device.Renderings.Cast<RenderingDefinition>() .FirstOrDefault(r => r.UniqueId == rendering.UniqueId)) .Where(instanceRendering => instanceRendering != null) .Reverse()) { device.Renderings.Remove(instanceRendering); } item.Edit(p => { var outputXml = layout.ToXml(); Item[LayoutFieldId] = outputXml; }); } else { WriteError(typeof(ObjectNotFoundException), "Cannot find a rendering to remove", ErrorIds.RenderingNotFound, ErrorCategory.ObjectNotFound, null); } }
public void ReceiveHunks(int documentId, int serverUpdateStamp, int clientUpdateStamp, IEnumerable<HunkDTO> hunkDtos) { DB(() => { var document = EntityMappingContext.Current.Documents.First(x => x.Id == documentId); DocumentEditState documentEditState = DS.DocumentEditStates[document]; PerDocumentClientState clientState = documentEditState.ClientStates[User]; if (clientUpdateStamp == clientState.ClientUpdateIndex + 1) { // got the index we expected! // apply this update // and then get stored updates one at a time from the sorted store foreach (var hunk in hunkDtos.Select(hunkDto => hunkDto.Convert())) { document.AppendHunk(hunk, User); } } else { //store it for subsequent application } }); var hunks = new List<Hunk>(hunkDtos.Select(_ => _.Convert())); foreach (Hunk hunk in hunks) System.Diagnostics.Debug.WriteLine(hunk.GetType() + " " + hunk); }
internal static IEnumerable<Document> GetDocumentsAffectedByRename(ISymbol symbol, Solution solution, IEnumerable<RenameLocation> renameLocations) { if (IsSymbolDefinedInsideMethod(symbol)) { // if the symbol was declared inside of a method, don't check for conflicts in non-renamed documents. return renameLocations.Select(l => solution.GetDocument(l.DocumentId)); } else { var documentsOfRenameSymbolDeclaration = symbol.Locations.Where(l => l.IsInSource).Select(l => solution.GetDocument(l.SourceTree)); var projectIdsOfRenameSymbolDeclaration = documentsOfRenameSymbolDeclaration.SelectMany(d => d.GetLinkedDocumentIds()) .Concat(documentsOfRenameSymbolDeclaration.First().Id) .Select(d => d.ProjectId).Distinct(); if (ShouldRenameOnlyAffectDeclaringProject(symbol)) { var isSubset = renameLocations.Select(l => l.DocumentId.ProjectId).Distinct().Except(projectIdsOfRenameSymbolDeclaration).IsEmpty(); Contract.ThrowIfFalse(isSubset); return projectIdsOfRenameSymbolDeclaration.SelectMany(p => solution.GetProject(p).Documents); } else { // We are trying to figure out the projects that directly depend on the project that contains the declaration for // the rename symbol. Other projects should not be affected by the rename. var relevantProjects = projectIdsOfRenameSymbolDeclaration.Concat(projectIdsOfRenameSymbolDeclaration.SelectMany(p => solution.GetProjectDependencyGraph().GetProjectsThatDirectlyDependOnThisProject(p))).Distinct(); return relevantProjects.SelectMany(p => solution.GetProject(p).Documents); } } }
public void SaveSelectedCategories(int promotionId, IEnumerable<string> selectedCategories) { var query = _dbcontext.KeywordCategories.Where(c => c.PromotionFK == promotionId); if (!query.Any()) { foreach ( var keyCategory in selectedCategories.Select( category => new KeywordCategory { PromotionFK = promotionId, KeywordCategory1 = category }) ) { _dbcontext.KeywordCategories.Add(keyCategory); } _dbcontext.SaveChanges(); } else // categories exists so update them { // delete them first foreach (KeywordCategory kc in query) { _dbcontext.KeywordCategories.Remove(kc); } _dbcontext.SaveChanges(); // add them foreach ( var keyCategory in selectedCategories.Select( category => new KeywordCategory { PromotionFK = promotionId, KeywordCategory1 = category }) ) { _dbcontext.KeywordCategories.Add(keyCategory); } _dbcontext.SaveChanges(); } }
public string Build(IEnumerable<string> columns, bool upsert = true) { var sb = new StringBuilder(); sb.Append("IF EXISTS(SELECT * FROM [dbo].") .Append("[" + _tableName + "]").Append(" WHERE [").Append(_primaryKey).Append("] = @").Append(_primaryKey).AppendLine(")"); sb.Append("UPDATE [dbo].").AppendLine("[" + _tableName + "]"); var sets = columns.Skip(1).Select(m => string.Format("[{0}] = @{0}", m)); sb.Append("SET ").AppendLine(string.Join(",", sets)); sb.Append("WHERE [").Append(_primaryKey).Append("] = @").AppendLine(_primaryKey); sb.AppendLine("ELSE"); sb.Append("INSERT INTO [dbo].") .Append("[" + _tableName + "]") .Append(" (") .Append(string.Join(",", columns.Select(m => string.Format("[{0}]", m)))).AppendLine(")"); sb.Append("VALUES ") .Append("(") .Append(string.Join(",", columns.Select(m => string.Format("@{0}", m)))).AppendLine(")"); return sb.ToString(); }
static IEnumerable<string> alignText(IEnumerable<string> lines, Alignment alignment, int width) { switch (alignment) { case Alignment.LEFT: return lines; case Alignment.RIGHT: return lines.Select(t => new String(' ', width - t.Length) + t); case Alignment.CENTER: return lines.Select(t => new String(' ', (width - t.Length) / 2) + t); case Alignment.JUSTIFY: return lines.Select(t => { var words = t.Split(); var spaceRequired = width - t.Length; var spacing = spaceRequired / (words.Length - 1) + 1; return string.Join(new String(' ', spacing), words); }); default: throw new NotImplementedException(); } }
public OrderExportContext(IEnumerable<Order> orders, Func<int[], IList<Customer>> customers, Func<int[], Multimap<int, RewardPointsHistory>> rewardPointsHistory, Func<int[], IList<Address>> addresses, Func<int[], Multimap<int, OrderItem>> orderItems, Func<int[], Multimap<int, Shipment>> shipments) { if (orders == null) { _orderIds = new List<int>(); _customerIds = new List<int>(); _addressIds = new List<int>(); } else { _orderIds = new List<int>(orders.Select(x => x.Id)); _customerIds = new List<int>(orders.Select(x => x.CustomerId)); _addressIds = orders.Select(x => x.BillingAddressId) .Union(orders.Select(x => x.ShippingAddressId ?? 0)) .Where(x => x != 0) .Distinct() .ToList(); } _funcCustomers = customers; _funcRewardPointsHistories = rewardPointsHistory; _funcAddresses = addresses; _funcOrderItems = orderItems; _funcShipments = shipments; }
public static string[] GetAllowedResourceNames(string userId, IEnumerable<Resource> resources) { var rightsService = Discovery.GetRightsService(); string[] allowedResources = new string[0]; try { string[] resourceUris = resources.Select(r => String.Format(URI_RESOURCE_FORMAT, r.ResourceName)).ToArray(); allowedResources = rightsService .GetAccessibleFrom(userId, resourceUris, URI_RIGHT_RESOURCE_EXECUTE) .Select(uri => uri.Name) .ToArray(); rightsService.Close(); } catch (Exception e) { rightsService.Abort(); Log.Error("Exception on getting allowed resources from UserManagement for user " + userId + ": " + e.ToString()); } if (IsRightsIgnored()) allowedResources = resources.Select(r => r.ResourceName).ToArray(); Log.Info(String.Format("Allowed resources for user '{0}': [{1}]", userId, String.Join(", ", allowedResources))); return allowedResources; }
/// <summary></summary> public void HorizontalFlightTest(IEnumerable<HelicopterLogSnapshot> flightLog) { if (flightLog == null) return; if (Chart == null) return; // Add test Lines to demonstrate the control Chart.Primitives.Clear(); IEnumerable<Vector3> horizontalGPSSamples = flightLog.Select(e => e.Observed.Position).Where(p => p != Vector3.Zero); float radiusVariance = new Vector3( horizontalGPSSamples.Select(e => e.X).StandardDeviation(), horizontalGPSSamples.Select(e => e.Y).StandardDeviation(), horizontalGPSSamples.Select(e => e.Z).StandardDeviation()).Length(); Console.WriteLine(@"Radius std. dev. of GPS data: " + radiusVariance + @"m."); // GPS observations only occur every 1 second, so ignore Vector3.Zero positions (not 100% safe, but close enough) SwordfishGraphHelper.AddLineXZ(Chart, "GPS", Colors.Orange, horizontalGPSSamples); SwordfishGraphHelper.AddLineXZ(Chart, "Estimated", Colors.Navy, flightLog.Select(e => e.Estimated.Position)); SwordfishGraphHelper.AddLineXZ(Chart, "True", Colors.DarkRed, flightLog.Select(e => e.True.Position)); Chart.Title = "HorizontalFlightTest()"; Chart.XAxisLabel = "X [m]"; Chart.YAxisLabel = "Z [m]"; Chart.RedrawPlotLines(); }
public dynamic RenderLayout(LayoutContext context, IEnumerable<LayoutComponentResult> layoutComponentResults) { int columns = Convert.ToInt32(context.State.Columns); bool horizontal = Convert.ToString(context.State.Alignment) != "vertical"; string gridTag = Convert.ToString(context.State.GridTag); string gridClass = Convert.ToString(context.State.GridClass); if (!String.IsNullOrEmpty(gridClass)) gridClass += " "; gridClass += "projector-layout projector-grid-layout"; string gridId = Convert.ToString(context.State.GridId); string rowTag = Convert.ToString(context.State.RowTag); string rowClass = Convert.ToString(context.State.RowClass); string cellTag = Convert.ToString(context.State.CellTag); string cellClass = Convert.ToString(context.State.CellClass); string emptyCell = Convert.ToString(context.State.EmptyCell); IEnumerable<dynamic> shapes = context.LayoutRecord.Display == (int)LayoutRecord.Displays.Content ? layoutComponentResults.Select(x => _contentManager.BuildDisplay(x.ContentItem, context.LayoutRecord.DisplayType)) : layoutComponentResults.Select(x => x.Properties); return Shape.Grid(Id: gridId, Horizontal: horizontal, Columns: columns, Items: shapes, Tag: gridTag, Classes: new[] { gridClass }, RowTag: rowTag, RowClasses: new[] { rowClass }, CellTag: cellTag, CellClasses: new[] { cellClass }, EmptyCell: emptyCell); }
private static IList<RefinementGroup> GenerateAvailableProductRefinementsFrom(IEnumerable<ProductTitle> productsFound) { var brandsRefinementGroup = productsFound .Select(p => p.Brand).Distinct().ToList() .ConvertAll<IProductAttribute>(b => (IProductAttribute)b) .ConvertToRefinementGroup(RefinementGroupings.brand); var colorsRefinementGroup = productsFound .Select(p => p.Color).Distinct().ToList() .ConvertAll<IProductAttribute>(c => (IProductAttribute)c) .ConvertToRefinementGroup(RefinementGroupings.color); var sizesRefinementGroup = (from p in productsFound from si in p.Products select si.Size).Distinct().ToList() .ConvertAll<IProductAttribute>(s => (IProductAttribute)s) .ConvertToRefinementGroup(RefinementGroupings.size); IList<RefinementGroup> refinementGroups = new List<RefinementGroup>(); refinementGroups.Add(brandsRefinementGroup); refinementGroups.Add(colorsRefinementGroup); refinementGroups.Add(sizesRefinementGroup); return refinementGroups; }
private static string ParseFiles(IEnumerable<string> filePaths) { var classLines = new List<string>(); var usingsSet = new HashSet<string>(); Func<string, bool> isUsingStmt = (x) => x.StartsWith("using"); var lines = filePaths.Select(x => File.ReadAllLines(x)).SelectMany(x => x).ToList(); foreach (var line in filePaths.Select(x => File.ReadAllLines(x)).SelectMany(x => x)) { if (isUsingStmt(line)) { usingsSet.Add(line); } else { classLines.Add(line); } } var result = usingsSet.ToList(); result.AddRange(classLines); var builder = new StringBuilder(); result.ForEach(x => builder.AppendLine(x)); return builder.ToString(); }
public ParallelClock(IEnumerable<IClock> clocks) { this.clocks = clocks; FirstTick = clocks.Select(clock => clock.FirstTick).DefaultIfEmpty(TimeSpan.Zero).Min(); LastTick = clocks.Select(clock => clock.LastTick).DefaultIfEmpty(TimeSpan.Zero).Max(); Duration = clocks.Select(clock => clock.Duration).DefaultIfEmpty(TimeSpan.Zero).Max(); }
// AsFieldsAndAliasFields internal static IEnumerable <string> AsFieldsAndAliasFields(this IEnumerable <string> values, string leftAlias, string rightAlias, IDbSetting dbSetting) => values?.Select(value => value.AsFieldAndAliasField(leftAlias, rightAlias, dbSetting));
// AsFieldsAndParameters internal static IEnumerable <string> AsFieldsAndParameters(this IEnumerable <string> values, int index, IDbSetting dbSetting) => values?.Select(value => value.AsFieldAndParameter(index, dbSetting));
// AsAliasFields internal static IEnumerable <string> AsAliasFields(this IEnumerable <string> values, string alias, IDbSetting dbSetting) => values?.Select(value => value.AsAliasField(alias, dbSetting));
static public IEnumerable <MotionParam> KeyboardPressSequence( this IEnumerable <VirtualKeyCode> listKey) => listKey?.Select(key => KeyboardPressCombined(new[] { key }));
public CipherDetailsResponseModel(CipherDetails cipher, GlobalSettings globalSettings, IEnumerable <CollectionCipher> collectionCiphers, string obj = "cipherDetails") : base(cipher, globalSettings, obj) { CollectionIds = collectionCiphers?.Select(c => c.CollectionId) ?? new List <Guid>(); }
private async Task <IEnumerable <string> > GetLibraryVersionsAsync(string groupName, CancellationToken cancellationToken) { IEnumerable <Asset> assets = await GetAssetsAsync(groupName, cancellationToken).ConfigureAwait(false); return(assets?.Select(a => a.Version)); }
public IQuery WhereIn(FieldPath field, IEnumerable <object> values) { var query = _collectionReference.WhereIn(field?.ToNative(), values?.Select(x => x.ToNativeFieldValue()).ToList()); return(new QueryWrapper(query)); }
public static string ToEntry(IEnumerable <SortSetting> source) { return(source?.Select(x => x.ToEntryString()).Join(",")); }
// AsFieldsAndParameters internal static IEnumerable <string> AsFieldsAndParameters(this IEnumerable <Field> fields, int index = 0, string prefix = Constant.DefaultParameterPrefix) { return(fields?.Select(field => field.AsFieldAndParameter(index, prefix))); }
/* IEnumerable<PropertyInfo> */ // AsFields internal static IEnumerable <string> AsFields(this IEnumerable <Field> fields) { return(fields?.Select(field => field.AsField())); }
/// <summary>Initializes a new instance of the <see cref="SafePSIDArray"/> class.</summary> /// <param name="pSIDs">A list of <see cref="SafePSID"/> instances.</param> public SafePSIDArray(IEnumerable <SafePSID> pSIDs) : this(pSIDs?.Select(p => (PSID)p)) { }
public ICollection <string> BuildFcsFundingStreamPeriodCodes(IEnumerable <FcsContractAllocation> fcsContractAllocations) { return(new HashSet <string>(fcsContractAllocations? .Select(f => f.FundingStreamPeriodCode).ToList(), StringComparer.OrdinalIgnoreCase)); }
public override IEnumerable <string> Convert([CanBeNull] IEnumerable <KeyValuePair <string, string> > source) { return(source?.Select(item => $"{item.Key}={item.Value}")); }
public IQuery WhereArrayContainsAny(string field, IEnumerable <object> values) { var query = _collectionReference.WhereArrayContainsAny(field, values?.Select(x => x.ToNativeFieldValue()).ToList()); return(new QueryWrapper(query)); }
public Process(string serviceName, IEnumerable <KeyValuePair <string, object> > processTags) : this(serviceName, processTags?.Select(pt => pt.ToJaegerTag()).ToDictionary(pt => pt.Key, pt => pt)) { }
/// <summary> /// Creates a new <see cref="EnumKeyword"/>. /// </summary> /// <param name="values">The collection of enum values.</param> public EnumKeyword(IEnumerable <JsonElement> values) { Values = values?.Select(e => e.Clone()).ToList() ?? throw new ArgumentNullException(nameof(values)); }
/// <summary> /// Variable-length VisualFeatures arguments to a string. /// </summary> /// <param name="features">Variable-length VisualFeatures.</param> /// <returns>The visual features query parameter string.</returns> private string VisualFeaturesToString(IEnumerable <VisualFeature> features) { return(VisualFeaturesToString(features?.Select(feature => feature.ToString()).ToArray())); }
internal static IEnumerable <Location> ToLocations(this IEnumerable <MapLocation> mapLocations) => mapLocations?.Select(a => a.ToLocation());
public MultiTermsAggregationDescriptor <T> Terms(IEnumerable <Func <TermDescriptor <T>, ITerm> > ranges) => Assign(ranges?.Select(r => r(new TermDescriptor <T>())).ToListOrNullIfEmpty(), (a, v) => a.Terms = v);
public static IEnumerable <LogViewModel> DtoToViewModels(IEnumerable <LogDto> dtos) { return(dtos?.Select(DtoToViewModel)); }
public IEnumerable<RaspberryResponseModel> GetList() { IEnumerable<Raspberry> dtoItems = _raspberryService.GetList(); IEnumerable<RaspberryResponseModel> itemList = dtoItems?.Select(x => ModelBinder.Instance.ConvertToRaspberryResponseModel(x)); return itemList; }
public DateRangeAggregationDescriptor <T> Ranges(IEnumerable <Func <DateRangeExpressionDescriptor, IDateRangeExpression> > ranges) => Assign(ranges?.Select(r => r(new DateRangeExpressionDescriptor())).ToListOrNullIfEmpty(), (a, v) => a.Ranges = v);
internal static BindingList <Price> ConvertPricesFromBoToDto(IEnumerable <BoPrice> boPrices) { return(new BindingList <Price>(boPrices?.Select(ConvertPriceFromBoToDto).ToList())); }
public Names(IEnumerable <string> names) : this(names?.Select(n => (Name)n).ToList()) { }
// AsFieldsAndAliasFields internal static IEnumerable <string> AsFieldsAndAliasFields(this IEnumerable <Field> fields, string alias) { return(fields?.Select(field => field.AsFieldAndAliasField(alias))); }
internal static List <BoPrice> ConvertPricesFromDtoToBo(IEnumerable <Price> dtoPrices) { return(dtoPrices?.Select(ConvertPriceFromDtoToBo).ToList()); }
public TestsGuidList(IEnumerable <TestDescription> testDescriptions) : this(testDescriptions?.Select(t => t.Id)) { }
/// <summary> /// Build up an index of properties in the <paramref name="supportedFhirTypes"/>. /// </summary> /// <param name="fhirModel">IFhirModel that can provide mapping from resource names to .Net types</param> /// <param name="supportedFhirTypes">List of (resource and element) types to be indexed.</param> public FhirPropertyIndex(IFhirModel fhirModel, IEnumerable <Type> supportedFhirTypes) //Hint: supply all Resource and Element types from an assembly { _fhirModel = fhirModel; _fhirTypeInfoList = supportedFhirTypes?.Select(sr => CreateFhirTypeInfo(sr)).ToList(); }
public IMatcher[] Map([CanBeNull] IEnumerable <MatcherModel> matchers) { return(matchers?.Select(Map).Where(m => m != null).ToArray()); }
public override IEnumerable <KeyValuePair <string, EndpointSettings> > Convert([CanBeNull] IEnumerable <IDockerNetwork> source) { return(source?.Select(network => new KeyValuePair <string, EndpointSettings>(network.Name, new EndpointSettings { NetworkID = network.Id, Aliases = this.configuration.NetworkAliases?.ToArray() }))); }