當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。