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


C# IO.StringReader类代码示例

本文整理汇总了C#中System.IO.StringReader的典型用法代码示例。如果您正苦于以下问题:C# StringReader类的具体用法?C# StringReader怎么用?C# StringReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: button1_Click

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            ++equationsCount;
            string xamlTextBox = XamlWriter.Save(t1);
            StringReader stringReader = new StringReader(xamlTextBox);
            XmlReader xmlReader = XmlReader.Create(stringReader);
            TextBox newTextBox = (TextBox)XamlReader.Load(xmlReader);
            newTextBox.Name = "t" + equationsCount.ToString();
            newTextBox.Text = "";
            newTextBox.LostFocus += textBox_LostFocus;
            newTextBox.Margin = new Thickness(0, 29*(equationsCount-1) + 4, 6, 0);

            grid2.Children.Add(newTextBox);

            string xamlLabel = XamlWriter.Save(label2);
            stringReader = new StringReader(xamlLabel);
            xmlReader = XmlReader.Create(stringReader);
            Label newLabel = (Label)XamlReader.Load(xmlReader);
            newLabel.Name = "label" + (equationsCount*2).ToString();
            newLabel.Content = equationsCount.ToString() +":";
            newLabel.Margin = new Thickness(6, 29 * (equationsCount-1) + 4, 0, 0);

            grid2.Children.Add(newLabel);

            varForEq.Add(new List<string>());
        }
开发者ID:osst,项目名称:University,代码行数:26,代码来源:MainWindow.xaml.cs

示例2: ProcessRecord

        /// <summary>
        /// Processes the record.
        /// </summary>
        protected override void ProcessRecord()
        {
            this.WriteVerbose("Formatting log");
            using (var xmlReader = new StringReader(this.Log))
            {
                var xpath = new XPathDocument(xmlReader);
                using (var writer = new StringWriter())
                {
                    var transform = new XslCompiledTransform();
                    Func<string, string> selector = file => !Path.IsPathRooted(file) ? Path.Combine(Environment.CurrentDirectory, file) : file;
                    foreach (var fileToLoad in this.FormatFile.Select(selector))
                    {
                        this.WriteVerbose("Loading format file " + fileToLoad);
                        using (var stream = File.OpenRead(fileToLoad))
                        {
                            using (var reader = XmlReader.Create(stream))
                            {
                                transform.Load(reader);
                                transform.Transform(xpath, null, writer);
                            }
                        }
                    }

                    this.WriteObject(writer.GetStringBuilder().ToString(), false);
                }
            }
        }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:30,代码来源:FormatLog.cs

示例3: Visit

        public string Visit(string text)
        {
            text = text.Trim();

            var lines = new List<string>();
            using (var stringReader = new StringReader(text))
            {
                string line;
                while ((line = stringReader.ReadLine()) != null)
                {
                    line = line.Trim();
                    lines.Add(line);
                }
            }

            lines.Sort();

            var stringBuilder = new StringBuilder();
            foreach (var line in lines)
            {
                stringBuilder.AppendLine(line);
            }

            return stringBuilder.ToString();
        }
开发者ID:Teodor92,项目名称:OpenJudgeSystem,代码行数:25,代码来源:SortAndTrimLinesVisitor.cs

