コード例 #1
0
ファイル: VectorBLE.cs プロジェクト: magico13/VectorConfig
        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);
        }
コード例 #2
0
ファイル: Connection.cs プロジェクト: matdug/Tmds.DBus
 /// <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);
コード例 #3
0
ファイル: Connection.cs プロジェクト: matdug/Tmds.DBus
 /// <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 }));
 }
コード例 #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));
        }
コード例 #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));
 }
コード例 #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);
        }
コード例 #7
0
 public void WriteBusObject(IDBusObject busObject)
 {
     WriteObjectPath(busObject.ObjectPath);
 }