internal override IEnumerable <YamlNode> SafeAllNodes(RecursionLevel level) { level.Increment(); yield return((YamlNode)this); /*Error: Unable to find new state assignment for yield return*/; }
/// <summary> /// Returns a <see cref="string"/> that represents this instance. /// </summary> /// <returns> /// A <see cref="string"/> that represents this instance. /// </returns> internal override string ToString(RecursionLevel level) { if (!level.TryIncrement()) { return(MaximumRecursionLevelReachedToStringValue); } using var textBuilder = StringBuilderPool.Rent(); var text = textBuilder.Builder; text.Append("[ "); foreach (var child in children) { if (text.Length > 2) { text.Append(", "); } text.Append(child.ToString(level)); } text.Append(" ]"); level.Decrement(); return(text.ToString()); }
/// <summary> /// Saves the options to the specified writer. /// </summary> public void Save(Stream stream) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } StringBuilder sb = new StringBuilder() .AppendLine("[TeleCommand]") .Append("CommandID=").AppendLine(CommandID.ToString()) .Append("CreationTime=").AppendLine(CreationTime.ToString(DateTimeFormatInfo.InvariantInfo)) .Append("ClientName=").AppendLine(ClientName) .Append("UserID=").AppendLine(UserID.ToString()) .Append("CnlNum=").AppendLine(CnlNum.ToString()) .Append("ObjNum=").AppendLine(ObjNum.ToString()) .Append("DeviceNum=").AppendLine(DeviceNum.ToString()) .Append("CmdNum=").AppendLine(CmdNum.ToString()) .Append("CmdCode=").AppendLine(CmdCode) .Append("CmdVal=").AppendLine(CmdVal.ToString(NumberFormatInfo.InvariantInfo)) .Append("CmdData=").AppendLine(ScadaUtils.BytesToHex(CmdData)) .Append("RecursionLevel=").AppendLine(RecursionLevel.ToString()) .AppendLine("End="); using (StreamWriter writer = new StreamWriter(stream, Encoding.UTF8, 1024, true)) { writer.Write(sb.ToString()); } }
internal override string ToJson(RecursionLevel level) { if ("null".Equals(Value)) { return(Value); } return("\"" + Value + "\""); }
/// <summary> /// Recursively enumerates all the nodes from the document, starting on the current node, /// and throwing <see cref="MaximumRecursionLevelReachedException"/> /// if <see cref="RecursionLevel.Maximum"/> is reached. /// </summary> internal override IEnumerable <YamlNode> SafeAllNodes(RecursionLevel level) { level.Increment(); yield return(this); foreach (var child in children) { foreach (var node in child.SafeAllNodes(level)) { yield return(node); } } level.Decrement(); }
internal override string ToString(RecursionLevel level) { if (!level.TryIncrement()) { return("WARNING! INFINITE RECURSION!"); } StringBuilder stringBuilder = new StringBuilder("[ "); foreach (YamlNode child in children) { if (stringBuilder.Length > 2) { stringBuilder.Append(", "); } stringBuilder.Append(child.ToString(level)); } stringBuilder.Append(" ]"); level.Decrement(); return(stringBuilder.ToString()); }
/// <summary> /// Returns a <see cref="System.String"/> that represents this instance. /// </summary> /// <returns> /// A <see cref="System.String"/> that represents this instance. /// </returns> internal override string ToString(RecursionLevel level) { if (!level.TryIncrement()) { return(MaximumRecursionLevelReachedToStringValue); } var text = new StringBuilder("{ "); foreach (var child in children) { if (text.Length > 2) { text.Append(", "); } text.Append("{ ").Append(child.Key.ToString(level)).Append(", ").Append(child.Value.ToString(level)).Append(" }"); } text.Append(" }"); level.Decrement(); return(text.ToString()); }
/// <summary> /// When implemented, recursively enumerates all the nodes from the document, starting on the current node. /// If <see cref="RecursionLevel.Maximum"/> is reached, a <see cref="MaximumRecursionLevelReachedException"/> is thrown /// instead of continuing and crashing with a <see cref="StackOverflowException"/>. /// </summary> internal abstract IEnumerable <YamlNode> SafeAllNodes(RecursionLevel level);
internal abstract string ToString(RecursionLevel level);
public override string ToString() { var level = new RecursionLevel(MaximumRecursionLevel); return(ToString(level)); }
/// <summary> /// Returns a <see cref="System.String"/> that represents this instance. /// </summary> /// <returns> /// A <see cref="System.String"/> that represents this instance. /// </returns> internal override string ToString(RecursionLevel level) { return("*" + Anchor); }
/// <summary> /// Recursively enumerates all the nodes from the document, starting on the current node, /// and throwing <see cref="MaximumRecursionLevelReachedException"/> /// if <see cref="RecursionLevel.Maximum"/> is reached. /// </summary> internal override IEnumerable <YamlNode> SafeAllNodes(RecursionLevel level) { yield return(this); }
/// <summary> /// Returns a <see cref="string"/> that represents this instance. /// </summary> /// <returns> /// A <see cref="string"/> that represents this instance. /// </returns> internal override string ToString(RecursionLevel level) { return(Value ?? string.Empty); }
public override string ToString() { RecursionLevel level = new RecursionLevel(1000); return(ToString(level)); }
internal abstract string ToJson(RecursionLevel level);
public string ToJson() { var level = new RecursionLevel(MaximumRecursionLevel); return(ToJson(level)); }