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


C# StringReader.ReadLine方法代码示例

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


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

示例1: ToString

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(Message);
            int i = 1;
            foreach (IValidationResult result in ValidationResults)
            {
                if (!BoolUtil.IsTrue(result.Passed))
                {
                    if (result.Details != null)
                    {
                        foreach (IValidationResultInfo info in result.Details)
                        {
                            sb.Append(Environment.NewLine + i + ": ");
                            StringReader sr = new StringReader(info.ToString());
                            string s = sr.ReadLine();
                            bool isFirstLine = true;
                            while (!string.IsNullOrEmpty(s))
                            {
                                if (!isFirstLine)
                                    sb.Append(Environment.NewLine);
                                sb.Append("\t" + s);
                                isFirstLine = false;
                                s = sr.ReadLine();
                            }
                            sr.Close();

                            i++;
                        }
                    }
                }
            }

            return sb.ToString();
        }
开发者ID:ddaysoftware,项目名称:icalvalid,代码行数:35,代码来源:TestError.cs

示例2: Insert

        public bool Insert(Range range, string text, bool addNewline)
        {
            if (text.Length == 0)
            {
                return true;
            }

            string fileContents = File.ReadAllText(_filename);

            using (StringReader reader = new StringReader(fileContents))
            using (TextWriter writer = new StreamWriter(File.Open(_filename, FileMode.Create)))
            {
                string lineText;
                if (SeekTo(reader, writer, range, out lineText))
                {
                    writer.WriteLine(lineText.Substring(0, range.LineRange.Start) + text + (addNewline ? Environment.NewLine : string.Empty) + lineText.Substring(range.LineRange.Start));
                }

                lineText = reader.ReadLine();

                while (lineText != null)
                {
                    writer.WriteLine(lineText);
                    lineText = reader.ReadLine();
                }
            }

            return true;
        }
开发者ID:yannduran,项目名称:ProjectTaskRunner,代码行数:29,代码来源:FileTextUtil.cs

示例3: Parse

        public static Table Parse(IRestResponse response)
        {
            Table table = new Table();
            StringReader reader = new StringReader(response.Content);
            string readLine = reader.ReadLine();

            if (readLine != null)
            {
                string[] collection = readLine.Split(Separator);
                foreach (string column in collection)
                {
                    table.Columns.Add(column.TrimStart('"').TrimEnd('"'));
                }
            }

            string line = reader.ReadLine();

            while (!string.IsNullOrEmpty(line))
            {
                Row row = new Row(line);
                table.Rows.Add(row);
                line = reader.ReadLine();
            }

            return table;
        }
开发者ID:Genbox,项目名称:SPARQL.NET,代码行数:26,代码来源:CSVParser.cs

示例4: FetchData

		async Task FetchData ()
		{
			historyCache = new Dictionary<int, IEnumerable<KeyValuePair<DateTime, int>>> ();

			for (int i = 0; i < 3; i++) {
				try {
					var data = await client.GetStringAsync (HistoryApiEndpoint);
					// If another update was done in the meantime, no need to process it
					if (!NeedFetching)
						return;

					var reader = new StringReader (data);
					string line = reader.ReadLine ();
					var times = line.Split ('|').Select (t => DateTime.FromBinary (long.Parse (t))).ToArray ();
					while ((line = reader.ReadLine ()) != null) {
						var split = line.Split ('|');
						var id = int.Parse (split[0]);
						var datapoints = split.Skip (1).Select ((v, index) => {
							var time = times[index];
							var num = int.Parse (v);

							return new KeyValuePair<DateTime, int> (time, num);
						}).ToArray ();
						historyCache[id] = datapoints;
					}
					lastFetch = DateTime.UtcNow;
				} catch (Exception e) {
					e.Data ["method"] = "FetchData";
					Xamarin.Insights.Report (e);
					Android.Util.Log.Error ("HistoryDownloader", e.ToString ());
				}
			}
		}
开发者ID:SpiderMaster,项目名称:BikeNow,代码行数:33,代码来源:ProntoHistory.cs

