mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-17 02:34:10 +02:00
32 lines
972 B
C#
32 lines
972 B
C#
using System;
|
|
using TweetLib.Core.Application;
|
|
|
|
namespace TweetLib.Core{
|
|
public sealed class App{
|
|
public static IAppErrorHandler ErrorHandler { get; private set; }
|
|
public static IAppSystemHandler SystemHandler { get; private set; }
|
|
|
|
// Builder
|
|
|
|
public sealed class Builder{
|
|
public IAppErrorHandler? ErrorHandler { get; set; }
|
|
public IAppSystemHandler? SystemHandler { get; set; }
|
|
|
|
// Validation
|
|
|
|
internal void Initialize(){
|
|
App.ErrorHandler = Validate(ErrorHandler, nameof(ErrorHandler))!;
|
|
App.SystemHandler = Validate(SystemHandler, nameof(SystemHandler))!;
|
|
}
|
|
|
|
private T Validate<T>(T obj, string name){
|
|
if (obj == null){
|
|
throw new InvalidOperationException("Missing property " + name + " on the provided App.");
|
|
}
|
|
|
|
return obj;
|
|
}
|
|
}
|
|
}
|
|
}
|