Example #1
0
        public static T GetInstance <T>(this IDBusConnection provider, ObjectPath path, string serviceName, out IDBusObjectProxy <T> container)
        {
            var interfaceAttribute = typeof(T).GetCustomAttribute <DBusInterfaceAttribute>(false);

            if (interfaceAttribute == null)
            {
                throw new ArgumentException($"{nameof(DBusInterfaceAttribute)} missing");
            }
            return(provider.GetInstance(path, interfaceAttribute.Name, serviceName, out container));
        }
Example #2
0
 public ProxyInterceptor(IDBusObjectProxy proxyInfo, TypeDescription typeDescription)
 {
     this.proxyInfo = proxyInfo;
     TypeDescriptor = typeDescription;
 }
Example #3
0
        public T GetInstance <T>(ObjectPath path, string interfaceName, string serviceName, out IDBusObjectProxy <T> container)
        {
            IClientObjectProvider preferred = null;
            IClientObjectProvider first     = null;

            foreach (var prov in proxyProviders)
            {
                var pref = prov.TypePreference <T>();
                if (preferred == null)
                {
                    if (pref == ProviderPreferences.Preferred)
                    {
                        preferred = prov;
                        break;
                    }
                }
                if (first == null && pref != ProviderPreferences.UnableToGet)
                {
                    first = prov;
                }
            }
            if (preferred == null)
            {
                preferred = first;
            }
            if (preferred == null)
            {
                throw new ArgumentException($"Unable to find proxy provider to create instance for {typeof(T)}");
            }
            return(preferred.GetInstance <T>(path, interfaceName, serviceName, out container));
        }
 public static T CreateProxy <T>(this IConnection connection, string service, ObjectPath path, out IDBusObjectProxy <T> container)
 {
     if (connection == null)
     {
         throw new ArgumentNullException(nameof(connection));
     }
     return(connection.BaseDBusConnection.GetInstance <T>(path, service, out container));
 }