static void WriteSnippets() { //string structSig = "(bs)"; Udbus.Types.dbus_type[] terminator = new Udbus.Types.dbus_type[] { Udbus.Types.dbus_type.DBUS_INVALID }; Udbus.Types.dbus_type[] structSig = new Udbus.Types.dbus_type[] { Udbus.Types.dbus_type.DBUS_STRUCT_BEGIN, Udbus.Types.dbus_type.DBUS_BOOLEAN, Udbus.Types.dbus_type.DBUS_STRING, Udbus.Types.dbus_type.DBUS_STRUCT_END }; Udbus.Types.dbus_type[] structTypes = structSig.Concat(terminator).ToArray(); //object[] astruct = new object[] { dbus_union.CreateStruct(new object[] { true, "One" }, structTypes), // dbus_union.CreateStruct(new object[] { false, "Two" }, structTypes) //}; object[] astruct = new object[] { new object[] { true, "One" }, new object[] { false, "Two" } }; object[] adict = new object[] { new object[] { 1, new object[] { true, "One" } }, new object[] { 2, new object[] { false, "Two" } } }; Udbus.Types.dbus_type[] dictTypes = new Udbus.Types.dbus_type[] { Udbus.Types.dbus_type.DBUS_ARRAY, Udbus.Types.dbus_type.DBUS_DICT_BEGIN, Udbus.Types.dbus_type.DBUS_INT32 } .Concat(structSig) .Concat(new Udbus.Types.dbus_type[] { Udbus.Types.dbus_type.DBUS_DICT_END }) .Concat(terminator) .ToArray(); dbus_union s = dbus_union.CreateStruct(astruct, structTypes); dbus_union d = dbus_union.Create(adict, dictTypes); //UdbusMessageBuilder builder = new UdbusMessageBuilder(); //MarshalWriteObjectDelegate del = UdbusMessageBuilder.BodyAdd_String; }
static void ManuallyBuildType() { // Array of dictionary of int => array of structs(array of strings, double) // "aa{ia(asd)}" dbus_union root = dbus_union.Create( new Dictionary <object, object> { { 1, // Key new object[] { // Value (array of structs) new object[] { new string[] { "a1" }, 1.1 }, // Ends struct 1 fields new object[] { new string[] { "a1a" }, 1.2 } // Ends struct 2 fields } // Ends array of structs (value) }, // Ends dictionary entry 1 { 2, // Key new object[] { // Value (array of structs) new object[] { new string[] { "a2" }, 2.1 }, // Ends struct 1 fields new object[] { new string[] { "a2a" }, 2.2 } // Ends struct 2 fields } // Ends array of structs (value) } // Ends dictionary entry 1 }, new Udbus.Types.dbus_type[] { Udbus.Types.dbus_type.DBUS_INT32, Udbus.Types.dbus_type.DBUS_ARRAY, Udbus.Types.dbus_type.DBUS_STRUCT_BEGIN, Udbus.Types.dbus_type.DBUS_ARRAY, Udbus.Types.dbus_type.DBUS_STRING, Udbus.Types.dbus_type.DBUS_DOUBLE, Udbus.Types.dbus_type.DBUS_STRUCT_END } ); #if MANUALLABOUR1 || MANUALLABOUR2 dbus_union root = new dbus_union { #if MANUALLABOUR1 //Type = Udbus.Types.dbus_type.DBUS_ARRAY, DbusObjectArray = new dbus_union[] { new dbus_union // root.DbusArray[0] { //Type = Udbus.Types.dbus_type.DBUS_DICT_BEGIN, DbusDictionary = new Dictionary <object, object> { // root.DbusArray[0] Dictionary { // root.DbusArray[0].DbusDictionary Entry 1 new dbus_union { /*Type = Udbus.Types.dbus_type.DBUS_INT32, */ DbusInt32 = 1 }, // root.DbusArray[0].Key new dbus_union // root.DbusArray[0].Value { //Type = Udbus.Types.dbus_type.DBUS_ARRAY, // root.DbusArray[0].Value Array DbusObjectArray = new dbus_union[] { new dbus_union { //Type = Udbus.Types.dbus_type.DBUS_STRUCT_BEGIN, // root.DbusArray[0].Value Array[0].Struct DbusObjectStruct = new dbus_union[] // root.DbusArray[0].Value Array[0].Struct.Fields { new dbus_union // root.DbusArray[0].Value Array[0].Struct[0] { //Type = Udbus.Types.dbus_type.DBUS_ARRAY, DbusObjectArray = new dbus_union[] // root.DbusArray[0].Value Array[0].Struct[0].Array { new dbus_union { /*Type = Udbus.Types.dbus_type.DBUS_STRING, */ DbusString = "One" }, new dbus_union { /*Type = Udbus.Types.dbus_type.DBUS_STRING, */ DbusString = "Two" } } // root.DbusArray[0].Value Array[0].Struct[0].Array }, // Ends root.DbusArray[0].Value Array[0].Struct[0] new dbus_union // root.DbusArray[0].Value Array[0].Struct[1] { //Type = Udbus.Types.dbus_type.DBUS_DOUBLE, DbusDouble = 1.2 } // Ends root.DbusArray[0].Value Array[0].Struct[1] } // Ends root.DbusArray[0].Value Array[0].Struct.Fields } // Ends root.DbusArray[0].Value Array[0].Struct } // // root.DbusArray[0].Value Array } // root.DbusArray[0].Value } // Ends root.DbusArray[0].DbusDictionary Entry 1 } // Ends root.DbusArray[0] Dictionary } // Ends root.DbusArray[0] } // Ends DbusArray #elif MANUALLABOUR2 //Type = Udbus.Types.dbus_type.DBUS_ARRAY, DbusArray = new dbus_union[] { new dbus_union // root.DbusArray[0] { //Type = Udbus.Types.dbus_type.DBUS_DICT_BEGIN, DbusDictionary = new Dictionary <dbus_primitive, dbus_union> { // root.DbusArray[0] Dictionary { // root.DbusArray[0].DbusDictionary Entry 1 new dbus_union { /*Type = Udbus.Types.dbus_type.DBUS_INT32, */ DbusInt32 = 1 }, // root.DbusArray[0].Key new dbus_union // root.DbusArray[0].Value { //Type = Udbus.Types.dbus_type.DBUS_ARRAY, // root.DbusArray[0].Value Array DbusArray = new dbus_union[] { new dbus_union { //Type = Udbus.Types.dbus_type.DBUS_STRUCT_BEGIN, // root.DbusArray[0].Value Array[0].Struct DbusStruct = new dbus_union[] // root.DbusArray[0].Value Array[0].Struct.Fields { new dbus_union // root.DbusArray[0].Value Array[0].Struct[0] { //Type = Udbus.Types.dbus_type.DBUS_ARRAY, DbusArray = new dbus_union[] // root.DbusArray[0].Value Array[0].Struct[0].Array { new dbus_union { /*Type = Udbus.Types.dbus_type.DBUS_STRING, */ DbusString = "One" }, new dbus_union { /*Type = Udbus.Types.dbus_type.DBUS_STRING, */ DbusString = "Two" } } // root.DbusArray[0].Value Array[0].Struct[0].Array }, // Ends root.DbusArray[0].Value Array[0].Struct[0] new dbus_union // root.DbusArray[0].Value Array[0].Struct[1] { //Type = Udbus.Types.dbus_type.DBUS_DOUBLE, DbusDouble = 1.2 } // Ends root.DbusArray[0].Value Array[0].Struct[1] } // Ends root.DbusArray[0].Value Array[0].Struct.Fields } // Ends root.DbusArray[0].Value Array[0].Struct } // // root.DbusArray[0].Value Array } // root.DbusArray[0].Value } // Ends root.DbusArray[0].DbusDictionary Entry 1 } // Ends root.DbusArray[0] Dictionary } // Ends root.DbusArray[0] } // Ends DbusArray #endif // MANUALLABOUR2 }; // Ends root #endif // MANUALLABOUR1 || MANUALLABOUR2 } } // Ends class Example