Sphere10.Framework.Application
3.0.2
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
<PackageReference Include="Sphere10.Framework.Application" Version="3.0.2" />
<PackageVersion Include="Sphere10.Framework.Application" Version="3.0.2" />
<PackageReference Include="Sphere10.Framework.Application" />
paket add Sphere10.Framework.Application --version 3.0.2
#r "nuget: Sphere10.Framework.Application, 3.0.2"
#:package Sphere10.Framework.Application@3.0.2
#addin nuget:?package=Sphere10.Framework.Application&version=3.0.2
#tool nuget:?package=Sphere10.Framework.Application&version=3.0.2
💫 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,CommandLineArgumentattributes 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
ServiceProviderwhen needed - Middleware Pattern: Apply transformations/cross-cutting concerns
- Settings by Convention: Type-safe settings with strong validation
📖 Related Projects
- Sphere10.Framework - Core framework
- Sphere10.Framework.Web.AspNetCore - ASP.NET Core integration
- Sphere10.Framework.Communications - RPC services with DI
- Sphere10.Framework.DApp.Host - DApp host using this framework
- Sphere10.Framework.DApp.Node - Blockchain node application
✅ 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 | Versions 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. |
-
net8.0
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Sphere10.Framework (>= 3.0.2)
- Sphere10.Framework.Data (>= 3.0.2)
- System.Configuration.ConfigurationManager (>= 8.0.0)
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
ASP.NET Core integration library providing middleware, extensions, and utilities for building web applications and APIs with Sphere10 Framework. Bridges the framework into the ASP.NET Core ecosystem for logging, configuration, dependency injection, routing, HTML/XML processing, sitemap support, and server-side form handling. |
GitHub repositories
This package is not used by any popular GitHub repositories.