当前位置: 首页>>代码示例>>C#>>正文


C# IEnumerable.Select方法代码示例

本文整理汇总了C#中IEnumerable.Select方法的典型用法代码示例。如果您正苦于以下问题:C# IEnumerable.Select方法的具体用法?C# IEnumerable.Select怎么用?C# IEnumerable.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEnumerable的用法示例。


在下文中一共展示了IEnumerable.Select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Announcement

        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");
            }
        }
开发者ID:CodeObsessed,项目名称:drumbleapp,代码行数:31,代码来源:Announcement.cs

示例2: RenderLayout

        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);
        }
开发者ID:Higea,项目名称:Orchard,代码行数:25,代码来源:GridLayout.cs

示例3: HorizontalFlightTest

        /// <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();
        }
开发者ID:idaohang,项目名称:Helicopter-Autopilot-Simulator,代码行数:32,代码来源:FlightLoggerTest.cs

示例4: ParseFiles

    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();
    }
开发者ID:JimLiaskos,项目名称:TankChallenge,代码行数:31,代码来源:Helper.cs

示例5: OrderExportContext

        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;
        }
开发者ID:toannguyen241994,项目名称:SmartStoreNET,代码行数:31,代码来源:OrderExportContext.cs

示例6: Announcement

        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");
            }
        }
开发者ID:CodeObsessed,项目名称:drumbleapp,代码行数:33,代码来源:Announcement.cs

示例7: ProcessRenderings

        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);
            }
        }
开发者ID:GuitarRich,项目名称:Console,代码行数:31,代码来源:RemoveRenderingCommand.cs

示例8: SaveSelectedCategories

 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();
         }
 }
开发者ID:rajskumar,项目名称:semplest2,代码行数:35,代码来源:CategoriesRepository.cs

示例9: Add

 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);
 }
开发者ID:raysearchlabs,项目名称:spark,代码行数:7,代码来源:MongoFhirStore.cs

示例10: GenerateExtensionList

 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)));
 }
开发者ID:bplasmeijer,项目名称:uMadeEasy,代码行数:7,代码来源:TemplateWriter.cs

示例11: LoadGroups

		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();
			}
		}
开发者ID:w01f,项目名称:VolgaTeam.Dashboard,代码行数:30,代码来源:FormEmail.cs

示例12: CalculateCoefficientValues

        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;
        }
开发者ID:rodrigogalhardo,项目名称:asms-md,代码行数:35,代码来源:EcoCalc.cs

示例13: GetUpdates

        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
                );
            }
        }
开发者ID:netide,项目名称:netide,代码行数:31,代码来源:NuGetQuerier.cs

示例14: FindShortestRoute

        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]);
        }
开发者ID:ajayprab,项目名称:TrainsExpress,代码行数:32,代码来源:DijkstraRouteFinder.cs

示例15: GenerateAvailableProductRefinementsFrom

        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;
        }
开发者ID:afrancocode,项目名称:Storefront,代码行数:25,代码来源:ProductMapper.cs


注:本文中的IEnumerable.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。