本文整理汇总了C#中System.IO.StringReader.ReadLine方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.StringReader.ReadLine方法的具体用法?C# System.IO.StringReader.ReadLine怎么用?C# System.IO.StringReader.ReadLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StringReader
的用法示例。
在下文中一共展示了System.IO.StringReader.ReadLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSampleClimate
public static SampleClimate GetSampleClimate()
{
List<double[]> result = new List<double[]>();
using (var f = new System.IO.StringReader(Properties.Resources.SampleCatchmentData))
{
var line = f.ReadLine();
while (!string.IsNullOrEmpty(line))
{
var items = line.Split(',');
double[] values = Array.ConvertAll(items, parseDouble);
if (values.Length != 3)
throw new ArgumentException();
result.Add(values);
line = f.ReadLine();
}
}
int n = result.Count;
var res = new double[][] { new double[n], new double[n], new double[n] };
for (int i = 0; i < n; i++)
{
for (int j = 0; j < 3; j++)
{
res[j][i] = result[i][j];
}
}
return new SampleClimate { Rainfall = res[0], Evapotranspiration = res[1], Runoff = res[2] };
}
示例2: PostProcess
/// <summary>Called when extension shall process generated code</summary>
/// <param name="code">The code</param>
/// <param name="provider">CodeDOM provider (the language)</param>
/// <version version="1.5.3">Parameter <c>Provider</c> renamed to <c>provider</c></version>
public void PostProcess(ref string code, CodeDomProvider provider)
{
System.IO.StringWriter tw = new System.IO.StringWriter();
provider.GenerateCodeFromStatement(new CodeCommentStatement(FirtsLineOfAccessor), tw, new System.CodeDom.Compiler.CodeGeneratorOptions());
string srch = tw.GetStringBuilder().ToString();
if (srch.EndsWith("\r\n")) srch = srch.Substring(0, srch.Length - 2);
else if (srch.EndsWith("\r") || srch.EndsWith("\n")) srch = srch.Substring(0, srch.Length - 1);
tw = new System.IO.StringWriter();
CodeTypeDeclaration foo = new CodeTypeDeclaration("foo");
foo.CustomAttributes.Add(NewAttribute);
provider.GenerateCodeFromType(foo, tw, new System.CodeDom.Compiler.CodeGeneratorOptions());
string attr = new System.IO.StringReader(tw.GetStringBuilder().ToString()).ReadLine();
System.IO.StringReader sr = new System.IO.StringReader(code);
List<String> Lines = new List<string>();
do {
string line = sr.ReadLine();
if (line == null) break;
if (line.EndsWith(srch))
Lines[Lines.Count - 1] = attr + "\r\n" + Lines[Lines.Count - 1];
else
Lines.Add(line);
} while (true);
System.Text.StringBuilder b = new System.Text.StringBuilder();
foreach (string line in Lines)
b.AppendLine(line);
code = b.ToString();
}
示例3: Read
//────────────────────────────────────────
/// <summary>
/// Listを作成します。
///
/// セルのデータ型は全て string です。
/// </summary>
/// <param name="csvText"></param>
/// <returns></returns>
public List<string[]> Read(
string string_Csv
)
{
//
// テーブルを作成します。
//
List<string[]> list_ArrayString = new List<string[]>();
System.IO.StringReader reader = new System.IO.StringReader(string_Csv);
CsvLineParserImpl csvParser = new CsvLineParserImpl();
// CSVを解析して、テーブル形式で格納。
{
int nRowIndex = 0;
while (-1 < reader.Peek())
{
string sLine = reader.ReadLine();
//
// 配列の返却値を、ダイレクトに渡します。
//
string[] sFields = csvParser.UnescapeLineToFieldList(sLine, this.CharSeparator).ToArray();
list_ArrayString.Add(sFields);
nRowIndex++;
}
}
// ストリームを閉じます。
reader.Close();
return list_ArrayString;
}
示例4: part3
//part3 поиск по маске рлецб p2[3] + p2[2] + * + p2[7] + p2[1]
public string part3(string str3,string strch,TextBox txtbox)
{
//должна вернуть слово(список слов)
System.IO.StringReader file = new System.IO.StringReader(Properties.Resources.Dictionary);
string line="";
string tmp3="";
string res = str3+"(";
int ctr = 0;
string toTxt3 = strch + " - ";
while ((line = file.ReadLine()) != null)
{
tmp3 = line.Trim();
if(tmp3.Length == 5)
{
if (tmp3[0] == str3[3] && tmp3[1] == str3[2] && tmp3[3] == str3[7] && tmp3[4] == str3[1])
{
res = res + tmp3 + ", ";
toTxt3 = toTxt3 + part4(tmp3);//+
ctr++;
}
}
}
if (toTxt3 != strch + " - ")
{
txtbox.AppendText(toTxt3 + "\r\n");
}
if (ctr == 0) { res = ""; }
else {
res = res.Substring(0, res.Length - 2) + "),";
}
return res;
}
示例5: TranslitEncoderFallbackBuffer
static TranslitEncoderFallbackBuffer()
{
transliterations = new Dictionary<char, string>(3900);
// initialize the transliterations table:
// load "translit.def" file content:
using (var translit = new System.IO.StringReader(Strings.translit))
{
string line;
while ((line = translit.ReadLine()) != null)
{
// remove comments:
int cut_from = line.IndexOf('#');
if (cut_from >= 0) line = line.Remove(cut_from);
// skip empty lines:
if (line.Length == 0) continue;
//
string[] parts = line.Split('\t'); // HEX\tTRANSLIT\t
Debug.Assert(parts != null && parts.Length == 3);
int charNumber = int.Parse(parts[0], System.Globalization.NumberStyles.HexNumber);
string str = parts[1];
if (transliterationsMaxCharCount < str.Length)
transliterationsMaxCharCount = str.Length;
transliterations[(char)charNumber] = str;
}
}
}
示例6: IgnoreList_TextChanged
private void IgnoreList_TextChanged(object sender, EventArgs e)
{
List<string> list = new List<string>();
int lineIndex = 1;
try {
using (var reader = new System.IO.StringReader(IgnoreList.Text)) {
string line;
while ((line = reader.ReadLine()) != null) {
line = line.Trim();
if (line.Length == 0) {
// ignore
}
else if (line.Length >= 3 && line.StartsWith("/") && line.EndsWith("/")) {
var subLine = line.Substring(1, line.Length - 2);
var regexp = new System.Text.RegularExpressions.Regex(subLine);
list.Add(line);
}
else {
list.Add(line);
}
lineIndex++;
}
}
_settings.IgnoreList = list.ToArray();
IgnoreListCheckResult.Visible = false;
btnClose.Enabled = true;
}
catch (Exception ex) {
IgnoreListCheckResult.Text = "[ " + lineIndex + " 行目 ] " + ex.Message;
IgnoreListCheckResult.Visible = true;
btnClose.Enabled = false;
}
}
示例7: ResolveImports
private String ResolveImports(String Path, List<String> FilesLoaded = null)
{
Path = Path.Replace('\\', '/');
if (FilesLoaded == null) FilesLoaded = new List<String>();
else if (FilesLoaded.Contains(Path))
return "";
FilesLoaded.Add(Path);
var source = LoadSourceFile(Path);
if (source.Item1 == false)
{
Core.LogError(Path + " - " + source.Item2);
return "";
}
var output = new StringBuilder();
var stream = new System.IO.StringReader(source.Item2);
while (true)
{
var line = stream.ReadLine();
if (line == null) break;
if (line.StartsWith("//import "))
{
var importedFilename = line.Substring("//import ".Length).Trim();
output.Append(ResolveImports(importedFilename, FilesLoaded));
output.AppendLine();
}
else
output.AppendLine(line);
}
return output.ToString();
}
示例8: parse
public List<CCFE_ConfigurationProperty> parse()
{
List<CCFE_ConfigurationProperty> propertyList = new List<CCFE_ConfigurationProperty>();
//read in file data as string
string fileText = System.IO.File.ReadAllText(FileLocation);
//create StringReader to parse string
System.IO.StringReader stringReader = new System.IO.StringReader(fileText);
string line;
string propertyPattern = "^([A-Z])([A-z])+=\\S+";
string[] propertyValues;
while ((line = stringReader.ReadLine()) != null)
{
//check if line is a property using regex
if (System.Text.RegularExpressions.Regex.IsMatch(line, propertyPattern))
{
//break string into 'name' and 'value' parts
propertyValues = line.Split('=');
propertyList.Add(new CCFE_ConfigurationProperty(propertyValues[0], propertyValues[1]));
}
}
stringReader.Close();
return propertyList;
}
示例9: AIHA
static AIHA()
{
aihaData = new System.Collections.Generic.List<ERPGData>();
try
{
System.IO.StringReader reader = new System.IO.StringReader(Properties.Resources._2015_ERPG_Levels);
string nextLine = reader.ReadLine();
while (nextLine != null)
{
aihaData.Add(new ERPGData(nextLine));
nextLine = reader.ReadLine();
}
}
catch (System.Exception obj)
{
obj.GetType();
}
}
示例10: parse
private void parse(String text, int type)
{
Regex rgx = new Regex(@"^(S\d+:)(.*)");
Run r;
StringBuilder sb = new StringBuilder();
var sr = new System.IO.StringReader(text);
String line;
while ((line = sr.ReadLine()) != null)
{
if (type == 0)
{
if (line.StartsWith("Routine"))
{
r = new Run(sb.ToString());
tb.Inlines.Add(r);
r = new Run(line + "\n");
r.Foreground = Brushes.Red;
r.FontWeight = FontWeights.Bold;
tb.Inlines.Add(r);
sb.Clear();
}
else
{
sb.Append(line + "\n");
}
}
else
{
Match m = rgx.Match(line);
if (m.Success)
{
r = new Run(sb.ToString());
tb.Inlines.Add(r);
r = new Run(m.Groups[1].Value);
r.Foreground = Brushes.Red;
r.FontWeight = FontWeights.Bold;
tb.Inlines.Add(r);
r = new Run(m.Groups[2].Value + "\n");
tb.Inlines.Add(r);
sb.Clear();
}
else
{
sb.Append(line + "\n");
}
}
}
r = new Run(sb.ToString());
tb.Inlines.Add(r);
}
示例11: TRIList
static TRIList()
{
triChemicalListData = new System.Collections.Generic.List<triChemical>();
try
{
System.IO.StringReader reader = new System.IO.StringReader(Properties.Resources.tri_chemical_list_for_ry15_11_5_2015_1);
string nextLine = reader.ReadLine();
while (nextLine != null)
{
triChemicalListData.Add(new triChemical(nextLine));
nextLine = reader.ReadLine();
}
}
catch (System.Exception obj)
{
obj.GetType();
}
}
示例12: IDLH
static IDLH()
{
idlhData = new System.Collections.Generic.List<nioshSubstance>();
try
{
System.IO.StringReader reader = new System.IO.StringReader(Properties.Resources.idlh);
string nextLine = reader.ReadLine();
while (nextLine != null)
{
idlhData.Add(new nioshSubstance(nextLine));
nextLine = reader.ReadLine();
}
}
catch (System.Exception obj)
{
obj.GetType();
}
}
示例13: frmSaveBarcodes_Load
private void frmSaveBarcodes_Load(object sender, EventArgs e)
{
using (System.IO.StringReader rd = new System.IO.StringReader(""))
{
richTextBox1.Text = rd.ReadLine();
rd.Close();
}
}
示例14: btnProcessFile_Click
private void btnProcessFile_Click(object sender, RoutedEventArgs e)
{
if (lbFileName.Text == "")
MessageBox.Show("Select the file you want to process.");
else if (!System.IO.File.Exists(lbFileName.Text))
MessageBox.Show("The specificed file does not exist anymore.");
else {
int minimumCharacterCount = 0;
try {
minimumCharacterCount = int.Parse(txMinimumCharacterCount.Text);
if (minimumCharacterCount == 0)
MessageBox.Show("You must enter a positive value for minimum character count.");
} catch {
MessageBox.Show("Be sure to only enter digits in the minimum character count.");
}
if (minimumCharacterCount > 0 && MessageBox.Show("This process will overwrite the specified file. Continue?", "Confirm Overwrite", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) {
var fileContents = System.IO.File.ReadAllText(lbFileName.Text);
var reader = new System.IO.StringReader(fileContents);
string line;
var newFileContents = new System.Text.StringBuilder();
line = reader.ReadLine();
while (line != null) {
if (line.Length >= minimumCharacterCount)
newFileContents.AppendLine(line);
line = reader.ReadLine();
}
reader.Close();
System.IO.File.WriteAllText(lbFileName.Text, newFileContents.ToString());
MessageBox.Show("Process Completed");
}
}
}
示例15: FromPlainText
/// <summary>
/// Convert a plain text to an XHTML valid text.
/// </summary>
public static string FromPlainText(string plainText, PlainTextMode mode)
{
if (mode == PlainTextMode.CSSPlainText)
{
string htmlEncoded = System.Web.HttpUtility.HtmlEncode(plainText);
System.Text.StringBuilder builder = new System.Text.StringBuilder();
builder.Append("<div class=\"plainText\">");
builder.Append(htmlEncoded);
builder.Append("</div>");
return builder.ToString();
}
else if (mode == PlainTextMode.XHtmlConversion)
{
System.Text.StringBuilder builder = new System.Text.StringBuilder();
using (System.IO.StringReader reader = new System.IO.StringReader(plainText))
{
string line;
while ( (line = reader.ReadLine()) != null )
{
if (line != null && line.Length > 0)
{
//Replace the space and tab characters at the begind of the line with a nont breaking space
for (int col = 0; col < line.Length; col++)
{
if (line[col] == ' ')
{
builder.Append(" ");
}
else if (line[col] == '\t')
{
builder.Append(" ");
}
else
{
string subLine = System.Web.HttpUtility.HtmlEncode(line.Substring(col));
builder.Append(subLine);
break;
}
}
}
builder.AppendLine("<br />");
}
}
return builder.ToString();
}
else
throw new EucalyptoException("Mode not valid");
}