コード例 #1
0
 /// <summary>
 ///     Adds a single app that gets instantiated by the provided Func
 /// </summary>
 /// <param name="services">Services</param>
 /// <param name="factoryFunc">The Func used to create the app</param>
 /// <param name="id">The id of the app. This parameter is optional,
 ///                  by default it tries to locate the id from the specified TAppType.</param>
 /// <param name="focus">Whether this app has focus or not. This parameter is optional,
 ///                     by default it tries to check this using the FocusAttribute</param>
 /// <typeparam name="TAppType">The type of the app</typeparam>
 public static IServiceCollection AddNetDaemonApp <TAppType>(
     this IServiceCollection services,
     Func <IServiceProvider, TAppType> factoryFunc,
     string?id  = default,
     bool?focus = default) where TAppType : class
 {
     return(services
            .AddAppModelIfNotExist()
            .AddSingleton <IAppFactoryProvider>(SingleAppFactoryProvider.Create(factoryFunc, id, focus)));
 }
コード例 #2
0
 /// <summary>
 ///     Add a single app
 /// </summary>
 /// <param name="services">Services</param>
 /// <param name="type">The type of the app to add</param>
 public static IServiceCollection AddNetDaemonApp(this IServiceCollection services, Type type)
 {
     return(services
            .AddAppModelIfNotExist()
            .AddSingleton(SingleAppFactoryProvider.Create(type)));
 }