/// <summary> /// 获取数据 /// </summary> /// <param name="key">键值</param> /// <returns>数据对象</returns> private Node getNode(ref keyType key) { Node node; if (dictionary.TryGetValue(ref key, out node)) { if (node != end) { Node previous = node.Previous; if (previous == null) { (header = node.Next).Previous = null; } else { (previous.Next = node.Next).Previous = previous; } end.Next = node; node.Previous = end; node.Next = null; end = node; } } return(node); }
/// <summary> /// 进入对象节点 /// </summary> /// <typeparam name="valueType">对象类型</typeparam> /// <param name="value">数据对象</param> /// <returns>是否继续处理对象</returns> private bool pushArray <valueType>(valueType value) { if (checkLoopDepth == 0) { if (forefatherCount != 0) { int count = forefatherCount; object objectValue = value; foreach (object arrayValue in forefather) { if (arrayValue == objectValue) { CharStream.WriteJsonObject(); return(false); } if (--count == 0) { break; } } } if (forefatherCount == forefather.Length) { forefather = forefather.copyNew(forefatherCount << 1); } forefather[forefatherCount++] = value; } else { if (--checkLoopDepth == 0) { throw new OverflowException(); } #if AutoCSer if (isLoopObject) { int index; if (objectIndexs.TryGetValue(new ObjectReference { Value = value }, out index)) { CharStream.PrepCharSize(Config.GetLoopObject.Length + (10 + 5 + 3)); CharStream.Data.SimpleWrite(Config.GetLoopObject); CharStream.Data.Write('('); CharStream.WriteJsonHex((uint)index); CharStream.Data.Write(',' + ('[' << 16) + ((long)']' << 32) + ((long)')' << 48)); return(false); } objectIndexs.Set(new ObjectReference { Value = value }, index = objectIndexs.Count); CharStream.PrepCharSize(Config.SetLoopObject.Length + (10 + 2 + 2)); CharStream.Data.SimpleWrite(Config.SetLoopObject); CharStream.Data.Write('('); CharStream.WriteJsonHex((uint)index); CharStream.Data.Write(','); } #endif } return(true); }