Sphere10.Framework.Application 3.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Sphere10.Framework.Application --version 3.0.2
                    
NuGet\Install-Package Sphere10.Framework.Application -Version 3.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sphere10.Framework.Application" Version="3.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sphere10.Framework.Application" Version="3.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Sphere10.Framework.Application" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Sphere10.Framework.Application --version 3.0.2
                    
#r "nuget: Sphere10.Framework.Application, 3.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Sphere10.Framework.Application@3.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Sphere10.Framework.Application&version=3.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Sphere10.Framework.Application&version=3.0.2
                    
Install as a Cake Tool

💫 Sphere10.Framework.Application

Application framework and lifecycle management providing dependency injection integration, settings management, command-line argument parsing, and foundation for building full-featured Sphere10 Framework-based applications.

Sphere10.Framework.Application enables rapid application development with built-in service configuration, CLI argument parsing, settings persistence, and application lifecycle hooks integrated with Microsoft.Extensions.DependencyInjection.

⚡ 10-Second Example

using Sphere10.Framework.Application;
using Microsoft.Extensions.DependencyInjection;

// Build application with framework
var app = Sphere10App.CreateBuilder()
    .ConfigureServices(services => {
        services.AddSingleton<IRepository, DatabaseRepository>();
        services.AddSingleton<ILogger, ConsoleLogger>();
    })
    .Build();

// Access configured services
var repo = app.ServiceProvider.GetRequiredService<IRepository>();
var logger = app.ServiceProvider.GetRequiredService<ILogger>();

logger.Info("Application started");
repo.SaveData("important", data);

// Application runs until disposal
app.Run();

🏗️ Core Concepts

Application Builder Pattern: Fluent builder API for configuring services, settings, and lifecycle hooks.

Dependency Injection: Full integration with Microsoft.Extensions.DependencyInjection for service composition.

Settings Management: Type-safe application settings with persistence and validation.

Lifecycle Hooks: Startup, configuration, and shutdown extensions for custom initialization.

Command-Line Parsing: Attribute-based CLI argument parsing with validation and help generation.

Product Management: Product identification, versioning, and licensing support.

� Core Examples

Basic Application Setup

using Sphere10.Framework.Application;
using Microsoft.Extensions.DependencyInjection;

// Create application with service configuration
var app = Sphere10App.CreateBuilder()
    .AddLogging()  // Add console logging
    .ConfigureServices(services => {
        // Register custom services
        services.AddSingleton<IUserRepository, UserRepository>();
        services.AddSingleton<IEmailService, SmtpEmailService>();
        services.AddSingleton<IDataProcessor, DataProcessor>();
    })
    .Build();

// Get configured service
var userRepo = app.ServiceProvider.GetRequiredService<IUserRepository>();
var users = userRepo.GetAllUsers();

Console.WriteLine($"Loaded {users.Count} users");

Settings Management

using Sphere10.Framework.Application;
using Microsoft.Extensions.DependencyInjection;

// Define typed settings
public class AppSettings {
    public string DatabaseConnection { get; set; }
    public int MaxConnections { get; set; }
    public bool EnableLogging { get; set; }
    public List<string> AllowedOrigins { get; set; }
}

var app = Sphere10App.CreateBuilder()
    .ConfigureSettings<AppSettings>(settings => {
        settings.DatabaseConnection = "Server=localhost;Database=mydb";
        settings.MaxConnections = 100;
        settings.EnableLogging = true;
        settings.AllowedOrigins = new[] { "http://localhost:3000", "https://myapp.com" }.ToList();
    })
    .ConfigureServices((services, settings) => {
        // Use settings in service configuration
        services.AddSingleton(new DatabaseConnection(settings.DatabaseConnection, settings.MaxConnections));
    })
    .Build();

// Access settings anywhere via DI
var appSettings = app.ServiceProvider.GetRequiredService<AppSettings>();
Console.WriteLine($"Database: {appSettings.DatabaseConnection}");
Console.WriteLine($"Max connections: {appSettings.MaxConnections}");

