public MicrosoftAccountHandler(IPasswordVaultService passwordVaultService) : base(passwordVaultService)
 {
     Scopes = new[]
     {
         APPIDURI_MSGRAPH + "User.Read.All",
     };
 }
Exemplo n.º 2
0
 public MainViewModel(IPasswordVaultService passwordVaultService)
 {
     _passwordVaultService = passwordVaultService;
 }
Exemplo n.º 3
0
        private static IEnumerable <PackageHandlerBase> InstantiateAllPackageHandlers(Assembly pluginAssembly, ISettingsService settings, IPasswordVaultService passwordVaultService)
        {
            object[] ctorArgs = new object[] { passwordVaultService };

            foreach (Type type in pluginAssembly.GetTypes()
                     .Where(t => t.BaseType.IsAssignableTo(typeof(PackageHandlerBase)) && t.IsPublic))
            {
                var ctr = type.GetConstructor(_ctorTypeList);
                if (ctr == null)
                {
                    continue;
                }

                // Create a new instance of the handler
                var handler = (PackageHandlerBase)ctr.Invoke(ctorArgs);
                if (handler == null)
                {
                    continue;
                }

                // Enable or disable according to user settings
                handler.IsEnabled = settings.GetPackageHandlerEnabledState(type.Name);

                // Pass services to handler
                ((IHandler)handler).SetServices(pkgSvc, accSvc);

                // Register handler with the type name as its ID
                yield return(handler);
            }
        }
Exemplo n.º 4
0
 public PackageHandlerBase(IPasswordVaultService passwordVaultService) : base(passwordVaultService)
 {
 }
Exemplo n.º 5
0
        /// <summary>
        /// Attempts to load all plugins located in <see cref="ISettingsService.PluginDirectory"/>
        /// and registers all loaded package handlers with the provided <paramref name="packageHandlers"/>.
        /// </summary>
        /// <param name="packageHandlers">The dictionary to add loaded package handlers to.</param>
        public static PluginLoadResult LoadPlugins(ISettingsService settings, IPasswordVaultService passwordVaultService)
        {
            PluginLoadResult result = new();

            // Make sure that the runtime looks for plugin dependencies
            // in the plugin's folder.
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.AssemblyResolve += LoadFromSameFolder;

            foreach (string pluginInfoPath in Directory.EnumerateFiles(settings.PluginDirectory, "*.txt", SearchOption.AllDirectories))
            {
                // The plugin info file is a plain text file where each line is
                // a relative path to the DLLs containing the actual implementation.
                // This is to avoid unnecessarily loading and searching for package
                // handlers in DLLs that are only for dependencies (and also serves
                // to prevent loading the same plugin twice, if one plugin depends
                // on another.
                string   pluginPath       = Path.GetDirectoryName(pluginInfoPath);
                string[] dllRelativePaths = File.ReadAllLines(pluginInfoPath);
                foreach (string dllRelativePath in dllRelativePaths)
                {
                    string assemblyPath = Path.Combine(pluginPath, dllRelativePath);
                    if (string.IsNullOrWhiteSpace(assemblyPath))
                    {
                        continue;
                    }

                    try
                    {
                        // Load assembly and consider only types that inherit from PackageHandlerBase
                        // and are public.
                        var assembly = Assembly.LoadFile(assemblyPath);

                        foreach (PackageHandlerBase handler in InstantiateAllPackageHandlers(assembly, settings, passwordVaultService))
                        {
                            // Register handler
                            result.PackageHandlers.Add(handler);
                        }
                    }
                    catch (Exception ex)
                    {
#if DEBUG
                        System.Diagnostics.Debug.WriteLine(ex);
#endif
                        continue;
                    }
                }
            }

            // Pass loaded handlers to respective services
            accSvc.AccountHandlers = result.AccountHandlers;
            pkgSvc.PackageHandlers = result.PackageHandlers;

            // Call OnLoaded method on all handlers
            IHandler[] handlers = result.AccountHandlers.OfType <IHandler>().Concat(result.PackageHandlers.Values.OfType <IHandler>()).ToArray();
            foreach (var handler in handlers)
            {
                handler.OnLoaded();
            }

            return(result);
        }
Exemplo n.º 6
0
 public FluentStoreHandler(IPasswordVaultService passwordVaultService) : base(passwordVaultService)
 {
     AccountHandler = new Users.FluentStoreAccountHandler(FSApi, passwordVaultService);
 }
Exemplo n.º 7
0
 public GitHubAccountHandler(GitHubClient client, CredentialStore credentialStore, IPasswordVaultService passwordVaultService)
     : base(passwordVaultService)
 {
     _client          = client;
     _credentialStore = credentialStore;
 }
Exemplo n.º 8
0
 public UwpCommunityHandler(IPasswordVaultService passwordVaultService) : base(passwordVaultService)
 {
     // TODO: Create UWPC account handler
     //AccountHandler = new Users.UwpCommunityAccountHandler(passwordVaultService);
 }
 public FluentStoreAccountHandler(FluentStoreAPI.FluentStoreAPI fsApi, IPasswordVaultService passwordVault)
     : base(passwordVault)
 {
     FSApi = fsApi;
 }
Exemplo n.º 10
0
 public AccountHandlerBase(IPasswordVaultService passwordVaultService)
 {
     _passwordVaultService = passwordVaultService;
 }
Exemplo n.º 11
0
 public MainViewModel(IPasswordVaultService passwordVaultService)
 {
     _passwordVaultService = passwordVaultService;
 }
Exemplo n.º 12
0
 public AuthService()
 {
     _passwordVaultService = App.Container.GetRequiredService <IPasswordVaultService>();
 }
Exemplo n.º 13
0
 protected OpenIDAccountHandler(IPasswordVaultService passwordVaultService) : base(passwordVaultService)
 {
 }
Exemplo n.º 14
0
 public ChocolateyHandler(IPasswordVaultService passwordVaultService) : base(passwordVaultService)
 {
 }