Mother DocsMother Docs
Buy me a Coffee
Steam Workshop
Discord
  • Mother OS (Ingame Script)
Buy me a Coffee
Steam Workshop
Discord
  • Mother OS (Ingame Script)
  • Mother OS (Ingame Script)
    • Getting Started

      • Upgrade Guide
      • Installation
      • Command Line Interface (CLI)
      • Configuration
      • Modules
    • Core Modules

      • Activity Monitor
      • Almanac
      • Block Catalogue
      • Local Storage
      • Intergrid Message Service
    • Extension Modules

      • Air Vent Module
      • Battery Module
      • Terminal Block Module
      • Cockpit Module
      • Connector Module
      • Display Module
      • Docking Module
      • Door Module
      • Flight Control Module
      • Flight Planning Module
      • Gas Tank Module
      • Gyroscope Module
      • Hinge Module
      • Landing Gear Module
      • Light Module
      • Map Module
      • Piston Module
      • Programmable Block Module
      • Rotor Module
      • Screen Module
      • Sensor Module
      • Sorter Module
      • Sound Block Module
      • Thruster Module
      • Timer Block Module
    • Command Cheatsheet
    • Compatibility
    • Examples
  • Mother Core (Script Framework)
    • Getting Started

      • Upgrade Guide
      • Installation
      • Architecture Overview
      • Managing Script Size & Complexity
    • Building A Module
    • Console (CLI)
    • Core Modules
      • Activity Monitor
      • Almanac
      • Block Catalogue
      • Clock
      • Command Bus
      • Configuration
      • Event Bus
      • Intergrid Message Service
      • Local Storage
      • Terminal
    • Utilities

      • Color Helper
      • Security
      • Serializer
  • Powered By Mother

Serializer

On several occasions, it is most practical to convert our objects into strings. This is necessary when commiting data to Local Storage or when communicating with another grid via the Intergrid Message Service.

The Serializer utility class provides a set of static methods to serialize and deserialize objects.

  • Serialize an Object

Serialize an Object

When sending a message to another grid, we need to convert our message into a string. This is done by calling the Serializer.SerializeDictionary() method to serialize or message header and body.

IntergridMessagingObject.cs

public virtual string Serialize()
{
    // Create a dictionary to store the message
    Dictionary<string, object> body;
    Dictionary<string, object> header;

    string headerSerialized = Serializer.SerializeDictionary(header);
    string bodySerialized = Serializer.SerializeDictionary(body);

    // Serialize the dictionary
    return  $"<header>{headerSerialized}</header>" +
            $"<body>{bodySerialized}</body>";
}

See the Intergrid Message Service for more information on how to send messages to other grids.

Last Updated: 8/8/25, 10:08 PM
Contributors: Luke Morrison, lukejamesmorrison
Prev
Security