Exemplo n.º 1
0
        static void WriteSnippets()
        {
            //string structSig = "(bs)";
            dbus_type[] terminator  = new dbus_type[] { dbus_type.DBUS_INVALID };
            dbus_type[] structSig   = new dbus_type[] { dbus_type.DBUS_STRUCT_BEGIN, dbus_type.DBUS_BOOLEAN, dbus_type.DBUS_STRING, dbus_type.DBUS_STRUCT_END };
            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" } }
            };
            dbus_type[] dictTypes = new dbus_type[] { dbus_type.DBUS_ARRAY, dbus_type.DBUS_DICT_BEGIN, dbus_type.DBUS_INT32 }
            .Concat(structSig)
            .Concat(new dbus_type[] { 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;
        }
Exemplo n.º 2
0
        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 dbus_type[] {
                dbus_type.DBUS_INT32, dbus_type.DBUS_ARRAY, dbus_type.DBUS_STRUCT_BEGIN,
                dbus_type.DBUS_ARRAY, dbus_type.DBUS_STRING, dbus_type.DBUS_DOUBLE,
                dbus_type.DBUS_STRUCT_END
            }
                );

#if MANUALLABOUR1 || MANUALLABOUR2
            dbus_union root = new dbus_union
            {
#if MANUALLABOUR1
                //Type = dbus_type.DBUS_ARRAY,
                DbusObjectArray = new dbus_union[]
                {
                    new dbus_union // root.DbusArray[0]
                    {
                        //Type = dbus_type.DBUS_DICT_BEGIN,
                        DbusDictionary = new Dictionary <object, object>
                        {                        // root.DbusArray[0] Dictionary
                            {                    // root.DbusArray[0].DbusDictionary Entry 1
                                new dbus_union { /*Type = dbus_type.DBUS_INT32, */
                                    DbusInt32 = 1
                                },               // root.DbusArray[0].Key
                                new dbus_union   // root.DbusArray[0].Value
                                {                //Type = dbus_type.DBUS_ARRAY, // root.DbusArray[0].Value Array
                                    DbusObjectArray = new dbus_union[]
                                    {
                                        new dbus_union
                                        {                                       //Type = 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 = dbus_type.DBUS_ARRAY,
                                                    DbusObjectArray = new dbus_union[] // root.DbusArray[0].Value Array[0].Struct[0].Array
                                                    {
                                                        new dbus_union {               /*Type = dbus_type.DBUS_STRING, */
                                                            DbusString = "One"
                                                        },
                                                        new dbus_union { /*Type = 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 = 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 = dbus_type.DBUS_ARRAY,
                DbusArray = new dbus_union[]
                {
                    new dbus_union // root.DbusArray[0]
                    {
                        //Type = 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 = dbus_type.DBUS_INT32, */
                                    DbusInt32 = 1
                                },               // root.DbusArray[0].Key
                                new dbus_union   // root.DbusArray[0].Value
                                {                //Type = dbus_type.DBUS_ARRAY, // root.DbusArray[0].Value Array
                                    DbusArray = new dbus_union[]
                                    {
                                        new dbus_union
                                        {                                 //Type = 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 = dbus_type.DBUS_ARRAY,
                                                    DbusArray = new dbus_union[] // root.DbusArray[0].Value Array[0].Struct[0].Array
                                                    {
                                                        new dbus_union {         /*Type = dbus_type.DBUS_STRING, */
                                                            DbusString = "One"
                                                        },
                                                        new dbus_union { /*Type = 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 = 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