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


C# List.AsEnumerable方法代码示例

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


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

示例1: SetComponentLinks

        internal void SetComponentLinks(IEnumerable<AbstractEndpoint.IAbstractComponentLink> componentLinks)
        {
            var links = new List<ComponentsOrderingViewModel>();

            var setOrder = new Action(() =>
                {
                    var worker = new BackgroundWorker();
                    worker.DoWork += (e, s) =>
                    {
                        foreach (var cl in links.AsEnumerable().Reverse())
                        {
                            cl.Link.Order = links.IndexOf(cl) + 1;
                        }
                    };
                    worker.RunWorkerAsync();
                });
            foreach (var cl in componentLinks.OrderBy(x => x.Order))
            {
                var vm = new ComponentsOrderingViewModel { Link = cl };
                links.Add(vm);
                vm.UpCommand = new RelayCommand(
                    () =>
                    {
                        var prevIndex = links.IndexOf(vm);
                        links.Remove(vm);
                        links.Insert(prevIndex - 1, vm);
                        this.ComponentList.ItemsSource = null;
                        this.ComponentList.ItemsSource = links;
                        this.ComponentList.SelectedItem = vm;
                        setOrder();
                    }, () => links.IndexOf(vm) > 0);
                vm.DownCommand = new RelayCommand(
                    () =>
                    {
                        var prevIndex = links.IndexOf(vm);
                        links.Remove(vm);
                        links.Insert(prevIndex + 1, vm);
                        this.ComponentList.ItemsSource = null;
                        this.ComponentList.ItemsSource = links;
                        this.ComponentList.SelectedItem = vm;
                        setOrder();
                    }, () => links.IndexOf(vm) < links.Count - 1);
            }
            this.ComponentList.ItemsSource = links;
        }
开发者ID:slamj1,项目名称:ServiceMatrix,代码行数:45,代码来源:ComponentsOrderingView.xaml.cs

示例2: CreateRepo_Click

        private async void CreateRepo_Click(object sender, RoutedEventArgs e)
        {
            CreateRepo.IsEnabled = false;
            RepoProgress.Visibility = Visibility.Visible;

            var asd = new List<string>();
            foreach (CheckBox item in ListOfFolders.Items)
            {
                if (item.IsChecked.HasValue)
                {
                    if ((bool)item.IsChecked) asd.Add((string)item.Content);
                }
            }

            if (asd.Count > 0)
            {
                await Task.Run(() =>
                {
                    var newRepo = new RepositoryData();
                    newRepo.DownloadRoot = Repository.DefaultUrlBase;

                    newRepo.Files = r.CreateRepositoryData(asd.AsEnumerable());
                    string output = JsonConvert.SerializeObject(newRepo);

                    try
                    {
                        using (var wr = new StreamWriter("updater.json", false))
                        {
                            wr.Write(output);
                            wr.Flush();
                        }
                        MessageBox.Show("Metadata created successfully.");
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Unable to write metadata file.");
                    }
                });
            }

            CreateRepo.IsEnabled = true;
            RepoProgress.Visibility = Visibility.Hidden;
        }
开发者ID:tuomur,项目名称:polloeskadroona_updater_wpf,代码行数:43,代码来源:CreateRepositoryWindow.xaml.cs

示例3: GetMemberAccessAndAccessedTypes

        /*
         * Get the member access in the document, returning a tuple of member access node and the RefactoringType it is accessing.
         */
        public IEnumerable<Tuple<SyntaxNode, ITypeSymbol>> GetMemberAccessAndAccessedTypes()
        {
            // For all the classes whose memeber is accessed and their types.
            var typedAccesses = new List<Tuple<SyntaxNode, ITypeSymbol>>();

            // Get all nodes whose RefactoringType is member access.
            var accesses = root.DescendantNodes().Where(n => n.Kind == SyntaxKind.MemberAccessExpression);

            // For all the access in the list.
            foreach (SyntaxNode access in accesses)
            {
                // Get left and right side of the access.
                var analyzer = AnalyzerFactory.GetMemberAccessAnalyzer();
                analyzer.SetMemberAccess(access);
                var left = analyzer.GetLeftPart();

                // Query about the RefactoringType of the left side of the access, if it is not null, add to the results.
                // ATTENTION: mode.GetTypeInfo() cannot get primitive RefactoringType such as int.
                var infor = model.GetTypeInfo(left);
                if(infor.Type != null)
                    typedAccesses.Add(Tuple.Create(access, infor.Type));
            }
            return typedAccesses.AsEnumerable();
        }
