Пример #1
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;
        }