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);
}