using System;
using System.IO;
using IPA.Config.Data;
namespace IPA.Config
{
///
/// An interface for configuration providers.
///
///
///
/// Implementers must provide a default constructor. Do not assume that will ever be set for a given object.
///
///
/// Implementers are expected to preserve the typing of values passed to when returned from .
/// The only exceptions to this are the numeric types, and , since they can be coerced
/// to each other with and respectively. The provider should
/// however store and recover with as much precision as is possible. For example, a JSON provider may decide to
/// decode all numbers that have an integral value, even if they were originally , as .
/// This is reasonable, as is more precise, particularly with larger values, than .
///
///
public interface IConfigProvider
{
///
/// Gets the extension without a dot to use for files handled by this provider.
///
///
/// This must work immediately, and is used to generate the used to set
/// .
///
string Extension { get; }
///
/// Sets the file that this provider will read and write to.
///
///
/// The provider is expected to gracefully handle this changing at any point,
/// and is expected to close any old file handles when this is reassigned.
/// This may be set to the same file multiple times in this object's lifetime.
/// This will always have been set at least once before any calls to
/// or are made.
///
FileInfo File { set; }
// TODO: consider moving to asynchronous Store and Load with a FileInfo parameter
///
/// Stores the given to disk in the format specified.
///
/// the to store
void Store(Value value);
///
/// Loads a from disk in whatever format this provider provides
/// and returns it.
///
/// the loaded
Value Load();
}
}