Skip to main content

Write Object

Mapping object in string

To configure an object, you should use ObjectMapper and WriteProperty properties to map string layout.

[ObjectMapper(length: 50)]
public struct Nothing
public Nothing(string name, string webSite)
this.Name = name;
this.WebSite = webSite;

[WriteProperty(length: 20, order: 1, paddingChar: ' ')]
public string Name { get; private set; }

[WriteProperty(length: 30, order: 2, paddingChar: ' ')]
public string WebSite { get; private set; }

The sum length of all mapped property should not be more than ObjectMapper length.


To map you object as string, you need instantiate Spinner passing the object type in T and an instance of the object in the constructor.

  Nothing nothing = new Nothing("spinner", "");
Spinner<Nothing> spinner = new Spinner<Nothing>(nothing);

Write an Object

After configured the object, you can call the WriteAsString method to write the object in a string format.

  string stringResponse = spinner.WriteAsString();