开发者ID:nkcsgexi,项目名称:GhostFactor2,代码行数:27,代码来源:TypablesRetriever.cs

示例4: MapToAnotherDocument

        /* Map all the nodes to another document. */
        public IEnumerable<SyntaxNode> MapToAnotherDocument(IDocument document)
        {
            var analyzer = AnalyzerFactory.GetSyntaxNodeAnalyzer();
            var list = new List<SyntaxNode>();

            foreach (SyntaxNode node in nodes)
            {
                analyzer.SetSyntaxNode(node);
                list.Add(analyzer.MapToAnotherDocument(document));
            }
            return list.AsEnumerable();
        }
开发者ID:nkcsgexi,项目名称:GhostFactor2,代码行数:13,代码来源:SyntaxNodesAnalyzer.cs

示例5: GetNeighborredNodesGroups

        /*
         * Get groups of nodes. In each group, nodes are sequentially ordered and no code in
         * between of each two nearby nodes.
         */
        public IEnumerable<IEnumerable<SyntaxNode>> GetNeighborredNodesGroups()
        {
            // Remove all the nodes contained by other node in the list, also sort the list by starting position
            var sortedNodes = RemoveSubNodes().OrderBy(n => n.Span.Start);
            var breakIndexes = new List<int>();
            var analyzer = AnalyzerFactory.GetSyntaxNodeAnalyzer();
            logger.Debug("Sourted node count: " + sortedNodes.Count());

            // Iterate all the nodes, if one is not neighborred with its previous one, add to the break indexes.
            for (int i = 1; i < sortedNodes.Count(); i++)
            {
                analyzer.SetSyntaxNode(nodes.ElementAt(i));
                if (!analyzer.IsNeighborredWith(sortedNodes.ElementAt(i - 1)))
                {
                    breakIndexes.Add(i);
                }
            }

            // The number of elements shall be the last break index.
            breakIndexes.Add(nodes.Count());

            var lists = new List<IEnumerable<SyntaxNode>>();
            int start = 0;

            // Iterate each break index, from 'last break index' to 'current break index -1'
            // is a group of neiborred syntax node.
            foreach (var end in breakIndexes)
            {
                lists.Add(sortedNodes.Skip(start).Take(end - start));
                start = end;
            }
            return lists.AsEnumerable();
        }
开发者ID:nkcsgexi,项目名称:GhostFactor2,代码行数:37,代码来源:SyntaxNodesAnalyzer.cs

示例6: GetStatementsByIndexRange

 /* Get a subset of all the containing statements, start and end index are inclusive. */
 public IEnumerable<SyntaxNode> GetStatementsByIndexRange(int start, int end)
 {
     var statements = GetStatements();
     var subList = new List<SyntaxNode>();
     for(int i = start; i <= end; i++)
     {
         subList.Add(statements.ElementAt(i));
     }
     return subList.AsEnumerable();
 }
开发者ID:nkcsgexi,项目名称:ghostfactor1,代码行数:11,代码来源:MethodDeclarationAnalyzer.cs

示例7: GetStatementsBefore

        public IEnumerable<SyntaxNode> GetStatementsBefore(int position)
        {
            // Get all the statements first.
            IEnumerable<SyntaxNode> statements = GetStatements();

            // Initiate an empty statement list.
            IList<SyntaxNode> result = new List<SyntaxNode>();

            // Iterate all the statement.
            foreach(var statement in statements)
            {
                // For statement whose end point is before the position, add it to the result
                if (statement.Span.End < position)
                {
                    result.Add(statement);
                }
            }
            return result.AsEnumerable();
        }
开发者ID:nkcsgexi,项目名称:ghostfactor1,代码行数:19,代码来源:MethodDeclarationAnalyzer.cs

