/// <summary> /// 读取当前代码块。 /// </summary> /// <param name="reader">字符串读取实例。</param> public override void Init(SourceReader reader) { reader.EscapeWhiteSpace(); var declarations = new List <string>(); string value = null; while (reader.CanRead) { switch (reader.Current) { case ')': reader.Offset(); //{}或者=>; Rules = reader.ReadRules(); if (reader.Current == ';') //接口方法,没有主体 { reader.Offset(); //移除; return; } // 代码块 if (reader.IsNext("=>")) { reader.Offset(2); Lambda = reader.ReadQuoteUntil(';').Trim(); reader.Offset(); //移除; return; } else if (reader.Current == ':') { //构造函数 reader.Offset(); reader.EscapeWhiteSpace(); BaseConstructor = reader.ReadQuoteUntil('{').Trim(); } break; case '{': //结束 Code = reader.ReadQuoteBlock('{', '}'); return; case ',': reader.Offset(); Parameters.Add(new ParameterElement(declarations, value, this)); declarations = new List <string>(); value = null; break; case '=': reader.Offset(); value = reader.ReadQuoteUntil(')', ','); break; default: declarations.Add(reader.ReadParameterDeclaration(')')); break; } reader.EscapeWhiteSpace(); } }
/// <summary> /// 读取当前代码块。 /// </summary> /// <param name="reader">字符串读取实例。</param> public override void Init(SourceReader reader) { reader.EscapeWhiteSpace(); var declarations = new List <string>(); string value = null; while (reader.CanRead) { switch (reader.Current) { case ']': reader.Offset(); //{}或者=>; Rule = reader.ReadUntil('{', '=').Trim(); reader.Offset(); //移除{或者= base.Init(reader); return; //结束 case ',': reader.Offset(); Parameters.Add(new ParameterElement(declarations, value, this)); declarations = new List <string>(); value = null; break; case '=': reader.Offset(); value = reader.ReadQuoteUntil(']', ','); break; default: declarations.Add(reader.ReadParameterDeclaration(']')); break; } reader.EscapeWhiteSpace(); } }