internal override void Record <T>(ref T value, string label, Parameters parameters) { if (asThis) { Dbg.Err($"Attempting to write a second field after a RecordAsThis call"); return; } if (parameters.asThis) { if (fields.Count > 0) { Dbg.Err($"Attempting to make a RecordAsThis call after writing a field"); return; } asThis = true; Serialization.ComposeElement(node, value, typeof(T)); return; } if (fields.Contains(label)) { Dbg.Err($"Field '{label}' written multiple times"); return; } fields.Add(label); Serialization.ComposeElement(node.CreateChild(label), value, typeof(T)); }
/// <summary> /// Returns C# validation code starting at an option. /// </summary> public static string WriteValidation <T>(T target) { var writerContext = new WriterValidationRecord(); Serialization.ComposeElement(writerContext.StartData(), target, target != null ? target.GetType() : typeof(T)); return(writerContext.Finish()); }
/// <summary> /// Returns a fully-formed XML document starting at an object. /// </summary> public static string Write <T>(T target, bool pretty = true) { var writerContext = new WriterXmlRecord(); Serialization.ComposeElement(writerContext.StartData(), target, target != null ? target.GetType() : typeof(T)); return(writerContext.Finish(pretty)); }
public void ComposeNull() { var writerContext = new WriterNull(true); foreach (var decObj in Database.List) { Serialization.ComposeElement(WriterNodeNull.Start(writerContext), decObj, decObj.GetType(), isRootDec: true); } }
public string ComposeValidation() { var writerContext = new WriterValidationCompose(); foreach (var decObj in Database.List) { Serialization.ComposeElement(writerContext.StartDec(decObj.GetType(), decObj.DecName), decObj, decObj.GetType(), isRootDec: true); } return(writerContext.Finish()); }
public string ComposeXml(bool pretty) { var writerContext = new WriterXmlCompose(); foreach (var decObj in Database.List) { Serialization.ComposeElement(writerContext.StartDec(decObj.GetType(), decObj.DecName), decObj, decObj.GetType(), new Recorder.Context(), isRootDec: true); } return(writerContext.Finish(pretty)); }
/// <summary> /// Runs the Null writer, which is mostly useful for performance testing. /// </summary> public static void WriteNull <T>(T target) { var writerContext = new WriterNull(false); Serialization.ComposeElement(WriterNodeNull.Start(writerContext), target, target != null ? target.GetType() : typeof(T)); }