示例5: Filter

        /// <summary>
        /// Filters a raw stack trace and returns the result.
        /// </summary>
        /// <param name="rawTrace">The original stack trace</param>
        /// <returns>A filtered stack trace</returns>
        public static string Filter(string rawTrace)
        {
            if (rawTrace == null) return null;

            StringReader sr = new StringReader(rawTrace);
            StringWriter sw = new StringWriter();

            try
            {
                string line;
                // Skip past any Assert or Assume lines
                while ((line = sr.ReadLine()) != null && assertOrAssumeRegex.IsMatch(line))
                    /*Skip*/
                    ;

                // Copy lines down to the line that invoked the failing method.
                // This is actually only needed for the compact framework, but 
                // we do it on all platforms for simplicity. Desktop platforms
                // won't have any System.Reflection lines.
                while (line != null && line.IndexOf(" System.Reflection.") < 0)
                {
                    sw.WriteLine(line.Trim());
                    line = sr.ReadLine();
                }
            }
            catch (Exception)
            {
                return rawTrace;
            }

            return sw.ToString();
        }
开发者ID:alfeg,项目名称:nunit,代码行数:37,代码来源:StackFilter.cs

示例6: Filter

        /// <summary>
        /// Filters a raw stack trace and returns the result.
        /// </summary>
        /// <param name="rawTrace">The original stack trace</param>
        /// <returns>A filtered stack trace</returns>
        public static string Filter(string rawTrace)
        {
            if (rawTrace == null) return null;

            StringReader sr = new StringReader(rawTrace);
            StringWriter sw = new StringWriter();

            try
            {
                string line;
                // TODO: Handle Assume and any other verbs
                // Best way is probably to check first line and
                // see where the exception was thrown, then
                // discard all leading lines within the same class.
                while ((line = sr.ReadLine()) != null && line.IndexOf("at NUnit.Framework.Assert.") >= 0)
                    /*Skip*/
                    ;

                while (line != null)
                {
                    sw.WriteLine(line);
                    line = sr.ReadLine();
                }
            }
            catch (Exception)
            {
                return rawTrace;
            }

            return sw.ToString();
        }
开发者ID:balaghanta,项目名称:nunit-framework,代码行数:36,代码来源:StackFilter.cs

示例7: MIMEHeader

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="HeaderText">Text for the header</param>
 public MIMEHeader(string HeaderText)
 {
     if(string.IsNullOrEmpty(HeaderText))
         throw new ArgumentNullException("Header text can not be null");
     StringReader Reader=new StringReader(HeaderText);
     try
     {
         string LineRead=Reader.ReadLine();
         string Field=LineRead+"\r\n";
         while(!string.IsNullOrEmpty(LineRead))
         {
             LineRead=Reader.ReadLine();
             if (!string.IsNullOrEmpty(LineRead) && (LineRead[0].Equals(' ') || LineRead[0].Equals('\t')))
             {
                 Field += LineRead + "\r\n";
             }
             else
             {
                 Fields.Add(new Field(Field));
                 Field = LineRead + "\r\n";
             }
         }
     }
     finally
     {
         Reader.Close();
         Reader=null;
     }
 }
开发者ID:summer-breeze,项目名称:ChengGouHui,代码行数:33,代码来源:MIMEHeader.cs

示例8: RunSWAT

        /// <summary>
        /// Run given SWAT executable and return the running time
        /// </summary>
        /// <param name="swatexe">The path of the executable</param>
        /// <param name="num">Number of times the executable will be run</param>
        /// <param name="iprint">The iprint that will be set to file.cio</param>
        /// <returns></returns>
        static double RunSWAT(string swatexe, int num, int iprint)
        {
            Console.WriteLine(string.Format("Runing {0} with iprint = {1}",swatexe,iprint));

            //change the iprint first
            //find file.cio
            System.IO.FileInfo info = new FileInfo(swatexe);
            string cioFile = info.DirectoryName + @"\file.cio";
            if (!System.IO.File.Exists(cioFile))
                throw new Exception("Couldn't find " + cioFile);

            //modify file.cio with given output interval, which is located in line 59
            string cio = null;
            using (System.IO.StreamReader reader = new StreamReader(cioFile))
            {
                cio = reader.ReadToEnd();
            }
            using (System.IO.StreamWriter writer = new StreamWriter(cioFile))
            {
                using (System.IO.StringReader reader = new StringReader(cio))
                {
                    string oneline = reader.ReadLine();
                    while (oneline != null)
                    {
                        if (oneline.Contains("IPRINT"))
                            oneline = string.Format("{0}    | IPRINT: print code (month, day, year)", iprint);
                        writer.WriteLine(oneline);
                        oneline = reader.ReadLine();
                    }
                }
            }

            //start to run
            return RunSWAT(swatexe, num);
        }