示例8: GetParameterUsages

        public IEnumerable<IEnumerable<SyntaxNode>> GetParameterUsages()
        {
            // Containing the results.
            var list = new List<IEnumerable<SyntaxNode>>();

            // All the parameters taken.
            var parameters = GetParameters();

            // Block of the method declaration.
            var block = ASTUtil.GetBlockOfMethod(method);

            // For each parameter.
            // ATTENTION: foreach will throw null exception if it has nothing in it.
            foreach (ParameterSyntax para in parameters)
            {
                // Need a new subList to copy out nodes, IEnumerable is a read only interface that will not copy out as new
                // elements. To copy out as new elements, a list is needed.
                // ATTENTION: cannot list.add(block.DecendantNodes()...), because if have multiple paras the previous added IEnumerable
                // will be rewrite.
                var sublist = new List<SyntaxNode>();

                // Only able to retrieve the parameter usages if the method block exists.
                if (block != null)
                {
                    // If an identifier name equals the paraemeter's name, it is one usage of the
                    // parameter.
                    sublist.AddRange(block.DescendantNodes().Where(n => n.Kind == SyntaxKind.IdentifierName
                        && n.GetText().Equals(para.Identifier.ValueText)));
                }
                logger.Info("Parameter " + para.Identifier + " usage:" +
                               StringUtil.ConcatenateAll(",", sublist.Select(n => n.Span.ToString())));
                list.Add(sublist.AsEnumerable());
            }
            return list.AsEnumerable();
        }
开发者ID:nkcsgexi,项目名称:ghostfactor1,代码行数:35,代码来源:MethodDeclarationAnalyzer.cs

