// Kyoo - A portable and vast media library solution.
// Copyright (c) Kyoo.
//
// See AUTHORS.md and LICENSE file in the project root for full license information.
//
// Kyoo is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// Kyoo is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Kyoo. If not, see .
using System;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Kyoo.Abstractions.Models;
using Kyoo.Abstractions.Models.Exceptions;
namespace Kyoo.Abstractions.Controllers
{
///
/// A class to ease configuration management. This work WITH Microsoft's package, you can still use IOptions patterns
/// to access your options, this manager ease dynamic work and editing.
/// It works with .
///
public interface IConfigurationManager
{
///
/// Add an editable configuration to the editable configuration list.
///
/// The root path of the editable configuration. It should not be a nested type.
/// The type of the configuration.
void AddTyped(string path);
///
/// Add an editable configuration to the editable configuration list.
/// WARNING: this method allow you to add an unmanaged type. This type won't be editable. This can be used
/// for external libraries or variable arguments.
///
/// The root path of the editable configuration. It should not be a nested type.
void AddUntyped(string path);
///
/// An helper method of and .
/// This register a typed value if is not null and registers an untyped type
/// if is null.
///
/// The root path of the editable configuration. It should not be a nested type.
/// The type of the configuration or null.
void Register(string path, [CanBeNull] Type type);
///
/// Get the value of a setting using it's path.
///
/// The path of the resource (can be separated by ':' or '__').
/// No setting found at the given path.
/// The value of the settings (if it's a strongly typed one, the given type is instantiated.
object GetValue(string path);
///
/// Get the value of a setting using it's path.
/// If your don't need a strongly typed value, see .
///
/// The path of the resource (can be separated by ':' or '__').
/// A type to strongly type your option.
/// If your type is not the same as the registered type.
/// No setting found at the given path.
/// The value of the settings (if it's a strongly typed one, the given type is instantiated.
T GetValue(string path);
///
/// Edit the value of a setting using it's path. Save it to the json file.
///
/// The path of the resource (can be separated by ':' or '__').
/// The new value of the resource.
/// No setting found at the given path.
/// A representing the asynchronous operation.
Task EditValue(string path, object value);
}
}