开发者ID:ajarbancina,项目名称:swat-eclipse,代码行数:42,代码来源:Program.cs

示例9: SharePointClient

        // ---------- PROPERTIES ----------
        // ---------- CONSTRUCTORS ----------
        /// <summary>
        /// Connects the client to SharePoint using the configuration in the specified configuration item.
        /// </summary>
        /// <param name="configurationItemDirectoryPath">The physical path to the directory where configuration item files can be found.</param>
        /// <param name="configurationItemName">The name of the configuration item containing the SharePoint client configuration.</param>
        public SharePointClient(string configurationItemDirectoryPath, string configurationItemName)
        {
            if (!string.IsNullOrWhiteSpace(configurationItemDirectoryPath) && !string.IsNullOrWhiteSpace(configurationItemName))
            {
                // Get the configuration item with the connection data from a file.
                ConfigurationItem configItem = new ConfigurationItem(configurationItemDirectoryPath, configurationItemName, true);

                // Read the credentials from the configuration item.
                if (!string.IsNullOrWhiteSpace(configItem.Value))
                {
                    StringReader reader = new StringReader(configItem.Value);
                    userName = reader.ReadLine();
                    password = reader.ReadLine();
                    domain = reader.ReadLine();
                    contextUrl = reader.ReadLine();
                }

                // Initialize the client context.
                clientContext = new ClientContext(contextUrl)
                {
                    // Add the credentials to the SharePoint context.
                    Credentials = new NetworkCredential(userName, password, domain)
                };
            }
            else
            {
                throw new ArgumentException("Unable to establish connection to SharePoint.");
            }
        }
开发者ID:iw79,项目名称:Galactic,代码行数:36,代码来源:SharePointClient.cs

示例10: TaskAssignmentsInit

        private void TaskAssignmentsInit(string input)
        {
            StringReader sr = new StringReader(input);

            n = Convert.ToInt32(sr.ReadLine());
            m = 0;

            string[] aInputs = sr.ReadLine().Split(new char[]{' '});
            a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = Convert.ToInt32(aInputs[i]);
                if (a[i] > m)
                    m = a[i];
            }

            string[] bInputs = sr.ReadLine().Split(new char[] { ' ' });
            b = new int[n];
            for (int i = 0; i < n; i++)
            {
                b[i] = Convert.ToInt32(bInputs[i]);
                if (b[i] > m)
                    m = b[i];
            }

            mn = m * n;
            p = new bool[mn+1, mn+1, n+1];
        }
开发者ID:neolee11,项目名称:Algorithm,代码行数:28,代码来源:DPTaskAssignmentsClass.cs

示例11: InsertXmlDocumentation

 static void InsertXmlDocumentation(AstNode node, StringReader r)
 {
     // Find the first non-empty line:
     string firstLine;
     do
     {
         firstLine = r.ReadLine();
         if (firstLine == null)
             return;
     } while (string.IsNullOrWhiteSpace(firstLine));
     string indentation = firstLine.Substring(0, firstLine.Length - firstLine.TrimStart().Length);
     string line = firstLine;
     int skippedWhitespaceLines = 0;
     // Copy all lines from input to output, except for empty lines at the end.
     while (line != null)
     {
         if (string.IsNullOrWhiteSpace(line))
         {
             skippedWhitespaceLines++;
         }
         else
         {
             while (skippedWhitespaceLines > 0)
             {
                 node.Parent.InsertChildBefore(node, new Comment(string.Empty, CommentType.Documentation), Roles.Comment);
                 skippedWhitespaceLines--;
             }
             if (line.StartsWith(indentation, StringComparison.Ordinal))
                 line = line.Substring(indentation.Length);
             node.Parent.InsertChildBefore(node, new Comment(" " + line, CommentType.Documentation), Roles.Comment);
         }
         line = r.ReadLine();
     }
 }
开发者ID:CompilerKit,项目名称:CodeWalk,代码行数:34,代码来源:AddXmlDocTransform.cs

