public ObjectPath RegisterObject(string serviceName, object o, string objectName) { ObjectPath path = null; if (DBusConnection.Enabled && Bus.Session != null) { object [] attrs = o.GetType().GetCustomAttributes(typeof(DBusExportableAttribute), true); if (attrs != null && attrs.Length > 0) { DBusExportableAttribute dbus_attr = (DBusExportableAttribute)attrs[0]; if (!String.IsNullOrEmpty(dbus_attr.ServiceName)) { serviceName = dbus_attr.ServiceName; } } lock (registered_objects) { registered_objects.Add(o, path = new ObjectPath(objectName)); } string bus_name = DBusConnection.MakeBusName(serviceName); Log.DebugFormat("Registering remote object {0} ({1}) on {2}", path, o.GetType(), bus_name); #pragma warning disable 0618 Bus.Session.Register(bus_name, path, o); #pragma warning restore 0618 } return(path); }
public static T FindInstance <T> (string serviceName, bool isFullBusName, string objectPath) where T : class { string busName = isFullBusName ? serviceName : DBusConnection.MakeBusName(serviceName); if (!DBusConnection.Enabled || !Bus.Session.NameHasOwner(busName)) { return(null); } string full_object_path = objectPath; if (!objectPath.StartsWith(ObjectRoot)) { full_object_path = ObjectRoot + objectPath; } return(Bus.Session.GetObject <T> (busName, new ObjectPath(full_object_path))); }