示例9: XMLParser_DoWork

        private void XMLParser_DoWork(object sender, DoWorkEventArgs e)
        {
            this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
            {
                CheckingLabel.Content = "Picking the right edition for you";
            }
            ));
            //OSParams Tree: [0] = LanguageCode, [1] = Edition, [2] = Architecture, [3] ProductName
            CurrentOSParams = new List<string>();
            CurrentOSParams.Add((CultureInfo.InstalledUICulture).Name.ToLower());
            CurrentOSParams.Add((string)Microsoft.Win32.Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "EditionId", null));
            if (Environment.Is64BitOperatingSystem)
                CurrentOSParams.Add("x64");
            else
                CurrentOSParams.Add("x86");
            CurrentOSParams.Add((string)Microsoft.Win32.Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "ProductName", null));
            this.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
            {
                MainWindowHandle.SendGXNReport("Launched on Build " + (string)Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentBuildNumber", null) + ": LanguageCode=" + CurrentOSParams[0] + ", Edition=" + CurrentOSParams[1] + ", Architecture=" + CurrentOSParams[2] + ", ProductName=" + CurrentOSParams[3]);
            }
            ));
            ESDList = new List<EsdFile>();
            HttpWebRequest wreq = HttpWebRequest.Create("http://msft.gq/pub/xml/mct/10240.16384_prd.xml") as HttpWebRequest;

            using (HttpWebResponse wres = wreq.GetResponse() as HttpWebResponse)
            using (Stream wresStr = wres.GetResponseStream())
            {
                XDocument xdoc = XDocument.Load(wresStr);

                var files = from f in xdoc.Descendants("File")
                            select new EsdFile()
                            {
                                FileName = f.Element("FileName").Value,
                                LanguageCode = f.Element("LanguageCode").Value,
                                Language = f.Element("Language").Value,
                                Edition = f.Element("Edition").Value,
                                Architecture = f.Element("Architecture").Value,
                                Size = long.Parse(f.Element("Size").Value),
                                Sha1 = f.Element("Sha1").Value,
                                FilePath = f.Element("FilePath").Value,
                                Key = f.Element("Key").Value,
                                Architecture_Loc = f.Element("Architecture_Loc").Value,
                                Edition_Loc = f.Element("Edition_Loc").Value,
                                IsRetailOnly = Convert.ToBoolean(f.Element("IsRetailOnly").Value)
                            };

                ESDList.AddRange(files);
            }
            IEnumerable<EsdFile> ESDListEnum = from XMLEntry in ESDList.AsEnumerable()
                                                where XMLEntry.LanguageCode.Equals(CurrentOSParams[0]) &&
                                                      XMLEntry.Edition.Equals(CurrentOSParams[1]) &&
                                                      XMLEntry.Architecture.Equals(CurrentOSParams[2])
                                                select XMLEntry;
            ESDParams = new List<string>();
            UpcomingOSParams = new List<string>();
            foreach (var ESD in ESDListEnum)
            {
                if (UpcomingOSParams.Count < 4)
                {
                    UpcomingOSParams.Add(ESD.LanguageCode);
                    UpcomingOSParams.Add(ESD.Edition);
                    UpcomingOSParams.Add(ESD.Architecture);
                    if (ESD.Edition_Loc.Equals("%EDU_N%"))
                        UpcomingOSParams.Add("Windows 10 Education N");
                    else if (ESD.Edition_Loc.Equals("%BASE_K%"))
                        UpcomingOSParams.Add("Windows 10 Home K");
                    else if (ESD.Edition_Loc.Equals("%BASE%"))
                        UpcomingOSParams.Add("Windows 10 Home");
                    else if (ESD.Edition_Loc.Equals("%BASE_CHINA%"))
                        UpcomingOSParams.Add("Windows 10 Home China");
                    else if (ESD.Edition_Loc.Equals("%EDU_K%"))
                        UpcomingOSParams.Add("Windows 10 Education K");
                    else if (ESD.Edition_Loc.Equals("%BASE_N%"))
                        UpcomingOSParams.Add("Windows 10 Home N");
                    else if (ESD.Edition_Loc.Equals("%PRO_K%"))
                        UpcomingOSParams.Add("Windows 10 Pro K");
                    else if (ESD.Edition_Loc.Equals("%EDU%"))
                        UpcomingOSParams.Add("Windows 10 Education");
                    else if (ESD.Edition_Loc.Equals("%SINGLE_LANGUAGE%"))
                        UpcomingOSParams.Add("Windows 10 Home Single Language");
                    else if (ESD.Edition_Loc.Equals("%EDU_KN%"))
                        UpcomingOSParams.Add("Windows 10 Education KN");
                    else if (ESD.Edition_Loc.Equals("%PRO_N%"))
                        UpcomingOSParams.Add("Windows 10 Pro N");
                    else if (ESD.Edition_Loc.Equals("%PRO%"))
                        UpcomingOSParams.Add("Windows 10 Pro");
                    else if (ESD.Edition_Loc.Equals("%PRO_KN%"))
                        UpcomingOSParams.Add("Windows 10 Pro KN");
                    else if (ESD.Edition_Loc.Equals("%BASE_KN%"))
                        UpcomingOSParams.Add("Windows 10 Home KN");
                }
                //ESDParams Tree: [0] Url, [1] FileName, [2] Sha1, [3] Key
                if (ESDParams.Count < 4)
                {
                    ESDParams.Add(ESD.FilePath);
                    ESDParams.Add(ESD.FileName);
                    ESDParams.Add(ESD.Sha1);
                    ESDParams.Add(ESD.Key);
                }
            }
//.........这里部分代码省略.........
开发者ID:LucasM99,项目名称:GXN,代码行数:101,代码来源:WelcomePage.xaml.cs

示例10: GetTypableIdentifierTypeTuples

        /*
         * Get tuples of node and RefactoringType. Nodes shall be identifier names.
         * ATTENTION: the declarations cannot get RefactoringType info, only identifiers(references) can.
         */
        public IEnumerable<Tuple<SyntaxNode, ITypeSymbol>> GetTypableIdentifierTypeTuples()
        {
            var typedIdentifiers = new List<Tuple<SyntaxNode, ITypeSymbol>>();

            // Get all identifiers.
            var identifiers = root.DescendantNodes().Where(n => n.Kind == SyntaxKind.IdentifierName);
            foreach (SyntaxNode id in identifiers)
            {
                // Query RefactoringType information of an identifier.
                var info = model.GetTypeInfo(id);

                // If RefactoringType is retrieved, add to the result.
                if (info.Type != null)
                    typedIdentifiers.Add(Tuple.Create(id, info.Type));
            }
            return typedIdentifiers.AsEnumerable();
        }
开发者ID:nkcsgexi,项目名称:GhostFactor2,代码行数:21,代码来源:TypablesRetriever.cs


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