/// <summary> /// /// </summary> /// <param name="line"></param> /// <returns>Continuable.</returns> public Boolean Process(String line) { if (String.IsNullOrWhiteSpace(this.ClassName)) { throw new InvalidOperationException("ClassName must be set."); } using (var reader = new LineReader(line)) { var instruction = reader.ReadWord(); switch (instruction) { case "@end": return false; case "@using": var @using = reader.ReadToEnd(); if (String.IsNullOrEmpty(@using)) { throw new FormatException("@using not allow empty definition."); } if (@using.StartsWith(".")) { this._shortUsings.Add(@using.Remove(0, 1)); } else { this._fullUsings.Add(@using); } break; case "@ns": case "@namespace": if (this._namespace != null) { throw new FormatException("Duplicated @namespace."); } var ns = reader.ReadToEnd(); if (String.IsNullOrEmpty(ns)) { throw new FormatException("@namespace not allow empty definition."); } this._namespace = ns; break; case "@base": if (this._base != null) { throw new FormatException("Duplicated @base."); } var @base = reader.ReadToEnd(); if (String.IsNullOrEmpty(@base)) { throw new FormatException("@base not allow empty definition."); } this._base = @base.Replace("$class", this.ClassName); break; case "@impl": case "@implement": var impl = reader.ReadToEnd(); if (String.IsNullOrEmpty(impl)) { throw new FormatException("@using not allow empty definition."); } this._implements.Add(impl.Replace("$class", this.ClassName)); break; case "@defaultAccess": var defPropAccess = reader.ReadToEnd(); this._propertyDefaultSettings.PropertyAccess = defPropAccess; break; case "@defaultType": var defPropType = reader.ReadToEnd(); this._propertyDefaultSettings.PropertyType = defPropType; break; default: // Ignore unknown instruction. break; } return true; } }
public PropertyReader(String line) { this.reader = new LineReader(line, Delimiters); }