public static TreeNode CreateNode(DataItem item) { if (item is Scalar) { return CreateNodeForScalar(item as Scalar); } else if (item is Sequence) { return CreateNodeForSequence(item as Sequence); } else if (item is Mapping) { return CreateNodeForMapping(item as Mapping); } else { return null; } }
private DataItem ParseDataItem(out bool success) { int errorCount = Errors.Count; DataItem dataItem = new DataItem(); int start_position = position; while (true) { int seq_start_position1 = position; dataItem.Property = ParseNodeProperty(out success); if (!success) { Error("Failed to parse Property of DataItem."); break; } ParseSeparationLines(out success); if (!success) { Error("Failed to parse SeparationLines of DataItem."); position = seq_start_position1; } break; } success = true; ErrorStatck.Push(errorCount); errorCount = Errors.Count; while (true) { dataItem = ParseScalar(out success); if (success) { ClearError(errorCount); break; } dataItem = ParseSequence(out success); if (success) { ClearError(errorCount); break; } dataItem = ParseMapping(out success); if (success) { ClearError(errorCount); break; } break; } errorCount = ErrorStatck.Pop(); if (!success) { Error("Failed to parse (Scalar / Sequence / Mapping) of DataItem."); position = start_position; } if (success) { ClearError(errorCount); } return dataItem; }
private DataItem ParseEmptyFlow(out bool success) { int errorCount = Errors.Count; DataItem dataItem = new DataItem(); success = true; if (success) { return new Scalar(); } return dataItem; }
void SetDataItemProperty(DataItem dataItem, NodeProperty property) { if (property.Anchor != null) { currentDocument.AnchoredItems[property.Anchor] = dataItem; } dataItem.Property = property; }