Lifecycle Hooks

using Sphere10.Framework.Application;
using Microsoft.Extensions.DependencyInjection;

var app = Sphere10App.CreateBuilder()
    .ConfigureServices(services => {
        services.AddSingleton<IInitializer, DatabaseInitializer>();
    })
    .OnStarting(async (app, cancellation) => {
        Console.WriteLine("Application starting...");
        
        // Initialize database
        var initializer = app.ServiceProvider.GetRequiredService<IInitializer>();
        await initializer.InitializeAsync(cancellation);
        
        Console.WriteLine("Application initialized");
    })
    .OnStopping(async (app, cancellation) => {
        Console.WriteLine("Application stopping...");
        
        // Cleanup resources
        var connection = app.ServiceProvider.GetRequiredService<IDbConnection>();
        connection?.Close();
        
        Console.WriteLine("Application stopped");
    })
    .Build();

// Run application until cancellation
await app.RunAsync();

Command-Line Argument Parsing

using Sphere10.Framework.Application;

// Define CLI arguments with attributes
[CommandLineOptions]
public class AppOptions {
    [CommandLineArgument("--database", "-d")]
    public string DatabasePath { get; set; } = "data.db";
    
    [CommandLineArgument("--verbose", "-v")]
    public bool Verbose { get; set; } = false;
    
    [CommandLineArgument("--threads", "-t")]
    public int ThreadCount { get; set; } = Environment.ProcessorCount;
    
    [CommandLineArgument("--config", "-c", Required = true)]
    public string ConfigFile { get; set; }
}

// Parse command-line arguments
var args = new[] { "--database", "custom.db", "--verbose", "--config", "app.json" };
var options = CommandLineParser.Parse<AppOptions>(args);

Console.WriteLine($"Database: {options.DatabasePath}");    // custom.db
Console.WriteLine($"Verbose: {options.Verbose}");          // true
Console.WriteLine($"Threads: {options.ThreadCount}");      // logical CPU count
Console.WriteLine($"Config: {options.ConfigFile}");        // app.json

// Get help message
string help = CommandLineParser.GetHelpText<AppOptions>();
Console.WriteLine(help);

Service Factories & Scoping

using Sphere10.Framework.Application;
using Microsoft.Extensions.DependencyInjection;

// Create scoped services for request-like patterns
var app = Sphere10App.CreateBuilder()
    .ConfigureServices(services => {
        // Singleton: one instance for entire application
        services.AddSingleton<IConfigurationService, ConfigurationService>();
        
        // Transient: new instance every time requested
        services.AddTransient<IRequestHandler, RequestHandler>();
        
        // Scoped: one instance per scope (e.g., per request)
        services.AddScoped<IDbContext, DbContext>();
    })
    .Build();

// Use services with scoping
using (var scope = app.ServiceProvider.CreateScope()) {
    var dbContext = scope.ServiceProvider.GetRequiredService<IDbContext>();
    var handler = scope.ServiceProvider.GetRequiredService<IRequestHandler>();
    
    handler.Process(dbContext);
}  // IDbContext disposed here

REST API Integration

using Sphere10.Framework.Application;
using Microsoft.Extensions.DependencyInjection;

public interface IUserService {
    Task<User> GetUserAsync(int id);
    Task CreateUserAsync(User user);
}

public class UserService : IUserService {
    private readonly IUserRepository _repo;
    
    public UserService(IUserRepository repo) => _repo = repo;
    
    public async Task<User> GetUserAsync(int id) => await _repo.GetAsync(id);
    public async Task CreateUserAsync(User user) => await _repo.SaveAsync(user);
}

// Build application with REST support
var app = Sphere10App.CreateBuilder()
    .ConfigureServices(services => {
        services.AddSingleton<IUserRepository, UserRepository>();
        services.AddSingleton<IUserService, UserService>();
        services.AddRestApi();  // Configure REST helpers
    })
    .Build();

