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


C# List.Select方法代码示例

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


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

示例1: CreateElementGroup

        private ElementCollection CreateElementGroup(string xPath, List<Element> list)
        {
            var names = new Dictionary<string, int>();
            foreach (var name in list.Select(el => el.Name))
            {
                if (names.ContainsKey(name))
                    names[name]++;
                else
                    names.Add(name, 1);
            }
            string mostRepeatedName = names.Keys.OrderBy(name => names[name]).First();

            int minX = list.Select(el => el.Location.X).Min();
            int minY = list.Select(el => el.Location.Y).Min();
            int maxX = list.Select(el => el.Location.X + el.Size.Width).Max();
            int maxY = list.Select(el => el.Location.Y + el.Size.Height).Max();

            var firstLocation = new Point(minX, minY);
            var combinedArea = new Size(maxX - minX, maxY - minY);
            return new ElementCollection()
            {
                Name = mostRepeatedName + "Group",
                LocatorType = "xpath",
                Locator = xPath,
                Location = firstLocation,
                Size = combinedArea
            };
        }
开发者ID:TA-Gen,项目名称:TA-Gen,代码行数:28,代码来源:GroupElementsByXpath.cs

示例2: WbImageData

        public WbImageData(
            List<WbVmUtils.PlotPoint<Color>> plotPoints,
            List<WbVmUtils.PlotRectangle<Color>> filledRects,
            List<WbVmUtils.PlotRectangle<Color>> openRects,
            List<WbVmUtils.PlotLine<Color>> plotLines, 
            double width, 
            double height)
        {
            Height = height;
            Width = width;
            PlotPoints = plotPoints;
            FilledRectangles = filledRects;
            OpenRectangles = openRects;
            PlotLines = plotLines;

            BoundingRect = RectExt.NegInfRect
                .BoundingRect(plotLines.Select(pl => pl.X1))
                .BoundingRect(plotLines.Select(pl => pl.X2))
                .BoundingRect(plotLines.Select(pl => pl.Y1))
                .BoundingRect(plotLines.Select(pl => pl.Y2))
                .BoundingRect(filledRects.Select(pl => pl.X))
                .BoundingRect(filledRects.Select(pl => pl.X + pl.Width))
                .BoundingRect(filledRects.Select(pl => pl.Y))
                .BoundingRect(filledRects.Select(pl => pl.Y + pl.Height))
                .BoundingRect(openRects.Select(pl => pl.X))
                .BoundingRect(openRects.Select(pl => pl.X + pl.Width))
                .BoundingRect(openRects.Select(pl => pl.Y))
                .BoundingRect(openRects.Select(pl => pl.Y + pl.Height))
                .BoundingRect(plotPoints.Select(pl => pl.X))
                .BoundingRect(plotPoints.Select(pl => pl.Y));
        }
开发者ID:tp-nscan,项目名称:HopAlong,代码行数:31,代码来源:WbImageData.cs

示例3: CreateActionDelegate

        private Delegate CreateActionDelegate(MethodInfo method)
        {
            List<ParameterExpression> parameters = new List<ParameterExpression>();
            foreach (ParameterInfo parameterInfo in method.GetParameters())
            {
                parameters.Add(Expression.Parameter(parameterInfo.ParameterType, parameterInfo.Name));
            }

            LambdaExpression lambda;

            if (method.IsStatic)
            {
                lambda = Expression.Lambda(
                    GetActionType(parameters.Select(p => p.Type).ToArray()),
                    Expression.Call(method, parameters.Cast<Expression>().ToArray()),
                    parameters.ToArray());
            }
            else
            {
                Type bindingType = method.DeclaringType;
                Expression<Func<object>> getInstanceExpression =
                    () => ScenarioContext.Current.GetBindingInstance(bindingType);

                lambda = Expression.Lambda(
                    GetActionType(parameters.Select(p => p.Type).ToArray()),
                    Expression.Call(
                        Expression.Convert(getInstanceExpression.Body, bindingType),
                        method,
                        parameters.Cast<Expression>().ToArray()),
                    parameters.ToArray());
            }


            return lambda.Compile();
        }
开发者ID:hedaayat,项目名称:SpecFlow,代码行数:35,代码来源:StepMethodBinding.cs