示例4: Filter

 public static string Filter(string stack)
 {
     if (stack == null)
     {
         return null;
     }
     StringWriter writer = new StringWriter();
     StringReader reader = new StringReader(stack);
     try
     {
         string str2;
         while ((str2 = reader.ReadLine()) != null)
         {
             if (!FilterLine(str2))
             {
                 writer.WriteLine(str2.Trim());
             }
         }
     }
     catch (Exception)
     {
         return stack;
     }
     return writer.ToString();
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:25,代码来源:StackTraceFilter.cs

示例5: CriticalPirsonCriterion

		private List<double> significance_level;		        //Уровнь значимости

		//Загружает таблицу критических значений
		private CriticalPirsonCriterion()
		{

			try
			{
				using (var sr = new StringReader(Resources.PirsonCritical))
				{
					int k = 1;          //Степень свободы
					string line;        //Текущая строка

					table = new List<Dictionary<double, double>>();

					//Парсим первую строку с уровнями значимости
					line = sr.ReadLine();
					significance_level = get_significance_levle(line);

					//Читаем оставшиеся строки и заполняем таблицу
					while ((line = sr.ReadLine()) != null)
						table.Add(get_line_values(line, significance_level));
				}
			}
			catch(FormatException exp)
			{
				throw new Exception("ОШИБКА ФАЙЛА КРИТИЧЕСКИХ ТОЧЕК: значение в файле не является числом");
			}
			catch(IOException exp)
			{
				throw new Exception("ОШИБКА ФАЙЛА КРИТИЧЕСКИХ ТОЧЕК: не удается открыть файл");
			}
			catch(Exception exp)
			{
				throw exp;
			}
		}
开发者ID:Garrus007,项目名称:StatisticDistribution.sln,代码行数:37,代码来源:CriticalPirsonCriterion.cs

示例6: Go

        public void Go()
        {
            var outputFile = Helpers.IO.GetClassOutputPath(this);
            var fixedHtml = FixBrokenServerControlMarkup(HTML);
            using (FileStream stream = new FileStream(
                outputFile,
                FileMode.Create,
                FileAccess.Write))
            {
                using (var document = new Document())
                {
                    PdfWriter writer = PdfWriter.GetInstance(
                        document, stream
                    );
                    document.Open();
                    using (var xmlSnippet = new StringReader(fixedHtml))
                    {
                        XMLWorkerHelper.GetInstance().ParseXHtml(
                            writer, document, xmlSnippet
                        );
                    }

                }
            }
        }
开发者ID:kuujinbo,项目名称:StackOverflow.iTextSharp,代码行数:25,代码来源:EndTag.cs

示例7: TestStemming

 public virtual void TestStemming()
 {
     TextReader reader = new StringReader("chevaux");
     TokenStream stream = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
     stream = TokenFilterFactory("FrenchMinimalStem").Create(stream);
     AssertTokenStreamContents(stream, new string[] { "cheval" });
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:7,代码来源:TestFrenchMinimalStemFilterFactory.cs

示例8: Parse

 public Document Parse(string commonMark)
 {
     using (var reader = new StringReader(commonMark))
     {
         return Parse(reader);
     }
 }
开发者ID:MortenHoustonLudvigsen,项目名称:CommonMarkSharp,代码行数:7,代码来源:CommonMark.cs

示例9: Run_should_populate_StartTime_and_EndTime_and_TotalRunTime

        public void Run_should_populate_StartTime_and_EndTime_and_TotalRunTime()
        {
            // Arrange
            var beforeStart = DateTime.UtcNow;
            var config = new Config();
            var testCaseReader = new TestCaseReaderMock();
            var stringReader = new StringReader("");

            var response = new HttpResponse();
            response.ResponseTime = TimeSpan.FromSeconds(5);

            HttpClientMock httpClient = new HttpClientMock(response);
            IResultWriter resultWriter = new ResultWriterStub();
            var runner = new TestSessionRunner(config, httpClient, resultWriter);

            var caseCollection = CreateCaseCollection(new[]
            {
                new Case() { Url = "foo1" },
            });

            // Act
            TestCaseSession session = runner.Run(caseCollection);

            // Assert
            Assert.That(session.StartTime, Is.GreaterThanOrEqualTo(beforeStart));
            Assert.That(session.EndTime, Is.GreaterThanOrEqualTo(session.StartTime));
            Assert.That(session.TotalRunTime, Is.EqualTo(session.EndTime - session.StartTime));
        }
开发者ID:pawelkmiec,项目名称:syringe,代码行数:28,代码来源:TestSessionRunnerTests.cs

示例10: ParseInstalledPluginsFile

        public static IList<string> ParseInstalledPluginsFile(string filePath)
        {
            //read and parse the file
            if (!File.Exists(filePath))
                return new List<string>();

            var text = File.ReadAllText(filePath);
            if (String.IsNullOrEmpty(text))
                return new List<string>();
            
            //Old way of file reading. This leads to unexpected behavior when a user's FTP program transfers these files as ASCII (\r\n becomes \n).
            //var lines = text.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            
            var lines = new List<string>();
            using (var reader = new StringReader(text))
            {
                string str;
                while ((str = reader.ReadLine()) != null)
                {
                    if (String.IsNullOrWhiteSpace(str))
                        continue;
                    lines.Add(str.Trim());
                }
            }
            return lines;
        }
开发者ID:LaOrigin,项目名称:Leorigin,代码行数:26,代码来源:PluginFileParser.cs

示例11: GetData

 /// <summary>
 /// 读取指定节点的值
 /// </summary>
 /// <param name="XmlPathNode">节点的XPATH</param>
 /// <returns>返回一个DataView</returns>
 public DataSet GetData(string XmlPathNode)
 {
     DataSet ds = new DataSet();
     StringReader read = new StringReader(objXmlDoc.SelectSingleNode(XmlPathNode).OuterXml);
     ds.ReadXml(read);
     return ds;
 }
开发者ID:zhanglc8801,项目名称:WKT2015,代码行数:12,代码来源:XMLOper.cs

示例12: CheckSplits

        private static void CheckSplits(string testString, string expectedSplits)
        {
            StringReader r = new StringReader(testString);
            var filter = SnowballAndWordSplittingAnalyzer.GetStandardFilterSet(r);

            int expectToFindThisMany = expectedSplits.Split().Length;
            var expectedSplitWords = new HashSet<string>();
            foreach (var term in expectedSplits.Split())
                expectedSplitWords.Add(term.ToLower());
            var notExpected = new HashSet<string>();

            Token token = filter.Next();
            HashSet<string> foundSplits = new HashSet<string>() ;
            while (token!=null && !String.IsNullOrEmpty(token.ToString()))
            {
                Debug.WriteLine(token.Term());
                int before = expectedSplitWords.Count;
                expectedSplitWords.Remove(token.Term());
                int after = expectedSplitWords.Count;
                if (before == after)
                    notExpected.Add(token.Term());
                foundSplits.Add(token.Term());
                token = filter.Next();
            }
            Assert.AreEqual(0, expectedSplitWords.Count);
            Assert.AreEqual(foundSplits.Count, expectToFindThisMany, string.Join(", ", notExpected));
        }
开发者ID:spati2,项目名称:FSE-2012-SANDO,代码行数:27,代码来源:SandoDocumentStringExtensionTest.cs

示例13: Activate

		public void Activate(string[] args)
		{
			bool verbose = false;
			if (args.Length > 0)
			{
				foreach (string arg in args)
				{
					if (arg.ToLower() ==  "/verbose")
						verbose = true;
				}
			}
			try
			{
				runtime = new Runtime();
				Environment globalEnvironment = new Environment();
				foreach (string line in LSharpCode)
				{
					if (verbose)
						Console.Write(line + " --> ");
					System.IO.StringReader reader = new System.IO.StringReader(line);
					object output = Runtime.EvalString(line, globalEnvironment);
					Console.WriteLine(Printer.WriteToString(output));
				}
			}
			catch (Exception e)
			{
				Console.WriteLine(e.ToString());
			}
			System.Console.WriteLine("Press any key to Continue...");
			System.Console.ReadKey(true);
		}
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:31,代码来源:cadr.cs

示例14: ReadLines

		public static IEnumerable<string> ReadLines(this string content)
		{
			string line;
			using (var sr = new StringReader(content))
				while ((line = sr.ReadLine()) != null)
					yield return line;
		}
开发者ID:nashdot,项目名称:reversemarkdown-net,代码行数:7,代码来源:StringUtils.cs

示例15: TestPositionIncrements

 public virtual void TestPositionIncrements()
 {
     Reader reader = new StringReader("foo foobar super-duper-trooper");
     TokenStream stream = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
     stream = TokenFilterFactory("Length", LengthFilterFactory.MIN_KEY, "4", LengthFilterFactory.MAX_KEY, "10").Create(stream);
     AssertTokenStreamContents(stream, new string[] { "foobar" }, new int[] { 2 });
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:7,代码来源:TestLengthFilterFactory.cs


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