// Use service through REST framework (in ASP.NET Core or similar)
var userService = app.ServiceProvider.GetRequiredService<IUserService>();
var user = await userService.GetUserAsync(42);

🎯 Module Organization

  • Core: Sphere10App, Sphere10AppBuilder - Application creation and configuration
  • Lifecycle: Startup/shutdown hooks with async cancellation support
  • IoC/DI: Integration with Microsoft.Extensions.DependencyInjection
  • CommandLine: CommandLineParser, CommandLineArgument attributes for CLI parsing
  • Settings: Typed settings classes with validation and persistence
  • Product: ProductInfo, versioning, and license management
  • Presentation: Base classes for MVVM, view models, and UI bindings
  • Rest: Helper utilities for REST API development

🔧 Application Builder Pattern

The builder pattern provides fluent configuration:

Sphere10App.CreateBuilder()
    .AddLogging()
    .AddSettings<AppSettings>()
    .ConfigureServices(services => {/* ... */})
    .OnStarting(async (app, ct) => {/* ... */})
    .OnInitialized(async (app, ct) => {/* ... */})
    .OnStopping(async (app, ct) => {/* ... */})
    .Build()
    .Run();

🌐 Dependency Injection Container

Full Microsoft.Extensions.DependencyInjection support:

  • Singleton: Application-wide single instance (configuration, loggers)
  • Transient: New instance per request (handlers, processors)
  • Scoped: Instance per logical scope (request, transaction)
  • Factory: Custom factory methods for complex object creation

⚠️ Design Patterns

  • Composition Root: All service configuration in one place at startup
  • Dependency Inversion: Depend on abstractions, not implementations
  • Service Locator: Get services from ServiceProvider when needed
  • Middleware Pattern: Apply transformations/cross-cutting concerns
  • Settings by Convention: Type-safe settings with strong validation

✅ Status & Maturity

  • Core Framework: Production-tested, stable
  • DI Integration: Full support for Microsoft.Extensions.DependencyInjection
  • .NET Target: .NET 8.0+ (primary)
  • Thread Safety: Application-wide; services should handle their own thread safety
  • Async Support: Full async/await support throughout lifecycle hooks

📦 Dependencies

  • Sphere10 Framework: Core framework
  • Microsoft.Extensions.DependencyInjection: Service composition
  • System.Configuration.ConfigurationManager: Configuration support
  • System.Reflection: Service discovery and attribute processing

⚖️ License

Distributed under the MIT NON-AI License.

See the LICENSE file for full details. More information: Sphere10 NON-AI-MIT License

👤 Author

Herman Schoenfeld - Software Engineer

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Sphere10.Framework.Application:

Package Downloads
Sphere10.Framework.Windows.Forms

Windows Forms UI framework and component library for building desktop applications with Sphere10 Framework. Provides reusable WinForms controls, dialogs, layout/helpers, and common UI utilities intended to integrate cleanly with the framework's application and data layers.

Sphere10.Framework.Web.AspNetCore

Shared ASP.NET Core integration for Sphere10 Framework: hosting, dependency injection, logging, HTTP and session extensions, and middleware.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.2.0-ci.163.43664782937.1 54 11/15/2026
3.2.0-ci.160.43660265392.1 56 11/15/2026
3.2.0-ci.159.43537748063.1 73 11/14/2026
3.2.0-ci.158.43536665157.1 68 11/14/2026
3.2.0-ci.157.43350632870.1 72 11/13/2026
3.2.0-ci.156.43233095581.1 72 11/12/2026
3.1.2 246 9/9/2026
3.1.1 179 9/8/2026
3.1.0 134 9/7/2026
3.0.3 240 1/6/2026
3.0.2 178 1/2/2026
3.0.1 181 1/2/2026
3.0.0 172 1/2/2026