// Complexity is an abstract measure that corresponds to general // fuzziness of a message: attributes per element, children per // element, depth of child-element nesting, etc.. public GeneratedSerializableObject(int complexity, long size) { Size = ((size > 0) ? size : 0); Complexity = ((complexity > 0) ? complexity : 1); GeneratedSerializableObject pointer = this; long dataSizeLong = size / complexity; int dataSize = ((dataSizeLong > int.MaxValue) ? int.MaxValue : ((int)dataSizeLong)); a = (complexity < 2) ? null : new GeneratedSerializableObject(complexity - 1, dataSize * (complexity - 1)); b = MessageTestUtilities.GenerateData(dataSize); }
protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion version) { for (int i = 0; i < complexity; i++) { writer.WriteStartElement(("nestedSubtag" + i)); } for (int i = 0; i < complexity; i++) { writer.WriteEndElement(); } for (int i = 0; i < complexity; i++) { writer.WriteElementString(("nonNestedSubtag" + i), MessageTestUtilities.GenerateData(complexity)); } }
protected override void OnWriteBodyContents(XmlDictionaryWriter writer) { if (IsDisposed) { throw new ObjectDisposedException("", "MessageClosed."); } if (writer == null) { throw new ArgumentNullException(nameof(writer)); } for (int i = 0; i < complexity; i++) { writer.WriteStartElement(("nestedSubtag" + i)); if (addComments) { writer.WriteComment("Some after-open-tag comment" + i); } } for (int i = 0; i < complexity; i++) { writer.WriteEndElement(); if (addComments) { writer.WriteComment("Some after-end-tag comment" + i); } } long dataSizeLong = size / complexity; int dataSize = ((dataSizeLong > int.MaxValue) ? int.MaxValue : ((int)dataSizeLong)); for (int i = 0; i < complexity; i++) { writer.WriteElementString(("nonNestedSubtag" + i), MessageTestUtilities.GenerateData(dataSize)); } if (addComments) { writer.WriteComment("Some comment"); } }
public void WriteBody(XmlWriter writer) { if (writer == null) { throw new ArgumentNullException(nameof(writer)); } for (int i = 0; i < complexity; i++) { writer.WriteStartElement(("nestedSubtag" + i)); if (addComments) { writer.WriteComment("Some after-open-tag comment" + i); } } for (int i = 0; i < complexity; i++) { writer.WriteEndElement(); if (addComments) { writer.WriteComment("Some after-end-tag comment" + i); } } long dataSizeLong = size / complexity; int dataSize = ((dataSizeLong > int.MaxValue) ? int.MaxValue : ((int)dataSizeLong)); for (int i = 0; i < complexity; i++) { writer.WriteElementString(("nonNestedSubtag" + i), MessageTestUtilities.GenerateData(dataSize)); } if (addComments) { writer.WriteComment("Some comment"); } }