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