Exemple #1
0
        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);
        }
Exemple #2
0
 /// <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);
Exemple #3
0
 /// <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 }));
 }
Exemple #4
0
        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));
        }
Exemple #5
0
 internal static bool IsMatch(string interfaceName, ObjectPath objectPath, IDictionary <string, IDictionary <string, object> > interfaces, IDBusObject rootObject)
 {
     return(IsMatch(interfaceName, objectPath, interfaces.Keys, rootObject));
 }
Exemple #6
0
        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);
 }