示例4: GetUsedPaths

 private static IEnumerable<string> GetUsedPaths(List<Customer> customers)
 {
     IEnumerable<string> usedPaths = customers.Select(cust => cust.PhotoPath);
     usedPaths = usedPaths.Concat(customers.Select(cust => cust.ProofOfIdPath));
     usedPaths = usedPaths.Concat(customers.Select(cust => cust.Address.ProofOfAddressPath));
     return usedPaths;
 }
开发者ID:JWroe,项目名称:ScrapTraders,代码行数:7,代码来源:DeletionHelper.cs

示例5: FillEmptyDataPoints

        private List<DpsPerCharacter> FillEmptyDataPoints(List<DpsPerCharacter> list)
        {
            var allCharacters = list.Select(m => m.character).Distinct().OrderBy(m => m).ToList();
            var allIntervals = list.Select(m => m.interval).Distinct().OrderBy(m => m).ToList();

            // Fill in missing intervals
            var lastInterval = allIntervals.FirstOrDefault();
            foreach (var interval in allIntervals.OrderBy(m => m))
            {
                int diff = interval - lastInterval;
                if (diff > 1)
                {
                    for (int i = 1; i < diff; i++)
                    {
                        foreach (var character in allCharacters)
                        {
                            list.Add(new DpsPerCharacter { character = character, damage = 0, interval = lastInterval + i });
                        }
                    }
                }

                foreach (var character in allCharacters)
                {
                    if (list.Any(m => m.character == character && m.interval == interval) == false)
                    {
                        list.Add(new DpsPerCharacter { character = character, interval = interval, damage = 0 });
                    }
                }

                lastInterval = interval;
            }

            return list;
        }
开发者ID:Rivsoft,项目名称:SWTOR.Parser,代码行数:34,代码来源:Analyzer.cs

