public IEnumerable <string> EmitCode() { foreach (var l in ClassSummary.EmitSummary(0)) { yield return(l); } yield return(ClassDeclaration); yield return("{"); yield return(string.Empty); foreach (var l in _Fields.Indent(1)) { yield return(l); } yield return(string.Empty); yield return("/// <inheritdoc />".Indent(1)); yield return("protected override void SerializeProperties(JsonWriter writer)".Indent(1)); yield return("{".Indent(1)); if (HasBaseClass) { yield return("base.SerializeProperties(writer);".Indent(2)); } foreach (var l in _SerializerBody.Indent(2)) { yield return(l); } yield return("}".Indent(1)); yield return(string.Empty); yield return("/// <inheritdoc />".Indent(1)); yield return("protected override void DeserializeProperty(string jsonPropertyName, JsonReader reader)".Indent(1)); yield return("{".Indent(1)); yield return("switch (jsonPropertyName)".Indent(2)); yield return("{".Indent(2)); foreach (var l in _DeserializerSwitchBody.Indent(3)) { yield return(l); } if (HasBaseClass) { yield return("default: base.DeserializeProperty(jsonPropertyName, reader); break;".Indent(3)); } else { yield return("default: throw new NotImplementedException();".Indent(3)); } yield return("}".Indent(2)); yield return("}".Indent(1)); yield return(string.Empty); yield return("}"); }
public IEnumerable <string> EmitCode() { #if USENEWTONSOFT var readerType = "JsonReader"; var writerType = "JsonWriter"; #else var readerType = "ref Utf8JsonReader"; var writerType = "Utf8JsonWriter"; #endif foreach (var l in ClassSummary.EmitSummary(0)) { yield return(l); } yield return(ClassDeclaration); yield return("{"); yield return(string.Empty); foreach (var l in _Fields.Indent(1)) { yield return(l); } yield return(string.Empty); // yield return "/// <inheritdoc />".Indent(1); yield return($"protected override void SerializeProperties({writerType} writer)".Indent(1)); yield return("{".Indent(1)); if (HasBaseClass) { yield return("base.SerializeProperties(writer);".Indent(2)); } foreach (var l in _SerializerBody.Indent(2)) { yield return(l); } yield return("}".Indent(1)); yield return(string.Empty); // yield return "/// <inheritdoc />".Indent(1); yield return($"protected override void DeserializeProperty(string jsonPropertyName, {readerType} reader)".Indent(1)); yield return("{".Indent(1)); yield return("switch (jsonPropertyName)".Indent(2)); yield return("{".Indent(2)); foreach (var l in _DeserializerSwitchBody.Indent(3)) { yield return(l); } if (HasBaseClass) { yield return($"default: base.DeserializeProperty(jsonPropertyName,{_READERMODIFIER}reader); break;".Indent(3)); } else { yield return("default: throw new NotImplementedException();".Indent(3)); } yield return("}".Indent(2)); yield return("}".Indent(1)); yield return(string.Empty); yield return("}"); }