Beispiel #1
0
 internal static void SerializeObject(Object obj, WriteOnlyDatagram datagram, SerializerState state)
 {
     if (obj == null)
     {
         datagram.WriteUInt((uint)SerializedTypeCode.Null, 8);
     }
     else if (obj is String)
     {
         datagram.WriteUInt((uint)SerializedTypeCode.String, 8);
         datagram.WriteString(obj as String);
     }
     else if (obj is MISP.ScriptList)
     {
         datagram.WriteUInt((uint)SerializedTypeCode.List, 8);
         var filteredList = new MISP.ScriptList(
             (obj as MISP.ScriptList).Where((o) => IsSerializableType(o)));
         datagram.WriteUInt((uint)filteredList.Count, 16);
         foreach (var item in filteredList)
             SerializeObject(item, datagram, state);
     }
     else if (obj is int)
     {
         datagram.WriteUInt((uint)SerializedTypeCode.Integer, 8);
         datagram.WriteUInt((uint)(obj as int?).Value, 32);
     }
     else if (obj is MISP.GenericScriptObject)
     {
         state.WriteObject(obj as MISP.GenericScriptObject, datagram);
     }
 }