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


C# List.AddRange方法代码示例

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


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

示例1: WriteToFile

        public void WriteToFile(string fileName, List<Problem> source, int numberOfPage)
        {
            DocX doc = DocX.Create(fileName);
              var font = new System.Drawing.FontFamily("Consolas");
              var rand = new Random(DateTime.Now.Millisecond);
              var gap = new string(' ', spaceBetweenProblem - 1);

              var totalCount = colCount * rowCount * numberOfPage;

              List<Problem> allItems = new List<Problem>();
              while (allItems.Count < totalCount)
              {
            var problems = source.ToArray();
            Utils.Shuffle(problems);
            allItems.AddRange(problems);
              }

              Paragraph lastLine = null;
              for (int page = 0; page < numberOfPage; page++)
              {
            var from = colCount * rowCount * page;

            for (int row = 0; row < rowCount; row++)
            {
              var line1 = doc.InsertParagraph();
              lastLine = doc.InsertParagraph();
              for (int col = 0; col < colCount; col++)
              {
            line1.Append(string.Format("{0} ", allItems[from].LeftNumber.ToString().PadLeft(maxDigits + 1, ' '))).Font(font).FontSize(fontSize).Append(gap).Font(font).FontSize(fontSize);
            lastLine.Append(string.Format("{0}{1} ", allItems[from].Sign, allItems[from].RightNumber.ToString().PadLeft(maxDigits, ' '))).Font(font).FontSize(fontSize).UnderlineStyle(UnderlineStyle.thick).Append(gap).Font(font).FontSize(fontSize);
            from++;
              }

              if (row != rowCount - 1)
              {
            for (int i = 0; i < spaceLinesBetweenItem; i++)
            {
              lastLine = doc.InsertParagraph();
            }
              }
            }

            if (page != numberOfPage - 1 && addPageBreak)
            {
              lastLine.InsertPageBreakAfterSelf();
            }
              }
              doc.Save();
        }
开发者ID:shengqh,项目名称:education,代码行数:49,代码来源:ProblemWordRowColWriter.cs

示例2: InsertList

        public List InsertList(int index, List list)
        {
            Paragraph p = HelperFunctions.GetFirstParagraphEffectedByInsert(Document, index);

            XElement[] split = HelperFunctions.SplitParagraph(p, index - p.startIndex);
            var elements = new List<XElement> { split[0] };
            elements.AddRange(list.Items.Select(i => new XElement(i.Xml)));
            elements.Add(split[1]);
            p.Xml.ReplaceWith(elements.ToArray());

            return list;
        }
开发者ID:ScottSnodgrass,项目名称:DocX,代码行数:12,代码来源:Container.cs

示例3: FindUniqueByPattern

        /// <summary>
        /// Find all unique instances of the given Regex Pattern,
        /// returning the list of the unique strings found
        /// </summary>
        /// <param name="pattern"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public virtual List<string> FindUniqueByPattern(string pattern, RegexOptions options)
        {
            List<string> rawResults = new List<string>();

            foreach (Paragraph p in Paragraphs)
            {   // accumulate the search results from all paragraphs
                List<string> partials = p.FindAllByPattern(pattern, options);
                rawResults.AddRange(partials);
            }

            // this dictionary is used to collect results and test for uniqueness
            Dictionary<string, int> uniqueResults = new Dictionary<string, int>();

            foreach (string currValue in rawResults)
            {
                if (!uniqueResults.ContainsKey(currValue))
                {   // if the dictionary doesn't have it, add it
                    uniqueResults.Add(currValue, 0);
                }
            }

            return uniqueResults.Keys.ToList();  // return the unique list of results
        }
开发者ID:ScottSnodgrass,项目名称:DocX,代码行数:30,代码来源:Container.cs