示例6: RemoveDuplicateTphColumns_removes_multiple_batches_of_duplicate_columns_from_same_table

        [Fact] // CodePlex 583
        public void RemoveDuplicateTphColumns_removes_multiple_batches_of_duplicate_columns_from_same_table()
        {
            var removed = new List<EdmMember>();
            var mockTableType = CreateMockType("Lancre");
            mockTableType.Setup(m => m.RemoveMember(It.IsAny<EdmMember>())).Callback<EdmMember>(removed.Add);

            var columns = CreateColumns(
                mockTableType,
                "Nanny", "Ogg", "Nanny", "Nanny", "Granny", "Magrat", "Weatherwax", "Weatherwax", "Magrat", "Garlik", "Tiffany", "Tiffany");

            var mappings = CreateMappings(
                columns,
                "Nanny1", "Ogg", "Nanny2", "Nanny2", "Granny", "Magrat1", "Weatherwax", "Weatherwax", "Magrat2", "Garlik", "Tiffany",
                "Tiffany");

            new TphColumnFixer(mappings).RemoveDuplicateTphColumns();

            Assert.Equal(5, removed.Count);
            Assert.Equal(2, removed.Select(m => m.Name).Count(n => n == "Nanny"));
            Assert.Equal(1, removed.Select(m => m.Name).Count(n => n == "Weatherwax"));
            Assert.Equal(1, removed.Select(m => m.Name).Count(n => n == "Magrat"));
            Assert.Equal(1, removed.Select(m => m.Name).Count(n => n == "Tiffany"));

            AssertDuplicatesRemoved(mappings, "Nanny");
            AssertDuplicatesRemoved(mappings, "Weatherwax");
            AssertDuplicatesRemoved(mappings, "Magrat");
            AssertDuplicatesRemoved(mappings, "Tiffany");
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:29,代码来源:TphColumnFixerTests.cs

示例7: Sanitize

 public static IEnumerable<RestrictionModel> Sanitize(this IEnumerable<RestrictionModel> input)
 {
     var patterns = new List<PatternRestrictionModel>();
     foreach (var item in input)
     {
         var pattern = item as PatternRestrictionModel;
         if (pattern != null)
             patterns.Add(pattern);
         else
             yield return item;
     }
     if (patterns.Count == 1)
     {
         yield return patterns[0];
     }
     else if (patterns.Count > 1)
     {
         var config = patterns.Select(x => x.Configuration).First();
         var pattern = string.Join("|", patterns.Select(x => string.Format("({0})", x.Value)));
         yield return new PatternRestrictionModel(config)
         {
             Value = pattern,
         };
     }
 }
开发者ID:imileusnic,项目名称:XmlSchemaClassGenerator,代码行数:25,代码来源:EnumerableExtensions.cs

示例8: Main

        static void Main(string[] args)
        {
            var images = new List<ImageInfo>();

            var imageId = 0;
            foreach (var dir in new DirectoryInfo(@"..\..\Images").GetDirectories())
            {
                var groupId = int.Parse(dir.Name.Replace("s", string.Empty)) - 1;
                foreach (var imageFile in dir.GetFiles("*.pgm"))
                {
                    images.Add(new ImageInfo
                    {
                        Image = new Mat(imageFile.FullName, LoadMode.GrayScale),
                        ImageId = imageId++,
                        ImageGroupId = groupId
                    });
                }
            }

            var model = FaceRecognizer.CreateFisherFaceRecognizer();
            model.Train(images.Select(x => x.Image), images.Select(x => x.ImageGroupId));

            var rnd = new Random();
            var randomImageId = rnd.Next(0, images.Count - 1);
            var testSample = images[randomImageId];

            Console.WriteLine("Actual group: {0}", testSample.ImageGroupId);
            Cv2.ImShow("actual", testSample.Image);

            var predictedGroupId = model.Predict(testSample.Image);
            Console.WriteLine("Predicted group: {0}", predictedGroupId);

            Cv2.WaitKey(0);
        }
开发者ID:kauser-cse-buet,项目名称:OpenCVSharp-Samples,代码行数:34,代码来源:Program.cs

示例9: Agitator

        public ActionResult Agitator(int Id)
        {
            var politicalViews = new List<KeyValuePair<string, int>>();
            var agitatorHouses = dataManager.AgitatorHouseRelations.GetAll().Where(ah => ah.AgitatorId == Id && ah.HouseId.HasValue).Select(wh => wh.HouseId.Value).ToList();

            var houses = dataManager.Houses.GetAll().Where(h => agitatorHouses.Contains(h.Id) && h.Latitude.HasValue && h.Longitude.HasValue).ToList();
            var persons = dataManager.Persons.GetAll().Where(p => houses.Select(x => x.Id).Contains(p.HouseId ?? 0)).ToList();
            var voters = dataManager.Voters.GetAll().Where(v => persons.Select(x => x.Id).Contains(v.PersonId ?? 0)).ToList();
            var voterPartyRelations = dataManager.VoterPartyRelations.GetAll().ToList();
            var parties = voterPartyRelations.Where(vp => voters.Select(x => x.Id).Contains(vp.VoterId ?? 0))
                .Select(x => dataManager.Parties.Get(x.PartyId ?? 0)).ToList();

            foreach (var house in houses)
            {
                var hPersons = persons.Where(x => x.HouseId == house.Id).ToList();
                var hVoters = voters.Where(x => hPersons.Select(x2 => x2.Id).Contains(x.PersonId ?? 0)).ToList();
                var hVoterPartyRelations = voterPartyRelations.Where(x => hVoters.Select(x2 => x2.Id).Contains(x.VoterId ?? 0)).ToList();
                var hParties = parties.Where(x => hVoterPartyRelations.Select(x2 => x2.PartyId).Contains(x.Id)).ToList();

                foreach (var hParty in hParties.GroupBy(x => x.Id).Select(x => x.First()))
                {
                    politicalViews.Add(new KeyValuePair<string, int>(hParty.Name, hVoterPartyRelations.Where(x => x.PartyId == hParty.Id).Count()));
                }
            }
            var chart = new Chart(width: 200, height: 200)
            .AddSeries(
                name: "Employee",
                xValue: politicalViews.Select(p => p.Key).ToArray(),
                yValues: politicalViews.Select(p => p.Value).ToArray(),
                chartType: "Pie");
            return File(chart.GetBytes(), "image/jpeg");
        }
开发者ID:buddzbuddy,项目名称:MSECAnalyze,代码行数:32,代码来源:ChartController.cs

示例10: GetSchemaVersionsForSubscription

        public static ISet<int> GetSchemaVersionsForSubscription(List<string> capabilities)
        {
            //The first two schema versions follow the old regex, and versions 3 on follow the new one.
            if (capabilities == null)
            {
                throw new ArgumentNullException("capabilities");
            }

            var matchesOld = capabilities.Select(s => ClustersContractCapabilityRegexOld.Match(s)).Where(match => match.Success).ToList();

            var schemaVersions = new HashSet<int>(matchesOld.Select(m => Int32.Parse(m.Groups[1].Value, CultureInfo.CurrentCulture)).ToList());

            var matchesNew = capabilities.Select(s => ClustersContractCapabilityRegex.Match(s)).Where(match => match.Success).ToList();
            if (matchesNew.Count != 0)
            {
                schemaVersions.UnionWith(
                    matchesNew.Select(m => Int32.Parse(m.Groups[1].Value, CultureInfo.CurrentCulture)));
            }

            if (schemaVersions == null || !schemaVersions.Any())
            {
                throw new NotSupportedException("This subscription is not enabled for the clusters contract.");
            }

            return schemaVersions;
        }
开发者ID:RossMerr,项目名称:azure-sdk-for-net,代码行数:26,代码来源:SchemaVersionUtils.cs

示例11: Save

        public static bool Save(List<RoleFunctions> rolefunctions, OracleConnection conn)
        {
            try
            {
                bool saved = false;
                string query = "INSERT INTO SYSTEMROLEFUNCTIONS (ROLEID, FUNCTIONID) values(:roleid, :functionid)";
                using (var command = conn.CreateCommand())
                {
                    command.CommandText = query;
                    command.CommandType = CommandType.Text;
                    command.BindByName = true;
                    // In order to use ArrayBinding, the ArrayBindCount property
                    // of OracleCommand object must be set to the number of records to be inserted
                    command.ArrayBindCount = rolefunctions.Count;
                    command.Parameters.Add(":roleid", OracleDbType.Int32, rolefunctions.Select(rf => rf.RoleId).ToArray(), ParameterDirection.Input);
                    command.Parameters.Add(":functionid", OracleDbType.Int32, rolefunctions.Select(rf => rf.FunctionId).ToArray(), ParameterDirection.Input);

                    int result = command.ExecuteNonQuery();
                    if (result == rolefunctions.Count)
                        saved = true;

                    return saved;
                }
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }
开发者ID:oolatunji,项目名称:CardPersoWebSolution,代码行数:29,代码来源:RoleFunctionsDL.cs

示例12: RefactorCombineTableForm

		public RefactorCombineTableForm(Microsoft.VisualStudio.Modeling.Store store, nHydrateDiagram diagram, nHydrateModel model, Entity entity1, Entity entity2)
			: this()
		{
			_store = store;
			_model = model;
			_diagram = diagram;
			_entity1 = entity1;
			_entity2 = entity2;

			lblEntity1.Text = entity1.Name;
			lblEntity2.Text = entity2.Name;

			var fieldList = new List<Field>();
			fieldList.AddRange(entity1.Fields);
			fieldList.AddRange(entity2.Fields);
			fieldList.Remove(x => entity2.PrimaryKeyFields.Contains(x));

			if (fieldList.Select(x => x.Name.ToLower()).Count() != fieldList.Select(x => x.Name.ToLower()).Distinct().Count())
			{
				cmdApply.Enabled = false;
				lblError.Text = "Duplicate field names are not allowed.";
				lblError.Visible = true;
			}

			fieldList.ForEach(x => lstField.Items.Add(x.Name));
		}
开发者ID:nHydrate,项目名称:nHydrate,代码行数:26,代码来源:RefactorCombineTableForm.cs

示例13: Init

        public void Init(PluginInitContext context)
        {
            this.context = context;
            controlPanelItems = ControlPanelList.Create(48);
            iconFolder = Path.Combine(context.CurrentPluginMetadata.PluginDirectory, @"Images\ControlPanelIcons\");
            fileType = ".bmp";

            if (!Directory.Exists(iconFolder))
            {
                Directory.CreateDirectory(iconFolder);
            }

            foreach (ControlPanelItem item in controlPanelItems)
            {
                if (!File.Exists(iconFolder + item.GUID + fileType) && item.Icon != null)
                {
                    item.Icon.ToBitmap().Save(iconFolder + item.GUID + fileType);
                }
            }

            Task.Run(() =>
            {
                var characters = controlPanelItems.Select(i => i.LocalizedString)
                    .Concat(controlPanelItems.Select(i => i.InfoTip));

                Parallel.ForEach(characters, c =>
                {
                    if (!string.IsNullOrWhiteSpace(c) && Alphabet.ContainsChinese(c))
                    {
                        Alphabet.PinyinComination(c);
                    }
                });
            });
        }
开发者ID:Wox-launcher,项目名称:Wox,代码行数:34,代码来源:Main.cs

示例14: Create

        public ILogFormat Create(Stream stream)
        {
            var savedPresets = Settings.Default.LexPresets ?? new XElement("Presets");

            var presets = new List<LexPreset>(
                from element in savedPresets.Elements("Preset")
                select new LexPreset {
                    Name = (string) element.Attribute("Name"),
                    CommonCode = (string) element.Attribute("CommonCode"),
                    SegmentCode = (string) element.Attribute("SegmentCode"),
                    RecordCode = (string) element.Attribute("RecordCode")
                });

            var selectView = new LexPresetsView();
            var viewModel = selectView.ViewModel;

            foreach (var preset in presets)
                viewModel.Presets.Add(preset);

            viewModel.SelectedPreset = viewModel.Presets.FirstOrDefault();

            viewModel.EditPreset = preset => {
                InvalidateCache(preset);
                ShowEditPresetDialog(selectView, stream, preset, presets.Select(x => x.Name));
            };

            viewModel.CreateNewPreset = () => {
                var preset = new LexPreset {
                    Name = "New Preset",
                    SegmentCode = "%%",
                    RecordCode = "%%"
                };

                return ShowEditPresetDialog(selectView, stream, preset, presets.Select(x => x.Name)) ? preset : null;
            };

            if (selectView.ShowDialog() != true)
                return null;

            Settings.Default.LexPresets =
                new XElement("Presets",
                    from preset in viewModel.Presets
                    select new XElement("Preset",
                        new XAttribute("Name", preset.Name),
                        new XAttribute("CommonCode", preset.CommonCode),
                        new XAttribute("SegmentCode", preset.SegmentCode),
                        new XAttribute("RecordCode", preset.RecordCode)));

            Settings.Default.Save();

            var selectedPreset = selectView.ViewModel.SelectedPreset;

            if (selectedPreset == null)
                return null;

            if (selectedPreset.Format != null)
                return selectedPreset.Format;

            return Compile(selectedPreset) ?? CompileManually(selectView, stream, selectedPreset);
        }
开发者ID:SmartFire,项目名称:LogWatch,代码行数:60,代码来源:LexLogFormatFactory.cs

示例15: ExecuteUserCommand

        public static void ExecuteUserCommand(string command, Dictionary<string, string> userInputsArgs)
        {
            ChassisManagerLauncher launcher = new ChassisManagerLauncher();

            List<KeyValuePair<string, string>> methodParam = new List<KeyValuePair<string, string>>();

            foreach (KeyValuePair<string, string> parm in userInputsArgs)
            {
                if (parm.Key != command && parm.Key != string.Empty)
                {
                    methodParam.Add(new KeyValuePair<string, string>(CorrectParameterName(command,parm.Key) , parm.Value));
                }
            }

            try
            {
                launcher.GetType().InvokeMember(command, BindingFlags.InvokeMethod, null, launcher,
                    methodParam.Select(d => d.Value).ToArray(),
                    null, null, methodParam.Select(d => d.Key).ToArray());
            }
            catch (TargetInvocationException ex)
            {
                ex.InnerException.Data["OriginalStackTrace"] = ex.InnerException.StackTrace;
                throw ex.InnerException;
            }
        }
开发者ID:silupher,项目名称:ChassisManager,代码行数:26,代码来源:CommandFetcher.cs


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