Esempio n. 1
0
        public int HelloSend(uint serial, out string name, HelloRecvDelegate helloRecv)
        {
            Udbus.Serialization.UdbusMessageBuilder builder = new Udbus.Serialization.UdbusMessageBuilder();
            Udbus.Serialization.NMessageHandle.UdbusMessageHandle msgHandleSend = null;
            int result = -1;

            name = default(string);
            Udbus.Serialization.DbusConnectionParameters connectionParametersDbus = defaultConnectionParametersDbus;
            try
            {
                result = builder.UdbusMethodMessage(serial, connectionParametersDbus, "Hello").Result;
                if ((result == 0))
                {
                    msgHandleSend = builder.Message;
                    result        = this.Send(msgHandleSend);
                    if ((result != 0))
                    {
                        throw Udbus.Serialization.Exceptions.UdbusMethodSendException.Create("Hello", result, connectionParametersDbus);
                    }
                }
            }
            finally
            {
                if ((msgHandleSend != null))
                {
                    msgHandleSend.Dispose();
                }
            }

            if ((result == 0))
            {
                result = helloRecv(out name, this, serial, connectionParametersDbus);
            }
            return(result);
        }
Esempio n. 2
0
        private int WriteStruct(Udbus.Serialization.UdbusMessageBuilder builder, object[] structFields)
        {
            int result = 0;

            if (this.objectDelegate == null)                         // If no fields
            {
                if (structFields != null && structFields.Length > 0) // If there are fields to write
                {
                    result = -1;
                    throw new ApplicationException("Struct has no delegates to write struct fields with");
                } // Ends if there are fields to write
            }     // Ends if no fields
            else  // Else fields
            {
                result = builder.BodyAdd_Structure().Result;

                if (result == 0) // If started struct
                {
                    // Yay casting something to what we already know it is because, yeah, that's how this works...
                    System.Delegate[] delegates = this.objectDelegate.GetInvocationList();
                    int i = 0;

                    foreach (MarshalDelegate <object> fn in delegates)
                    {
                        result = fn(builder, structFields[i]);

                        if (result != 0) // If failed to read result
                        {
                            break;
                        } // Ends if failed to read result

                        ++i;
                    } // Ends loop over delegates

                    if (result == 0) // If read fields
                    {
                        result = builder.BodyAdd_StructureEnd().Result;
                    }    // Ends if read read fields
                    else // Else failed to read fields
                    {
                    }    // Ends if failed to read fields
                }        // Ends if started struct
                else     // Else failed to start struct
                {
                }        // Ends else failed to start struct
            }            // Ends else fields

            return(result);
        }
Esempio n. 3
0
        private int WriteDictionary(Udbus.Serialization.UdbusMessageBuilder builder, Udbus.Containers.dbus_union variantDict)
        {
            int result;

            if (variantDict.IsDbusDictionary == false) // If not a dictionary
            {
                result = -1;
                throw new System.InvalidCastException("object is a dbus_union, but not a dbus dictionary");
            }    // Ends if not a dictionary
            else // Else a dictionary
            {
                result = builder.MarshalDict(variantDict.DbusDictionary, this.ObjectDelegateKey, this.ObjectDelegateValue);
            } // Ends else a dictionary

            return(result);
        }
Esempio n. 4
0
        private int WriteArrayObject(Udbus.Serialization.UdbusMessageBuilder builder, object objArray)
        {
            int result;

            if (objArray is Array == false) // If not array
            {
                result = -1;
                throw new System.InvalidCastException("object is not an array");
            }    // Ends if not array
            else // Else array
            {
                object[] output = (object[])objArray;
                result = builder.MarshalEnumerable(output, this.Type, this.ObjectDelegate);
            } // Ends else array

            return(result);
        }
Esempio n. 5
0
        private int WriteDictionaryObject(Udbus.Serialization.UdbusMessageBuilder builder, object objDict)
        {
            int result;

            if (objDict is Udbus.Containers.dbus_union == false)
            {
                result = -1;
                throw new System.InvalidCastException("object is not a dbus_union");
            }
            else
            {
                Udbus.Containers.dbus_union variantDict = (Udbus.Containers.dbus_union)objDict;

                result = this.WriteDictionary(builder, variantDict);
            }
            return(result);
        }
Esempio n. 6
0
        // The object returned from a struct read is always a variant...
        private int WriteStructObject(Udbus.Serialization.UdbusMessageBuilder builder, object objStruct)
        {
            int result;

            if (objStruct is Udbus.Containers.dbus_union) // If it's a struct
            {
                Udbus.Containers.dbus_union variantStruct = (Udbus.Containers.dbus_union)objStruct;
                result = this.WriteStruct(builder, variantStruct);
            } // Ends if it's a struct
            else if (objStruct is object[]) // Else if it's an array
            {
                object[] structFields = (object[])objStruct;
                result = this.WriteStruct(builder, structFields);
            }    // Ends if it's an array
            else // Else wrong type
            {
                result = -1;
                throw new System.InvalidCastException("object is not a dbus_union or object[]");
            } // Ends else wrong type

            return(result);
        }
Esempio n. 7
0
        private int WriteArrayObject(Udbus.Serialization.UdbusMessageBuilder builder, Udbus.Containers.dbus_union variantArray)
        {
            int result = builder.MarshalEnumerable(variantArray.DbusObjectArray, this.Type, this.ObjectDelegate);

            return(result);
        }
Esempio n. 8
0
 private int WriteStruct(Udbus.Serialization.UdbusMessageBuilder builder, Udbus.Containers.dbus_union variantStruct)
 {
     return(this.WriteStruct(builder, variantStruct.DbusObjectStruct));
 }
Esempio n. 9
0
        public int HelloSend(uint serial, out string name, HelloRecvDelegate helloRecv)
        {
            Udbus.Serialization.UdbusMessageBuilder builder = new Udbus.Serialization.UdbusMessageBuilder();
            Udbus.Serialization.NMessageHandle.UdbusMessageHandle msgHandleSend = null;
            int result = -1;
            name = default(string);
            Udbus.Serialization.DbusConnectionParameters connectionParametersDbus = defaultConnectionParametersDbus;
            try
            {
                result = builder.UdbusMethodMessage(serial, connectionParametersDbus, "Hello").Result;
                if ((result == 0))
                {
                    msgHandleSend = builder.Message;
                    result = this.Send(msgHandleSend);
                    if ((result != 0))
                    {
                        throw Udbus.Serialization.Exceptions.UdbusMethodSendException.Create("Hello", result, connectionParametersDbus);
                    }
                }
            }
            finally
            {
                if ((msgHandleSend != null))
                {
                    msgHandleSend.Dispose();
                }
            }

            if ((result == 0))
            {
                result = helloRecv(out name, this, serial, connectionParametersDbus);
            }
            return result;
        }