private int ReadStruct(Udbus.Serialization.UdbusMessageReader reader, out object[] structFields) { int result = 0; if (this.objectDelegate == null) // If no fields { structFields = null; } // Ends if no fields else // Else fields { result = reader.ReadStructureStart(); 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(); object[] fields = new object[delegates.Length]; int i = 0; foreach (MarshalReadDelegate<object> fn in delegates) { result = fn(reader, out fields[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 = reader.ReadStructureEnd(); if (result != 0) // If struct end failed { structFields = null; } // Ends if struct end failed else // Else struct end ok { structFields = fields; } // Ends else struct end ok } // Ends if read read fields else // Else failed to read fields { structFields = null; } // Ends if failed to read fields } // Ends if started struct else // Else failed to start struct { structFields = null; } // Ends else failed to start struct } // Ends else fields return result; }