示例12: AsMarkdown

        /// <summary>
        ///     转化为markdown格式。
        /// </summary>
        /// <param name="schema"></param>
        /// <returns></returns>
        public static string AsMarkdown(JsonSchema schema)
        {
            var sb = new StringBuilder();

            // 生成表格
            sb.AppendLine(AsMarkdown(schema, 1).Trim());

            // 生成例子
            sb.AppendLine();
            sb.AppendLine("例子");
            sb.AppendLine();

            JToken demoToken = JsonDemoGenerator.Generate(schema);
            string demo = JsonConvert.SerializeObject(demoToken, Formatting.Indented);

            // 每一行前+4个空格,以适应markdown的code格式。
            var sr = new StringReader(demo);
            string line = sr.ReadLine();
            while (!string.IsNullOrEmpty(line))
            {
                sb.AppendLine("    " + line);
                line = sr.ReadLine();
            }

            return sb.ToString();
        }
开发者ID:JohnnyFee,项目名称:JsonDoc,代码行数:31,代码来源:JsonDocFormatter.cs

示例13: Load

        static List<AssetData> Load()
        {
            var assetlist = new List<AssetData>();

            var files = Directory.GetFiles("Assets", "ImportPackages*.imp", SearchOption.AllDirectories);
            foreach( var file in files ){
                var text = File.ReadAllText(file);
                var textReader = new System.IO.StringReader(text);
                var url = textReader.ReadLine();

                var assetData = new AssetData();
                assetData.asseturl = url;
                assetlist.Add(assetData);

                while( textReader.Peek() > -1 ){
                    var strs = textReader.ReadLine().Split(',');
                    var guid = strs[1];
                    var requestFilePath = strs[0];

                    var filePath = AssetDatabase.GUIDToAssetPath( guid );
                    if( string.IsNullOrEmpty( filePath ) || File.Exists(filePath) == false ){
                        assetData.pathList.Add(requestFilePath);
                    }
                }
            }

            return assetlist;
        }
开发者ID:tsubaki,项目名称:Unity-AssetRequest,代码行数:28,代码来源:PackageMaker.cs

示例14: GenerateCS

        private void GenerateCS()
        {
            using (Microsoft.CSharp.CSharpCodeProvider provider = new Microsoft.CSharp.CSharpCodeProvider())
            {
                CodeGeneratorOptions opts = new CodeGeneratorOptions();
                StringWriter sw = new StringWriter();
                provider.GenerateCodeFromMember(_method, sw, opts);
                StringReader sr = new StringReader(sw.GetStringBuilder().ToString());
                string line = sr.ReadLine();
                while (string.IsNullOrEmpty(line))
                    line = sr.ReadLine();
                int idx = line.IndexOf(" " + _method.Name + "(");
                idx = line.LastIndexOf(' ', idx - 1);

                if (_method.Statements.Count > 0)
                {
                    Text = "partial" + line.Remove(0, idx);
                    Text = sw.GetStringBuilder().Replace(line, Text).ToString();
                }
                else
                {
                    line = "partial" + line.Remove(0, idx);
                    idx = line.LastIndexOf(')');
                    Text = line.Remove(idx + 1) + ";" + Environment.NewLine;
                }
            }
        }
开发者ID:laymain,项目名称:CodeDomUtils,代码行数:27,代码来源:CodePartialMethod.cs

示例15: Run

        public static string Run(string input)
        {
            var sr = new StringReader(input);
            var gridMaxString = sr.ReadLine();

            Parser parser = new Parser();
            var gridMax = parser.MaxPosition(gridMaxString);

            var output = new StringBuilder();

            for (; ; )
            {
                var startAsString = sr.ReadLine();
                var movementsAsString = sr.ReadLine();
                if (string.IsNullOrEmpty(startAsString) || string.IsNullOrEmpty(movementsAsString))
                {
                    break;
                }

                var start = parser.Start(startAsString);
                var movements = parser.Movements(movementsAsString);
                var rover = new Rover(start.Position, start.Direction);
                rover = movements(rover);
                output.AppendFormat("{0}{1}", rover, Environment.NewLine);
            }

            return output.ToString();
        }
开发者ID:philderbeast,项目名称:mars-rover,代码行数:28,代码来源:Program.cs


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