mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-08-21 12:54:08 +02:00
.github
Application
Browser
Configuration
Controls
Dialogs
Management
Plugins
Properties
Resources
Updates
Utils
bld
lib
TweetLib.Communication
TweetLib.Core
Application
Browser
Collections
Data
Features
Serialization
Systems
Utils
App.cs
Lib.cs
TweetLib.Core.csproj
TweetTest.System
TweetTest.Unit
subprocess
video
.gitattributes
.gitignore
LICENSE.md
Program.cs
README.md
Reporter.cs
TweetDuck.csproj
TweetDuck.sln
TweetDuck.sln.DotSettings
Version.cs
packages.config
37 lines
1.4 KiB
C#
37 lines
1.4 KiB
C#
using System;
|
|
using TweetLib.Core.Application;
|
|
|
|
namespace TweetLib.Core{
|
|
public sealed class App{
|
|
#pragma warning disable CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable.
|
|
public static IAppErrorHandler ErrorHandler { get; private set; }
|
|
public static IAppSystemHandler SystemHandler { get; private set; }
|
|
public static IAppResourceHandler ResourceHandler { get; private set; }
|
|
#pragma warning restore CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable.
|
|
|
|
// Builder
|
|
|
|
public sealed class Builder{
|
|
public IAppErrorHandler? ErrorHandler { get; set; }
|
|
public IAppSystemHandler? SystemHandler { get; set; }
|
|
public IAppResourceHandler? ResourceHandler { get; set; }
|
|
|
|
// Validation
|
|
|
|
internal void Initialize(){
|
|
App.ErrorHandler = Validate(ErrorHandler, nameof(ErrorHandler))!;
|
|
App.SystemHandler = Validate(SystemHandler, nameof(SystemHandler))!;
|
|
App.ResourceHandler = Validate(ResourceHandler, nameof(ResourceHandler))!;
|
|
}
|
|
|
|
private T Validate<T>(T obj, string name){
|
|
if (obj == null){
|
|
throw new InvalidOperationException("Missing property " + name + " on the provided App.");
|
|
}
|
|
|
|
return obj;
|
|
}
|
|
}
|
|
}
|
|
}
|