private static async Task <IReadOnlyList <T> > GetProxiesAsync <T>(IDBusObject rootObject, string interfaceName) { // Console.WriteLine("GetProxiesAsync called."); var objectManager = Connection.System.CreateProxy <IObjectManager>(BluezConstants.DbusService, "/"); var objects = await objectManager.GetManagedObjectsAsync(); var matchingObjects = objects .Where(obj => obj.Value.Keys.Contains(interfaceName)) .Select(obj => obj.Key) .Where(objectPath => objectPath.ToString().StartsWith($"{rootObject.ObjectPath}/")); var proxies = matchingObjects .Select(objectPath => Connection.System.CreateProxy <T>(BluezConstants.DbusService, objectPath)) .ToList(); // Console.WriteLine($"GetProxiesAsync returning {proxies.Count} proxies of type {typeof(T)}."); return(proxies); }
/// <summary> /// Unpublishes an object. /// </summary> /// <param name="o">object to unpublish.</param> /// <exception cref="ObjectDisposedException">The connection has been disposed.</exception> /// <exception cref="InvalidOperationException">The operation is invalid in the current state.</exception> /// <exception cref="DisconnectedException">The connection is closed.</exception> public void UnregisterObject(IDBusObject o) => UnregisterObject(o.ObjectPath);
/// <summary> /// Publishes an object. /// </summary> /// <param name="o">Object to publish.</param> /// <exception cref="ObjectDisposedException">The connection has been disposed.</exception> /// <exception cref="InvalidOperationException">The operation is invalid in the current state.</exception> /// <exception cref="DisconnectedException">The connection was closed.</exception> public Task RegisterObjectAsync(IDBusObject o) { return(RegisterObjectsAsync(new[] { o })); }
internal static bool IsMatch(string interfaceName, ObjectPath objectPath, ICollection <string> interfaces, IDBusObject rootObject) { if (rootObject != null && !objectPath.ToString().StartsWith($"{rootObject.ObjectPath}/")) { return(false); } return(interfaces.Contains(interfaceName)); }
internal static bool IsMatch(string interfaceName, ObjectPath objectPath, IDictionary <string, IDictionary <string, object> > interfaces, IDBusObject rootObject) { return(IsMatch(interfaceName, objectPath, interfaces.Keys, rootObject)); }
internal static async Task <IReadOnlyList <T> > GetProxiesAsync <T>(string interfaceName, IDBusObject rootObject) { var objectManager = Connection.System.CreateProxy <IObjectManager>(BluezConstants.DbusService, "/"); var objects = await objectManager.GetManagedObjectsAsync(); var matchingObjectPaths = objects .Where(obj => IsMatch(interfaceName, obj.Key, obj.Value, rootObject)) .Select(obj => obj.Key); var proxies = matchingObjectPaths .Select(objectPath => Connection.System.CreateProxy <T>(BluezConstants.DbusService, objectPath)) .ToList(); return(proxies); }
public void WriteBusObject(IDBusObject busObject) { WriteObjectPath(busObject.ObjectPath); }