/// <summary> /// 一直读到某个字符出现或者字符串结束,返回已读取的字符 /// </summary> /// <param name="fixChar"></param> /// <returns></returns> public string ReadToChar(Char fixChar) { if (IsEnd() || Current == fixChar)//已到结尾 { return(string.Empty); } _Buff.Clear(); do { //判断当前字符是否等于转义符 if (Current == '\\') { //读取下一个字符 if (MoveNext()) { if (EscapeFlag_Switch[Current]) { _Buff.Append('\\'); } } else {//读取失败 return(_Buff.ToString()); } } _Buff.Append(Current); //将当前字符推入缓冲区 } while (MoveNext() && Current != fixChar); //读取下一个字符 return(_Buff.ToString()); }
//泛对象 protected void AppendObject(object obj) { if (obj == null) { Buff.Append("null"); } else if (obj is String) { AppendString((String)obj); } else if (obj is Int32) { AppendInt32((Int32)obj); } else if (obj is Boolean) { AppendBoolean((Boolean)obj); } else if (obj is DateTime) { AppendDateTime((DateTime)obj); } else if (obj is Double) { AppendDouble((Double)obj); } else if (obj is Enum) { AppendEnum((Enum)obj); } else if (obj is Decimal) { AppendDecimal((Decimal)obj); } else if (obj is Char) { AppendChar((Char)obj); } else if (obj is Single) { AppendSingle((Single)obj); } else if (obj is Guid) { AppendGuid((Guid)obj); } else if (obj is Byte) { AppendByte((Byte)obj); } else if (obj is Int16) { AppendInt16((Int16)obj); } else if (obj is Int64) { AppendInt64((Int64)obj); } else if (obj is SByte) { AppendSByte((SByte)obj); } else if (obj is UInt32) { AppendUInt32((UInt32)obj); } else if (obj is UInt64) { AppendUInt64((UInt64)obj); } else if (_LoopObject.ContainsKey(obj) == false) { _LoopObject.Add(obj, null); if (obj is IDictionary) { AppendJson((IDictionary)obj); } else if (obj is IEnumerable) { AppendArray((IEnumerable)obj); } else if (obj is DataSet) { AppendDataSet((DataSet)obj); } else if (obj is DataTable) { AppendDataTable((DataTable)obj); } else if (obj is DataView) { AppendDataView((DataView)obj); } else { AppendOther(obj); } _LoopObject.Remove(obj); } else { Buff.Append("undefined"); } }