本文整理汇总了C#中TextReader类的典型用法代码示例。如果您正苦于以下问题:C# TextReader类的具体用法?C# TextReader怎么用?C# TextReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextReader类属于命名空间,在下文中一共展示了TextReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Generate
/// <summary>Parse the input X# source code file and generate the matching target assembly
/// language.</summary>
/// <param name="aReader">X# source code reader.</param>
/// <returns>The resulting target assembler content. The returned object contains
/// a code and a data block.</returns>
public Assembler Generate(TextReader aReader)
{
if (aReader == null)
{
throw new ArgumentNullException(nameof(aReader));
}
mPatterns.EmitUserComments = EmitUserComments;
mLineNo = 0;
var xResult = new Assembler();
try
{
// Read one X# source code line at a time and process it.
while (true)
{
mLineNo++;
string xLine = aReader.ReadLine();
if (xLine == null)
{
break;
}
ProcessLine(xLine, mLineNo);
}
AssertLastFunctionComplete();
return xResult;
}
finally
{
Assembler.ClearCurrentInstance();
}
}
开发者ID:ChrisJamesSadler,项目名称:Cosmos,代码行数:36,代码来源:AsmGenerator.cs
示例2: Parse
public static DataTable Parse(TextReader stream, CsvHeadersAction Headers, char delimiter)
{
DataTable table = new DataTable();
CsvStream csv = new CsvStream(stream);
string[] row = csv.GetNextRow(delimiter);
if (row == null)
return null;
if (Headers == CsvHeadersAction.SkipHeaderLine)
{
row = csv.GetNextRow(delimiter);
}
if (Headers == CsvHeadersAction.UseAsColumnNames)
{
//foreach (string header in row)
for (int i = 0;i<row.Length;i++)
{
if (row[i] != null && row[i].Length > 0 && !table.Columns.Contains(row[i]))
table.Columns.Add(row[i], typeof(string));
else
table.Columns.Add(GetNextColumnHeader(table), typeof(string));
}
row = csv.GetNextRow(delimiter);
}
while (row != null)
{
while (row.Length > table.Columns.Count)
table.Columns.Add(GetNextColumnHeader(table), typeof(string));
table.Rows.Add(row);
row = csv.GetNextRow(delimiter);
}
stream.Close();
stream.Dispose();
return table;
}
开发者ID:pirzada,项目名称:sinapse,代码行数:34,代码来源:Parser.cs
示例3: BufferedCharReader
public BufferedCharReader(TextReader reader, int bufferSize)
{
Debug.Assert(reader != null);
_reader = reader;
_bufferSize = Math.Max(256, bufferSize);
}
开发者ID:ashou1986,项目名称:top4net,代码行数:7,代码来源:BufferedCharReader.cs
示例4: ThesaurusSpliter
/// <summary>
/// �ִʴ��������캯��
/// </summary>
/// <param name="input">�ı���ȡ��</param>
public ThesaurusSpliter(TextReader input)
{
this.input = input;
//����������.ģ�����뷨���������Ĺ���
assoStream = new AssociateStream();
ReadBuffer();
}
开发者ID:sqzhuyi,项目名称:cnopenblog,代码行数:11,代码来源:ThesaurusSpliter.cs
示例5: WsdlParser
// Main parser
internal WsdlParser(TextReader input, String outputDir, ArrayList outCodeStreamList, String locationURL, bool bWrappedProxy, String proxyNamespace)
{
Util.Log("WsdlParser.WsdlParser outputDir "+outputDir+" locationURL "+locationURL+" bWrappedProxy "+bWrappedProxy+" proxyNamespace "+proxyNamespace);
// Initialize member variables
_XMLReader = null;
_readerStreamsWsdl = new ReaderStream(locationURL);
_readerStreamsWsdl.InputStream = input;
_writerStreams = null;
_outputDir = outputDir;
_outCodeStreamList = outCodeStreamList;
_bWrappedProxy = bWrappedProxy;
if (proxyNamespace == null || proxyNamespace.Length == 0)
_proxyNamespace = "InteropNS";
else
_proxyNamespace = proxyNamespace;
if (outputDir == null)
outputDir = ".";
int length = outputDir.Length;
if (length > 0)
{
char endChar = outputDir[length-1];
if (endChar != '\\' && endChar != '/')
_outputDir = _outputDir + '\\';
}
//_namespaceStack = null;
_URTNamespaces = new ArrayList();
_blockDefault = SchemaBlockType.ALL;
_primedNametable = CreatePrimedNametable();
}
开发者ID:JianwenSun,项目名称:cc,代码行数:32,代码来源:WsdlParser.cs
示例6: AccumulatePartial
private string AccumulatePartial(TextReader reader)
{
StringBuilder buffer = new StringBuilder();
buffer.Append(">");
do
{
reader.Read();
}
while(char.IsWhiteSpace((char)reader.Peek()));
while(true)
{
var peek = (char)reader.Peek();
if (peek == '}' || peek == '~' || char.IsWhiteSpace(peek))
{
break;
}
var node = reader.Read();
if (node == -1)
{
throw new InvalidOperationException("Reached end of template before the expression was closed.");
}
else
{
buffer.Append((char)node);
}
}
return buffer.ToString();
}
开发者ID:jamisliao,项目名称:Handlebars.Net,代码行数:28,代码来源:PartialParser.cs
示例7: OperatorScanner
internal OperatorScanner(TextReader reader, ErrorReporter reporter)
: base(reader, reporter)
{
twoCharacterOperators = new Dictionary<char, IDictionary<char, Type>>();
twoCharacterOperators[':'] = new Dictionary<char, Type>();
twoCharacterOperators[':']['='] = typeof(AssignmentToken);
twoCharacterOperators['.'] = new Dictionary<char, Type>();
twoCharacterOperators['.']['.'] = typeof(RangeToken);
singleCharacterOperators = new Dictionary<char, Type>();
singleCharacterOperators.Add('+', typeof(PlusToken));
singleCharacterOperators.Add('-', typeof(MinusToken));
singleCharacterOperators.Add('*', typeof(MultiplyToken));
singleCharacterOperators.Add('/', typeof(DivideToken));
singleCharacterOperators.Add('<', typeof(LessThanToken));
singleCharacterOperators.Add('=', typeof(ComparisonToken));
singleCharacterOperators.Add('&', typeof(AndToken));
singleCharacterOperators.Add('!', typeof(NotToken));
singleCharacterOperators.Add(';', typeof(SemicolonToken));
singleCharacterOperators.Add(':', typeof(ColonToken));
singleCharacterOperators.Add('(', typeof(LParenToken));
singleCharacterOperators.Add(')', typeof(RParenToken));
}
开发者ID:Valtis,项目名称:CompilerCourseProject,代码行数:25,代码来源:OperatorScanner.cs
示例8: RunCommand
public int RunCommand(TextReader input, TextWriter output, string tenant, string[] args, Dictionary<string, string> switches)
{
try {
tenant = tenant ?? "Default";
var env = FindOrCreateTenant(tenant);
var parameters = new CommandParameters {
Arguments = args,
Switches = switches,
Input = input,
Output = output
};
env.Resolve<ICommandManager>().Execute(parameters);
return 0;
}
catch (Exception e) {
for (int i = 0; e != null; e = e.InnerException, i++) {
if (i > 0) {
output.WriteLine("-------------------------------------------------------------------");
}
output.WriteLine("Error: {0}", e.Message);
output.WriteLine("{0}", e.StackTrace);
}
return 5;
}
}
开发者ID:mofashi2011,项目名称:orchardcms,代码行数:29,代码来源:CommandHostAgent.cs
示例9: TemplateParser
public TemplateParser (string filename, TextReader input)
{
this.filename = filename;
fileText = input.ReadToEnd ();
StringReader reader = new StringReader (fileText);
tokenizer = new TemplateTokenizer (reader);
}
开发者ID:apakian,项目名称:fluorinefx,代码行数:7,代码来源:TemplateParser.cs
示例10: Initialize
private void Initialize(TextReader input)
{
rand = new Random();
fortunes = new List<string>();
StringBuilder sb = new StringBuilder();
string line = input.ReadLine();
while (line != null)
{
if (line == "%")
{
if (sb.Length > 0)
{
fortunes.Add(sb.ToString());
sb.Clear();
}
}
else
{
if (sb.Length > 0)
{
sb.Append(' ');
}
sb.Append(line);
}
line = input.ReadLine();
}
if (sb.Length > 0)
{
fortunes.Add(sb.ToString());
}
}
开发者ID:Rejendo,项目名称:orleans,代码行数:32,代码来源:Fortune.cs
示例11: XsvReader
public XsvReader(TextReader reader, string commentString = null)
{
if (reader == null)
{ throw new ArgumentNullException("reader"); }
this.BaseReader = reader;
this.CommentString = commentString;
}
开发者ID:pierre3,项目名称:HandyUtilities.Xsv,代码行数:7,代码来源:XsvReader.cs
示例12: DoOpen
protected override void DoOpen (FileInfo info)
{
if (Extension == ".gz" || Extension == ".bz2" || Extension == ".lzma")
GetCompressedInfoReader ();
else
reader = base.TextReader;
}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:7,代码来源:FilterInfo.cs
示例13: Parse
public override Sector Parse(TextReader reader)
{
Sector sector = new Sector();
StringBuilder accum = new StringBuilder();
while (true)
{
string line = reader.ReadLine();
if (line == null)
break;
if (Regex.IsMatch(line, @"^\s*$"))
continue;
if (Regex.IsMatch(line, @"^\s*#"))
continue;
if (Char.IsWhiteSpace(line[0]))
{
accum.Append(" ");
accum.Append(Regex.Replace(line, @"^\s+", ""));
continue;
}
if (accum.Length > 0)
Apply(accum.ToString(), sector);
accum.Clear();
accum.Append(line);
}
if (accum.Length > 0)
{
Apply(accum.ToString(), sector);
}
return sector;
}
开发者ID:Matt--,项目名称:travellermap,代码行数:34,代码来源:MSECParser.cs
示例14: Parse
public Instruction[] Parse(TextReader reader)
{
Token token;
mReader = reader;
mScratchpad = new List<Instruction>();
mState = Idle;
while(mState != null && ReadNextToken(out token)) {
mState = mState(token);
if (mState == null) {
mReader = null;
mBuilder.Length = 0;
mScratchpad.Clear();
mBlock.Clear();
return null;
}
}
mReader = null;
var result = mScratchpad.ToArray();
mBuilder.Length = 0;
mScratchpad.Clear();
if (mBlock.Count > 0) {
mBlock.Clear();
return null;
}
return result;
}
开发者ID:maxattack,项目名称:ROBOLOGO,代码行数:26,代码来源:InstructionParser.cs
示例15: XmlConverter
public XmlConverter(TextReader rdr, XmlWriter writer, IPlatform platform)
{
this.rdr = rdr;
this.writer = writer;
this.platform = platform;
this.parserState = new ParserState();
}
开发者ID:uxmal,项目名称:reko,代码行数:7,代码来源:XmlConverter.cs
示例16: JavaScriptReader
bool raise_on_number_error; // FIXME: use it
public JavaScriptReader (TextReader reader, bool raiseOnNumberError)
{
if (reader == null)
throw new ArgumentNullException ("reader");
this.r = reader;
raise_on_number_error = raiseOnNumberError;
}
开发者ID:stabbylambda,项目名称:mono,代码行数:9,代码来源:JavaScriptReader.cs
示例17: Deserialize
/// <summary>
/// Deserialize an IfcXml file to an iso_10303_28 object
/// </summary>
/// <param name="reader"></param>
/// <exception cref="XmlException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <returns></returns>
public iso_10303 Deserialize(TextReader reader){
if(reader == null)
throw new ArgumentNullException("reader");
iso_10303 deserializedUos;
IfcXmlValidator validator;
try{
validator = new IfcXmlValidator( reader );
deserializedUos = (iso_10303)serializer.Deserialize( validator.Reader );
}catch(XmlException xe){
logger.Error( String.Format(CultureInfo.InvariantCulture, "Deserialize failed: {0}", xe.Message) );
throw;
}catch(InvalidOperationException ioe){
logger.Error(String.Format(CultureInfo.InvariantCulture, "Deserialize failed: {0}", ioe.Message));
throw;
}finally{
reader.Close();
}
if(!validator.IsValid){
StringBuilder warningBuilder = new StringBuilder();
foreach(String warning in validator.Messages){
warningBuilder.AppendLine( warning );
}
throw new XmlException(String.Format(CultureInfo.InvariantCulture, "Not valid IfcXml: {0}", warningBuilder.ToString()));
}
return deserializedUos;
}
开发者ID:chenxx08,项目名称:ifc-dotnet,代码行数:38,代码来源:IfcXmlSerializer.cs
示例18: TokenStream
public override TokenStream TokenStream(string fieldName, TextReader reader)
{
string str = reader.ReadToEnd();
StringBuilder builder = new StringBuilder(str);
builder.Replace('.', ' ');
builder.Replace('<', ' ');
builder.Replace('>', ' ');
builder.Replace('[', ' ');
builder.Replace(']', ' ');
builder.Replace('(', ' ');
builder.Replace(')', ' ');
builder.Replace(',', ' ');
builder.Replace(" ", " ");
str = builder.ToString();
for (int i = builder.Length - 1; i > 0; i--)
{
if (char.IsUpper(builder[i]))
builder.Insert(i, ' ');
}
builder.Append(' ').Append(str);
return new LowerCaseFilter(new WhitespaceTokenizer(new StringReader(builder.ToString())));
}
开发者ID:LBiNetherlands,项目名称:LBi.LostDoc,代码行数:27,代码来源:TitleAnalyzer.cs
示例19: CreateParser
public static WSABooParser CreateParser(int tabSize, string readerName, TextReader reader, Boo.Lang.Parser.ParserErrorHandler errorHandler)
{
var parser = new WSABooParser(CreateBooLexer(tabSize, readerName, reader));
parser.setFilename(readerName);
parser.Error += errorHandler;
return parser;
}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:7,代码来源:WSABooParser.cs
示例20: Deserialize
public override object Deserialize(TextReader tr)
{
if (tr != null)
{
string value = tr.ReadToEnd();
ICalendarObject co = SerializationContext.Peek() as ICalendarObject;
if (co != null)
{
EncodableDataType dt = new EncodableDataType();
dt.AssociatedObject = co;
value = Decode(dt, value);
}
value = TextUtil.Normalize(value, SerializationContext).ReadToEnd();
try
{
Uri uri = new Uri(value);
return uri;
}
catch
{
}
}
return null;
}
开发者ID:logikonline,项目名称:DDay.iCal,代码行数:27,代码来源:UriSerializer.cs
注:本文中的TextReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论