You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel/Services/Config/IConfiguration.cs

148 lines
3.9 KiB

6 years ago
using System;
using System.Collections.Generic;
using ZeroLevel.Services.Serialization;
namespace ZeroLevel
{
/// <summary>
/// Configuration section
6 years ago
/// </summary>
public interface IConfiguration :
IEquatable<IConfiguration>,
IBinarySerializable
{
#region Properties
6 years ago
/// <summary>
/// Get values by key
6 years ago
/// </summary>
IEnumerable<string> this[string key] { get; }
6 years ago
/// <summary>
/// Keys
6 years ago
/// </summary>
IEnumerable<string> Keys { get; }
6 years ago
/// <summary>
/// Configuration is locked for change when true
6 years ago
/// </summary>
bool Freezed { get; }
#endregion Properties
6 years ago
#region Methods
6 years ago
/// <summary>
/// Get values by key
6 years ago
/// </summary>
/// <param name="key">Key</param>
/// <returns>Values list</returns>
6 years ago
IEnumerable<string> Items(string key);
6 years ago
/// <summary>
/// Get first value by key
6 years ago
/// </summary>
string First(string key);
6 years ago
/// <summary>
/// Get first value by key with cast to <typeparamref name="T"/>
6 years ago
/// </summary>
T First<T>(string key);
6 years ago
/// <summary>
/// Get first or default value by key
6 years ago
/// </summary>
string FirstOrDefault(string name, string defaultValue);
6 years ago
/// <summary>
/// Get first or default value by key with cast to <typeparamref name="T"/>
6 years ago
/// </summary>
T FirstOrDefault<T>(string name);
6 years ago
/// <summary>
/// Get first or default value by key with cast to <typeparamref name="T"/>
6 years ago
/// </summary>
T FirstOrDefault<T>(string name, T defaultValue);
6 years ago
/// <summary>
/// Check key exists
6 years ago
/// </summary>
bool Contains(string key);
6 years ago
/// <summary>
/// Check one of key exists
6 years ago
/// </summary>
bool Contains(params string[] keys);
6 years ago
/// <summary>
/// true if exists one or more values by key
6 years ago
/// </summary>
bool ContainsValue(string key, string value);
6 years ago
/// <summary>
/// Count values by key
6 years ago
/// </summary>
int Count(string key);
6 years ago
/// <summary>
/// Do action if key exists, action takes first value
6 years ago
/// </summary>
void DoWithFirst(string key, Action<string> action);
6 years ago
/// <summary>
/// Do action if key exists, action takes first value with cast to <typeparamref name="T"/>
6 years ago
/// </summary>
void DoWithFirst<T>(string key, Action<T> action);
#endregion Methods
6 years ago
#region Create, Clean, Delete
6 years ago
/// <summary>
/// Clean
6 years ago
/// </summary>
IConfiguration Clear();
6 years ago
/// <summary>
/// Clean values by key
6 years ago
/// </summary>
IConfiguration Clear(string key);
6 years ago
/// <summary>
/// Remove key and binded values
6 years ago
/// </summary>
IConfiguration Remove(string key);
6 years ago
/// <summary>
/// Append key and value
6 years ago
/// </summary>
IConfiguration Append(string key, string value);
5 years ago
/// <summary>
/// Append key and values list
/// </summary>
IConfiguration Append(string key, IEnumerable<string> values);
6 years ago
/// <summary>
/// Set key with one value, if any values by key exists, they will be dropped
6 years ago
/// </summary>
IConfiguration SetUnique(string key, string value);
6 years ago
/// <summary>
/// Sets a prohibition on changing
6 years ago
/// </summary>
/// <returns>false - prohibition was set already</returns>
6 years ago
bool Freeze(bool permanent = false);
6 years ago
/// <summary>
/// Remove a prohibition on changing
6 years ago
/// </summary>
bool Unfreeze();
#endregion Create, Clean, Delete
void CopyTo(IConfiguration config);
T Bind<T>();
object Bind(Type type);
6 years ago
}
}

Powered by TurnKey Linux.