示例4: FindAll

        public virtual List<int> FindAll(string str, RegexOptions options)
        {
            List<int> list = new List<int>();

            foreach (Paragraph p in Paragraphs)
            {
                List<int> indexes = p.FindAll(str, options);

                for (int i = 0; i < indexes.Count(); i++)
                    indexes[0] += p.startIndex;

                list.AddRange(indexes);
            }

            return list;
        }
开发者ID:ScottSnodgrass,项目名称:DocX,代码行数:16,代码来源:Container.cs

示例5: LoadTemplateSets

        private void LoadTemplateSets()
        {
            var ds = new List<string>();
            ds.Add(string.Empty);
            ds.Add(ITEM_CHOOSE);

            if (Directory.Exists(SUBS_PATH))
            {
                var files = Directory.GetFiles(SUBS_PATH, SUBS_SEARCH_PATTERN);
                ds.AddRange(files.Select(s => s.Replace(SUBS_PATH, "")));
            }

            cbSubstitutions.DataSource = ds;
        }
开发者ID:mkoscak,项目名称:easy-replacer,代码行数:14,代码来源:FrmMain.cs

示例6: LoadSubstitutions

        private void LoadSubstitutions()
        {
            var ds = new List<string>();
            ds.Add(string.Empty);
            ds.Add(ITEM_CHOOSE);

            if (Directory.Exists(TEMPLATES_PATH))
            {
                var dirs = Directory.GetDirectories(TEMPLATES_PATH);
                ds.AddRange(dirs.Select(s => s.Replace(TEMPLATES_PATH, "")));
            }

            cbTemplate.DataSource = ds;
        }
开发者ID:mkoscak,项目名称:easy-replacer,代码行数:14,代码来源:FrmMain.cs

示例7: PrintOrder


//.........这里部分代码省略.........
            Queue<string> filesExtCost = new Queue<string>();

            //questo array mi serve per il merge
            Queue<string> RepassCost = new Queue<string>();

            //questo array mi serve per il merge
            Queue<string> filesDelivery = new Queue<string>();

            order.MergeField(docMain);
            order.OrderProduct.MergeField(docMain);
            order.OrderProduct.Product.MergeField(docMain);

            var product = productRepository.GetSingle(order.OrderProduct.Product.CodProduct);
            product.ProductParts.FirstOrDefault().MergeField(docMain);
            try
            {
                product.ProductParts.FirstOrDefault().productpartprintings.FirstOrDefault().MergeField(docMain);
            }
            catch (Exception)
            {
            }

            //    product.ProductParts.FirstOrDefault().ProductPartPrintableArticles.FirstOrDefault().MergeField(docMain);

            var costs = order.OrderProduct.Costs.OrderBy(x => x.IndexOf);
            Console.WriteLine(costs);



            //group costdetails by taskexecutor
            List<CostDetail> costDetails = new List<CostDetail>();
            foreach (var item in costs)
            {
                costDetails.AddRange(item.CostDetails);
            }

            var TaskExecutorGroups = costDetails.GroupBy(p => p.CodTaskExecutorSelected,
                p => p,
                (key, g) => new CostDetailGrouped
                {
                    CodTaskExecutorSelected = key,
                    CostDetails = g.ToList()
                });

            Console.WriteLine(TaskExecutorGroups);
            //end grouping




            foreach (var cost in costs)
            {
                // Create the document in memory:
                //var docCost = DocX.Load(fileNameCost);
                //                cost.MergeField(docCost);

                //try
                //{
                var cd = cost.CostDetails.FirstOrDefault();
                if (cd != null)
                {
                    cd = costDetailRepository.GetSingle(cd.CodCostDetail);
                    cd.InitCostDetail(taskExecutorRepository.GetAll(), articleRepository.GetAll());

                    if (cost.CostDetails.FirstOrDefault().TypeOfCostDetail.ToString() == "PrintedRollArticleCostDetail" ||
                        cost.CostDetails.FirstOrDefault().TypeOfCostDetail.ToString() == "PrintingZRollCostDetail" ||
开发者ID:algola,项目名称:backup,代码行数:67,代码来源:DocumentController2.cs


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