Refactoring and localization

pull/1/head
Ogoun 6 years ago
parent 618d1de5ff
commit d30d681f0c

@ -6,19 +6,32 @@ namespace ZeroExample
public sealed class MyFirstApp
: BaseWindowsService, IZeroService
{
public MyFirstApp() : base("MyApp") { Log.AddConsoleLogger(); }
public override void PauseAction() { }
public override void ResumeAction() { }
public MyFirstApp() : base("MyApp")
{
Log.AddConsoleLogger();
}
public override void PauseAction()
{
}
public override void ResumeAction()
{
}
public override void StartAction()
{
Log.Info("Started");
}
public override void StopAction() { }
public override void StopAction()
{
}
}
class Program
internal class Program
{
static void Main(string[] args)
private static void Main(string[] args)
{
Bootstrap.Startup<MyFirstApp>(args);
}

@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following

@ -4,8 +4,8 @@
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<appSettings>
<add key="console" value="true"/>
<add key="port" value="8885"/>
<add key="console" value="true" />
<add key="port" value="8885" />
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

@ -11,6 +11,7 @@ namespace ZeroLevel.Discovery
public abstract class BaseController : ApiController
{
#region Responce create helpers
public static HttpResponseMessage BadRequestAnswer(HttpRequestMessage request, string message)
{
return request.CreateSelfDestroyingResponse(HttpStatusCode.BadRequest,
@ -90,6 +91,7 @@ namespace ZeroLevel.Discovery
}
return null;
}
#endregion
#endregion Responce create helpers
}
}

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Description;
using ZeroLevel.Models;

@ -1,8 +1,8 @@
namespace ZeroLevel.Discovery
{
class Program
internal class Program
{
static void Main(string[] args)
private static void Main(string[] args)
{
Bootstrap.Startup<DiscoveryService>(args);
}

@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following

@ -3,7 +3,6 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using ZeroLevel.Microservices;
using ZeroLevel.Models;
@ -24,6 +23,7 @@ namespace ZeroLevel.Discovery
}
#region Snapshot
private static readonly object _snapshot_lock = new object();
private void Save()
@ -89,7 +89,8 @@ namespace ZeroLevel.Discovery
Log.Error(ex, "Fault load snapshot");
}
}
#endregion
#endregion Snapshot
private bool Ping(string protocol, string endpoint, string msg)
{

@ -67,6 +67,7 @@ namespace ZeroLevel.Discovery
}
private static bool _log_request_response;
public static void StartWebPanel(int port,
bool log_request_response)
{

@ -6,8 +6,11 @@ namespace ZeroLevel.Microservices.Contracts
public interface IDiscoveryClient
{
void Register(MicroserviceInfo info);
IEnumerable<ServiceEndpointInfo> GetServiceEndpoints(string serviceKey);
IEnumerable<ServiceEndpointInfo> GetServiceEndpointsByGroup(string serviceGroup);
IEnumerable<ServiceEndpointInfo> GetServiceEndpointsByType(string serviceType);
ServiceEndpointInfo GetService(string serviceKey, string endpoint);

@ -18,9 +18,11 @@ namespace ZeroLevel.Microservices
public MicroserviceInfo ServiceInfo { get; set; }
public ExService Server { get; set; }
}
private bool _disposed = false;
private readonly long _registerTaskKey = -1;
private readonly IDiscoveryClient _discoveryClient;
private readonly ConcurrentDictionary<string, MetaService> _services
= new ConcurrentDictionary<string, MetaService>();
@ -116,6 +118,7 @@ namespace ZeroLevel.Microservices
}
#region Private methods
private void ValidateService(IExchangeService service)
{
if (string.IsNullOrWhiteSpace(service.Protocol))
@ -127,6 +130,7 @@ namespace ZeroLevel.Microservices
throw new ArgumentNullException("Service.Key");
}
}
private void ValidateService(MicroserviceInfo service)
{
if (string.IsNullOrWhiteSpace(service.Protocol))
@ -218,9 +222,11 @@ namespace ZeroLevel.Microservices
_discoveryClient.Register(service);
}
}
#endregion
#endregion Private methods
#region Utils
private static Delegate CreateDelegate(MethodInfo methodInfo, object target)
{
Func<Type[], Type> getType;
@ -241,9 +247,11 @@ namespace ZeroLevel.Microservices
}
return Delegate.CreateDelegate(getType(types.ToArray()), target, methodInfo.Name);
}
#endregion
#endregion Utils
#region Inboxes
/// <summary>
/// Регистрация обработчика входящих сообщений
/// </summary>
@ -263,6 +271,7 @@ namespace ZeroLevel.Microservices
Log.SystemError(ex, $"[Exchange] Register inbox handler error. Protocol '{meta.ServiceInfo.Protocol}'. Inbox '{inbox}'. Service '{meta.ServiceInfo.ServiceKey}'");
}
}
/// <summary>
/// Регистрация метода отдающего ответ на входящий запрос
/// </summary>
@ -283,6 +292,7 @@ namespace ZeroLevel.Microservices
Log.SystemError(ex, $"[Exchange] Register inbox replier error. Protocol '{meta.ServiceInfo.Protocol}'. Inbox '{inbox}'. Service '{meta.ServiceInfo.ServiceKey}'");
}
}
/// <summary>
/// Регистрация метода отдающего ответ на входящий запрос, не принимающего входящих данных
/// </summary>
@ -302,9 +312,11 @@ namespace ZeroLevel.Microservices
Log.SystemError(ex, $"[Exchange] Register inbox replier error. Protocol '{meta.ServiceInfo.Protocol}'. Inbox '{inbox}'. Service '{meta.ServiceInfo.ServiceKey}'");
}
}
#endregion
#endregion Inboxes
#region Transport helpers
/// <summary>
/// Call service with round-robin balancing
/// </summary>
@ -503,7 +515,8 @@ namespace ZeroLevel.Microservices
}
}
}
#endregion
#endregion Transport helpers
public void Dispose()
{

@ -4,10 +4,8 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using ZeroLevel.Microservices.Contracts;
using ZeroLevel.Microservices.Model;
using ZeroLevel.Network.Microservices;
using ZeroLevel.Services.Network;
using ZeroLevel.Services.Serialization;
namespace ZeroLevel.Microservices
{
@ -21,12 +19,14 @@ namespace ZeroLevel.Microservices
private readonly ExServiceHost _host;
#region Ctor
public Exchange(IDiscoveryClient discoveryClient)
{
this._discoveryClient = discoveryClient ?? throw new ArgumentNullException(nameof(discoveryClient));
this._host = new ExServiceHost(this._discoveryClient);
}
#endregion
#endregion Ctor
/// <summary>
/// Регистрация сервиса
@ -42,6 +42,7 @@ namespace ZeroLevel.Microservices
}
#region Balanced send
/// <summary>
/// Отправка сообщения сервису
/// </summary>
@ -63,9 +64,11 @@ namespace ZeroLevel.Microservices
}
public bool Send<T>(string serviceKey, T data) => Send(serviceKey, ZBaseNetwork.DEFAULT_MESSAGE_INBOX, data);
#endregion
#endregion Balanced send
#region Balanced request
public Tresp Request<Treq, Tresp>(string serviceKey, string inbox, Treq data)
{
Tresp response = default(Tresp);
@ -157,9 +160,11 @@ namespace ZeroLevel.Microservices
public Tresp Request<Tresp>(string serviceKey) =>
Request<Tresp>(serviceKey, ZBaseNetwork.DEFAULT_REQUEST_INBOX);
#endregion
#endregion Balanced request
#region Direct request
public Tresp RequestDirect<Treq, Tresp>(string endpoint, string serviceKey, string inbox, Treq data)
{
Tresp response = default(Tresp);
@ -251,9 +256,11 @@ namespace ZeroLevel.Microservices
public Tresp RequestDirect<Tresp>(string endpoint, string serviceKey) =>
RequestDirect<Tresp>(endpoint, serviceKey, ZBaseNetwork.DEFAULT_REQUEST_INBOX);
#endregion
#endregion Direct request
#region Broadcast
/// <summary>
/// Отправка сообщения всем сервисам с указанным ключом в указанный обработчик
/// </summary>
@ -287,6 +294,7 @@ namespace ZeroLevel.Microservices
}
return false;
}
/// <summary>
/// Отправка сообщения всем сервисам с указанным ключом, в обработчик по умолчанию
/// </summary>
@ -295,6 +303,7 @@ namespace ZeroLevel.Microservices
/// <param name="data">Сообщение</param>
/// <returns>true - при успешной отправке</returns>
public bool SendBroadcast<T>(string serviceKey, T data) => SendBroadcast(serviceKey, ZBaseNetwork.DEFAULT_MESSAGE_INBOX, data);
/// <summary>
/// Отправка сообщения всем сервисам конкретного типа в указанный обработчик
/// </summary>
@ -328,6 +337,7 @@ namespace ZeroLevel.Microservices
}
return false;
}
/// <summary>
/// Отправка сообщения всем сервисам конкретного типа, в обработчик по умолчанию
/// </summary>
@ -337,6 +347,7 @@ namespace ZeroLevel.Microservices
/// <returns>true - при успешной отправке</returns>
public bool SendBroadcastByType<T>(string serviceType, T data) =>
SendBroadcastByType(serviceType, ZBaseNetwork.DEFAULT_MESSAGE_INBOX, data);
/// <summary>
/// Отправка сообщения всем сервисам конкретной группы в указанный обработчик
/// </summary>
@ -370,6 +381,7 @@ namespace ZeroLevel.Microservices
}
return false;
}
/// <summary>
/// Отправка сообщения всем сервисам конкретной группы, в обработчик по умолчанию
/// </summary>
@ -379,6 +391,7 @@ namespace ZeroLevel.Microservices
/// <returns>true - при успешной отправке</returns>
public bool SendBroadcastByGroup<T>(string serviceGroup, T data) =>
SendBroadcastByGroup(serviceGroup, ZBaseNetwork.DEFAULT_MESSAGE_INBOX, data);
/// <summary>
/// Широковещательный опрос сервисов по ключу
/// </summary>
@ -402,6 +415,7 @@ namespace ZeroLevel.Microservices
}
return Enumerable.Empty<Tresp>();
}
/// <summary>
/// Широковещательный опрос сервисов по ключу, без сообщеня запроса
/// </summary>
@ -423,6 +437,7 @@ namespace ZeroLevel.Microservices
}
return Enumerable.Empty<Tresp>();
}
/// <summary>
/// Широковещательный опрос сервисов по ключу, в обработчик по умолчанию
/// </summary>
@ -434,6 +449,7 @@ namespace ZeroLevel.Microservices
/// <returns>true - в случае успешной рассылки</returns>
public IEnumerable<Tresp> RequestBroadcast<Treq, Tresp>(string serviceKey, Treq data) =>
RequestBroadcast<Treq, Tresp>(serviceKey, ZBaseNetwork.DEFAULT_REQUEST_INBOX, data);
/// <summary>
/// Широковещательный опрос сервисов по ключу, без сообщеня запроса, в обработчик по умолчанию
/// </summary>
@ -443,6 +459,7 @@ namespace ZeroLevel.Microservices
/// <returns>true - в случае успешной рассылки</returns>
public IEnumerable<Tresp> RequestBroadcast<Tresp>(string serviceKey) =>
RequestBroadcast<Tresp>(serviceKey, ZBaseNetwork.DEFAULT_REQUEST_INBOX);
/// <summary>
/// Широковещательный опрос сервисов по типу сервису
/// </summary>
@ -466,6 +483,7 @@ namespace ZeroLevel.Microservices
}
return Enumerable.Empty<Tresp>();
}
/// <summary>
/// Широковещательный опрос сервисов по типу сервису, без сообщеня запроса
/// </summary>
@ -487,6 +505,7 @@ namespace ZeroLevel.Microservices
}
return Enumerable.Empty<Tresp>();
}
/// <summary>
/// Широковещательный опрос сервисов по типу сервису, в обработчик по умолчанию
/// </summary>
@ -498,6 +517,7 @@ namespace ZeroLevel.Microservices
/// <returns>true - в случае успешной рассылки</returns>
public IEnumerable<Tresp> RequestBroadcastByType<Treq, Tresp>(string serviceType, Treq data) =>
RequestBroadcastByType<Treq, Tresp>(serviceType, ZBaseNetwork.DEFAULT_REQUEST_INBOX, data);
/// <summary>
/// Широковещательный опрос сервисов по типу, без сообщеня запроса, в обработчик по умолчанию
/// </summary>
@ -507,6 +527,7 @@ namespace ZeroLevel.Microservices
/// <returns>true - в случае успешной рассылки</returns>
public IEnumerable<Tresp> RequestBroadcastByType<Tresp>(string serviceType) =>
RequestBroadcastByType<Tresp>(serviceType, ZBaseNetwork.DEFAULT_REQUEST_INBOX);
/// <summary>
/// Широковещательный опрос сервисов по группе сервисов
/// </summary>
@ -530,6 +551,7 @@ namespace ZeroLevel.Microservices
}
return Enumerable.Empty<Tresp>();
}
/// <summary>
/// Широковещательный опрос сервисов по группе сервисов, без сообщения запроса
/// </summary>
@ -551,6 +573,7 @@ namespace ZeroLevel.Microservices
}
return Enumerable.Empty<Tresp>();
}
/// <summary>
/// Широковещательный опрос сервисов по группе сервисов в обработчик по умолчанию
/// </summary>
@ -562,6 +585,7 @@ namespace ZeroLevel.Microservices
/// <returns>true - в случае успешной рассылки</returns>
public IEnumerable<Tresp> RequestBroadcastByGroup<Treq, Tresp>(string serviceGroup, Treq data) =>
RequestBroadcastByGroup<Treq, Tresp>(serviceGroup, ZBaseNetwork.DEFAULT_REQUEST_INBOX, data);
/// <summary>
/// Широковещательный опрос сервисов по группе сервисов, без сообщения запроса, в обработчик по умолчанию
/// </summary>
@ -573,6 +597,7 @@ namespace ZeroLevel.Microservices
RequestBroadcastByGroup<Tresp>(serviceGroup, ZBaseNetwork.DEFAULT_REQUEST_INBOX);
#region Private
private IEnumerable<Tresp> _RequestBroadcast<Treq, Tresp>(List<IExClient> clients, string inbox, Treq data)
{
var response = new List<Tresp>();
@ -628,9 +653,10 @@ namespace ZeroLevel.Microservices
}
return response;
}
#endregion
#endregion
#endregion Private
#endregion Broadcast
public void Dispose()
{

@ -19,6 +19,7 @@ namespace ZeroLevel.Microservices.Model
public byte[] Payload { get; set; }
#region IBinarySerializable
public void Deserialize(IBinaryReader reader)
{
this.Id = reader.ReadGuid();
@ -40,19 +41,23 @@ namespace ZeroLevel.Microservices.Model
writer.WriteInt32((int)this.CheckpointType);
writer.WriteBytes(this.Payload);
}
#endregion
#endregion IBinarySerializable
#region Ctors
public Checkpoint()
{
this.Id = Guid.NewGuid();
this.Timestamp = DateTime.Now.Ticks;
}
public Checkpoint(Guid id)
{
this.Timestamp = DateTime.Now.Ticks;
this.Id = id;
}
public Checkpoint(Checkpoint other)
{
this.Id = other.Id;
@ -63,9 +68,11 @@ namespace ZeroLevel.Microservices.Model
this.Payload = other.Payload;
this.ReasonPhrase = other.ReasonPhrase;
}
#endregion
#endregion Ctors
#region Equals & Hash
public override int GetHashCode()
{
return base.GetHashCode();
@ -75,16 +82,20 @@ namespace ZeroLevel.Microservices.Model
{
return this.Equals(obj as Checkpoint);
}
#endregion
#endregion Equals & Hash
#region ICloneable
public object Clone()
{
return new Checkpoint(this);
}
#endregion
#endregion ICloneable
#region IEquatable
public bool Equals(Checkpoint other)
{
if (this.Id != other.Id) return false;
@ -96,6 +107,7 @@ namespace ZeroLevel.Microservices.Model
if (false == ArrayExtensions.Equals(this.Payload, other.Payload)) return false;
return true;
}
#endregion
#endregion IEquatable
}
}

@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following

@ -15,6 +15,7 @@ namespace ZeroLevel.Microservices
BaseProxy, IDiscoveryClient
{
#region WebAPI
private IEnumerable<ServiceEndpointsInfo> GetRecords()
{
return GET<IEnumerable<ServiceEndpointsInfo>>("api/v0/routes");
@ -24,13 +25,16 @@ namespace ZeroLevel.Microservices
{
return POST<InvokeResult>("api/v0/routes", info);
}
#endregion
#endregion WebAPI
// Таблица по ключам
private readonly ConcurrentDictionary<string, RoundRobinCollection<ServiceEndpointInfo>> _tableByKey =
new ConcurrentDictionary<string, RoundRobinCollection<ServiceEndpointInfo>>();
private readonly ConcurrentDictionary<string, RoundRobinCollection<ServiceEndpointInfo>> _tableByGroups =
new ConcurrentDictionary<string, RoundRobinCollection<ServiceEndpointInfo>>();
private readonly ConcurrentDictionary<string, RoundRobinCollection<ServiceEndpointInfo>> _tableByTypes =
new ConcurrentDictionary<string, RoundRobinCollection<ServiceEndpointInfo>>();

@ -8,6 +8,7 @@ namespace ZeroLevel.Models
public abstract class BaseModel
{
#region Equal
public bool Equals(BaseModel other)
{
if (this == null)
@ -30,10 +31,13 @@ namespace ZeroLevel.Models
}
public static bool operator ==(BaseModel first, BaseModel second) => Equals(first, second);
public static bool operator !=(BaseModel first, BaseModel second) => !Equals(first, second);
#endregion
#endregion Equal
public abstract override int GetHashCode();
public abstract object Clone();
}
}

@ -17,32 +17,39 @@ namespace ZeroLevel.Models
/// Id
/// </summary>
public Guid Id { get; set; }
/// <summary>
/// File name
/// </summary>
public string FileName { get; set; }
/// <summary>
/// Content type (pdf, doc, etc.)
/// </summary>
public string ContentType { get; set; }
/// <summary>
/// Content
/// </summary>
public byte[] Document { get; set; }
/// <summary>
/// Creation date
/// </summary>
public DateTime Created { get; set; }
/// <summary>
/// Optional headers
/// </summary>
public List<Header> Headers { get; set; }
/// <summary>
/// Categories
/// </summary>
public List<Category> Categories { get; set; }
#region Ctors
public BinaryDocument()
{
Created = DateTime.Now;
@ -58,9 +65,11 @@ namespace ZeroLevel.Models
Deserialize(reader);
}
}
#endregion
#endregion Ctors
#region IBinarySerializable
public void Serialize(IBinaryWriter writer)
{
writer.WriteGuid(this.Id);
@ -82,9 +91,11 @@ namespace ZeroLevel.Models
this.Headers = reader.ReadCollection<Header>();
this.Categories = reader.ReadCollection<Category>();
}
#endregion
#endregion IBinarySerializable
#region Equals & Hash
public override bool Equals(object obj)
{
return this.Equals(obj as BinaryDocument);
@ -111,7 +122,8 @@ namespace ZeroLevel.Models
{
return Id.GetHashCode();
}
#endregion
#endregion Equals & Hash
public object Clone()
{

@ -12,10 +12,13 @@ namespace ZeroLevel.Models
IBinarySerializable
{
#region Static
private static readonly InvokeResult _successResultWitoutComment = new InvokeResult(true, String.Empty);
#endregion
#endregion Static
#region Ctor
public InvokeResult()
{
}
@ -25,35 +28,43 @@ namespace ZeroLevel.Models
Success = success;
Comment = comment;
}
#endregion
#endregion Ctor
#region Properties
/// <summary>
/// true when action successfully invoked
/// </summary>
[DataMember]
public bool Success;
/// <summary>
/// Comment
/// </summary>
[DataMember]
public string Comment;
#endregion
#endregion Properties
#region Fabric methods
/// <summary>
/// Error when action invoking
/// </summary>
public static InvokeResult Fault(string comment) { return new InvokeResult(false, comment); }
/// <summary>
/// Successfully
/// </summary>
public static InvokeResult Succeeding(string comment = "") { return new InvokeResult(true, comment); }
/// <summary>
/// Successfully
/// </summary>
public static InvokeResult Succeeding() { return _successResultWitoutComment; }
#endregion
#endregion Fabric methods
public virtual void Serialize(IBinaryWriter writer)
{
@ -75,6 +86,7 @@ namespace ZeroLevel.Models
public T Value { get { return _value; } }
#region Ctor
public InvokeResult(bool success, string comment)
{
Success = success;
@ -87,12 +99,22 @@ namespace ZeroLevel.Models
Success = success;
Comment = comment;
}
#endregion
#endregion Ctor
#region Fabric methods
public static InvokeResult<T> Succeeding(T value, string comment = "") { return new InvokeResult<T>(value, true, comment); }
public static InvokeResult<T> Fault<T>(string comment) { return new InvokeResult<T>(false, comment); }
#endregion
public static InvokeResult<T> Succeeding(T value, string comment = "")
{
return new InvokeResult<T>(value, true, comment);
}
public static InvokeResult<T> Fault<T>(string comment)
{
return new InvokeResult<T>(false, comment);
}
#endregion Fabric methods
public override void Serialize(IBinaryWriter writer)
{

@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following

@ -22,7 +22,6 @@ namespace ZeroLevel.Services.Applications
public ZeroServiceState State => _state;
private ZeroServiceState _state;
private ManualResetEvent InteraciveModeWorkingFlag = new ManualResetEvent(false);
public void InteractiveStart(string[] args)
@ -35,13 +34,19 @@ namespace ZeroLevel.Services.Applications
}
#region IZeroService
public abstract void StartAction();
public abstract void StopAction();
public abstract void PauseAction();
public abstract void ResumeAction();
#endregion
#endregion IZeroService
#region Windows service
protected override void OnStart(string[] args)
{
if (_state == ZeroServiceState.Initialized)
@ -116,6 +121,7 @@ namespace ZeroLevel.Services.Applications
}
}
}
#endregion
#endregion Windows service
}
}

@ -57,6 +57,7 @@ namespace ZeroLevel
Log.Fatal(ex, "[Bootstrap] Fault service install");
}
}
/// <summary>
/// Uninstall from windows services
/// </summary>

@ -5,8 +5,11 @@
ZeroServiceState State { get; }
void StartAction();
void StopAction();
void PauseAction();
void ResumeAction();
void InteractiveStart(string[] args);

@ -179,6 +179,7 @@ namespace ZeroLevel.Services.Async
public IAsyncWaitQueue<object> WaitQueue { get { return _cv._queue; } }
}
// ReSharper restore UnusedMember.Local
}
}

@ -186,6 +186,7 @@ namespace ZeroLevel.Services.Async
public IAsyncWaitQueue<IDisposable> WaitQueue { get { return _mutex._queue; } }
}
// ReSharper restore UnusedMember.Local
}
}

@ -154,6 +154,7 @@ namespace ZeroLevel.Services.Async
public Task CurrentTask { get { return _mre._tcs.Task; } }
}
// ReSharper restore UnusedMember.Local
}
}

@ -82,6 +82,7 @@ namespace ZeroLevel.Services.Async
[DebuggerNonUserCode]
internal int GetReaderCountForDebugger { get { return (_locksHeld > 0 ? _locksHeld : 0); } }
[DebuggerNonUserCode]
internal bool GetUpgradeInProgressForDebugger { get { return !_upgradeReaderQueue.IsEmpty; } }
@ -764,6 +765,7 @@ namespace ZeroLevel.Services.Async
public IAsyncWaitQueue<IDisposable> UpgradeReaderWaitQueue { get { return _rwl._upgradeReaderQueue; } }
}
// ReSharper restore UnusedMember.Local
}
}

@ -172,6 +172,7 @@ namespace ZeroLevel.Services.Async
public IAsyncWaitQueue<object> WaitQueue { get { return _semaphore._queue; } }
}
// ReSharper restore UnusedMember.Local
}
}

@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

@ -248,7 +248,8 @@ namespace ZeroLevel.Services.Async
return this.GetEnumerator();
}
#endregion
#endregion GenericListImplementations
#region ObjectListImplementations
int System.Collections.IList.Add(object value)
@ -329,7 +330,8 @@ namespace ZeroLevel.Services.Async
get { return this; }
}
#endregion
#endregion ObjectListImplementations
#region GenericListHelpers
/// <summary>
@ -386,7 +388,7 @@ namespace ZeroLevel.Services.Async
}
}
#endregion
#endregion GenericListHelpers
/// <summary>
/// Gets a value indicating whether this instance is empty.

@ -15,6 +15,7 @@ namespace ZeroLevel.Services.Async
/// </summary>
// ReSharper disable StaticFieldInGenericType
private static int _lastId;
// ReSharper restore StaticFieldInGenericType
/// <summary>

@ -75,6 +75,7 @@ namespace ZeroLevel.Services.Async
}
return @this.TrySetResult(resultFunc());
}
/// <summary>
/// Attempts to complete a <see cref="TaskCompletionSource{TResult}"/>, propagating the completion of <paramref name="eventArgs"/>.
/// </summary>
@ -91,6 +92,7 @@ namespace ZeroLevel.Services.Async
return @this.TrySetException(eventArgs.Error);
return @this.TrySetResult(getResult());
}
/// <summary>
/// Attempts to complete a <see cref="TaskCompletionSource"/>, propagating the completion of <paramref name="task"/>.
/// </summary>
@ -105,6 +107,7 @@ namespace ZeroLevel.Services.Async
return @this.TrySetCanceled();
return @this.TrySetResult();
}
/// <summary>
/// Attempts to complete a <see cref="TaskCompletionSource"/>, propagating the completion of <paramref name="eventArgs"/>.
/// </summary>
@ -119,6 +122,7 @@ namespace ZeroLevel.Services.Async
return @this.TrySetException(eventArgs.Error);
return @this.TrySetResult();
}
/// <summary>
/// Attempts to complete a <see cref="TaskCompletionSource{TResult}"/> with the specified value, forcing all continuations onto a threadpool thread even if they specified <c>ExecuteSynchronously</c>.
/// </summary>
@ -166,6 +170,7 @@ namespace ZeroLevel.Services.Async
{
}
}
/// <summary>
/// Creates a new TCS for use with async code, and which forces its continuations to execute asynchronously.
/// </summary>
@ -174,6 +179,7 @@ namespace ZeroLevel.Services.Async
{
return new TaskCompletionSource<TResult>(TaskCreationOptions.RunContinuationsAsynchronously);
}
/// <summary>
/// Attempts to complete a <see cref="TaskCompletionSource"/> as canceled, forcing all continuations onto a threadpool thread even if they specified <c>ExecuteSynchronously</c>.
/// </summary>

@ -54,6 +54,7 @@ namespace ZeroLevel.Services.Async
using (var cancelTaskSource = new CancellationTokenTaskSource<TResult>(cancellationToken))
return await await Task.WhenAny(task, cancelTaskSource.Task).ConfigureAwait(false);
}
/// <summary>
/// Waits for the task to complete, unwrapping any exceptions.
/// </summary>

@ -68,6 +68,7 @@ namespace ZeroLevel.Services.Collections
return (T)_getter.Invoke(_instance, key);
}
}
private readonly ConcurrentDictionary<Type, ConcreteTypeRepository> _shardedRepositories =
new ConcurrentDictionary<Type, ConcreteTypeRepository>();

@ -22,6 +22,7 @@ namespace ZeroLevel.Services.Collections
_nextIndex = 0;
_count = 0;
}
/// <summary>
/// If count is limited when intem adding, oldest item replace with new item
/// </summary>

@ -3,11 +3,17 @@
public interface IEverythingStorage
{
bool TryAdd<T>(string key, T value);
bool ContainsKey<T>(string key);
bool TryRemove<T>(string key);
void Add<T>(string key, T value);
void AddOrUpdate<T>(string key, T value);
void Remove<T>(string key);
T Get<T>(string key);
}
}

@ -5,10 +5,15 @@ namespace ZeroLevel.Services.Collections
public interface IFixSizeQueue<T>
{
void Push(T item);
long Count { get; }
bool TryTake(out T t);
T Take();
IEnumerable<T> Dump();
bool Contains(T item, IComparer<T> comparer = null);
}
}

@ -15,7 +15,9 @@ namespace ZeroLevel.Services.Collections
{
private readonly List<T> _collection =
new List<T>();
private int _index = -1;
private readonly ReaderWriterLockSlim _lock =
new ReaderWriterLockSlim();

@ -14,19 +14,24 @@ namespace ZeroLevel.Services.Config
IConfiguration
{
#region Private members
/// <summary>
/// When true, any changes disallow
/// </summary>
private bool _freezed = false;
/// <summary>
/// When true, freeze permanent, can't be canceled
/// </summary>
private bool _permanentFreezed = false;
private readonly object _freezeLock = new object();
/// <summary>
/// Key-values dictionary
/// </summary>
private readonly ConcurrentDictionary<string, IList<string>> _keyValues = new ConcurrentDictionary<string, IList<string>>();
/// <summary>
/// Empty list
/// </summary>
@ -40,9 +45,11 @@ namespace ZeroLevel.Services.Config
}
return key.Trim().ToLower(CultureInfo.InvariantCulture);
}
#endregion
#endregion Private members
#region Properties
/// <summary>
/// Get values by key
/// </summary>
@ -61,6 +68,7 @@ namespace ZeroLevel.Services.Config
return EmptyValuesList;
}
}
/// <summary>
/// Keys list
/// </summary>
@ -76,11 +84,13 @@ namespace ZeroLevel.Services.Config
return _freezed;
}
}
#endregion
#endregion Properties
#region Public methods
#region Get
/// <summary>
/// Получение списка значение соотвествующих указанному ключу
/// </summary>
@ -90,6 +100,7 @@ namespace ZeroLevel.Services.Config
{
return this[key];
}
/// <summary>
/// Получение первого значения для указанного ключа
/// </summary>
@ -140,6 +151,7 @@ namespace ZeroLevel.Services.Config
}
throw new KeyNotFoundException("Parameter not found: " + key);
}
/// <summary>
/// Получение первого значения для указанного ключа, или значения по умолчанию
/// </summary>
@ -156,6 +168,7 @@ namespace ZeroLevel.Services.Config
}
return defaultValue;
}
/// <summary>
/// Получение первого значения для указанного ключа, или значения по умолчанию, с попыткой преобразования в указанный тип
/// </summary>
@ -172,6 +185,7 @@ namespace ZeroLevel.Services.Config
}
return default(T);
}
/// <summary>
/// Получение первого значения для указанного ключа, или значения по умолчанию, с попыткой преобразования в указанный тип
/// </summary>
@ -189,6 +203,7 @@ namespace ZeroLevel.Services.Config
}
return defaultValue;
}
/// <summary>
/// Проверка наличия ключа и непустого списка связанных с ним значений
/// </summary>
@ -199,6 +214,7 @@ namespace ZeroLevel.Services.Config
key = GetKey(key);
return _keyValues.ContainsKey(key) && _keyValues[key].Count > 0;
}
/// <summary>
/// Проверка наличия одного из ключей
/// </summary>
@ -208,6 +224,7 @@ namespace ZeroLevel.Services.Config
if (Contains(key)) return true;
return false;
}
/// <summary>
/// Проверка наличия ключа и связанного с ним значения
/// </summary>
@ -223,6 +240,7 @@ namespace ZeroLevel.Services.Config
}
return false;
}
/// <summary>
/// Количество значений связанных с указанным ключом
/// </summary>
@ -237,7 +255,8 @@ namespace ZeroLevel.Services.Config
}
return 0;
}
#endregion
#endregion Get
/// <summary>
/// Add key-value
@ -257,6 +276,7 @@ namespace ZeroLevel.Services.Config
}
return this;
}
/// <summary>
/// Set unique value for key
/// </summary>
@ -277,6 +297,7 @@ namespace ZeroLevel.Services.Config
}
return this;
}
/// <summary>
/// Clean values binded with key
/// </summary>
@ -293,6 +314,7 @@ namespace ZeroLevel.Services.Config
}
return this;
}
/// <summary>
/// Configuration drop
/// </summary>
@ -304,6 +326,7 @@ namespace ZeroLevel.Services.Config
}
return this;
}
/// <summary>
/// Remove key and binded values
/// </summary>
@ -349,9 +372,11 @@ namespace ZeroLevel.Services.Config
return false;
}
}
#endregion
#endregion Public methods
#region IEquatable
public bool Equals(IConfiguration other)
{
if (other == null)
@ -371,9 +396,11 @@ namespace ZeroLevel.Services.Config
}
return true;
}
#endregion
#endregion IEquatable
#region Binary Serializable
public void Serialize(IBinaryWriter writer)
{
writer.WriteBoolean(this._freezed);
@ -408,6 +435,7 @@ namespace ZeroLevel.Services.Config
_keyValues.TryAdd(key, list_values);
}
}
#endregion
#endregion Binary Serializable
}
}

@ -13,6 +13,7 @@ namespace ZeroLevel.Services.Config
IConfigurationSet
{
#region Private members
/// <summary>
/// Sections
/// </summary>
@ -26,9 +27,11 @@ namespace ZeroLevel.Services.Config
}
return key.Trim().ToLower(CultureInfo.InvariantCulture);
}
#endregion
#endregion Private members
#region Properties
public IConfiguration Default
{
get { return _sections[Configuration.DEFAULT_SECTION_NAME]; }
@ -60,9 +63,10 @@ namespace ZeroLevel.Services.Config
}
}
#endregion
#endregion Properties
#region Methods
public BaseConfigurationSet()
{
CreateSection(Configuration.DEFAULT_SECTION_NAME);
@ -119,18 +123,22 @@ namespace ZeroLevel.Services.Config
}
return false;
}
#endregion
#endregion Methods
#region IEquatable
public bool Equals(IConfigurationSet other)
{
if (other == null) return false;
return this.SectionNames.NoOrderingEquals(other.SectionNames) &&
this.Sections.NoOrderingEquals(other.Sections);
}
#endregion
#endregion IEquatable
#region Freezing
private readonly object _freezeLock = new object();
public bool FreezeConfiguration(bool permanent = false)
@ -193,9 +201,11 @@ namespace ZeroLevel.Services.Config
return false;
}
}
#endregion
#endregion Freezing
#region Binary Serializable
public void Serialize(IBinaryWriter writer)
{
writer.WriteBoolean(this._sectionsFreezed);
@ -220,6 +230,7 @@ namespace ZeroLevel.Services.Config
_sections.TryAdd(key, reader.Read<BaseConfiguration>());
}
}
#endregion
#endregion Binary Serializable
}
}

@ -23,6 +23,7 @@ namespace ZeroLevel
public const string DEFAULT_SECTION_NAME = "_defaultsection";
#region Ctor
static Configuration()
{
_empty = new BaseConfiguration();
@ -30,9 +31,11 @@ namespace ZeroLevel
_empty.Freeze(true);
_emptySet.FreezeConfiguration(true);
}
#endregion
#endregion Ctor
#region Cachee
private static readonly IConfiguration _empty;
private static readonly IConfigurationSet _emptySet;
private static readonly ConcurrentDictionary<string, IConfiguration> _cachee = new ConcurrentDictionary<string, IConfiguration>();
@ -97,9 +100,11 @@ namespace ZeroLevel
}
return result;
}
#endregion
#endregion Cachee
#region Factory
public static IConfiguration Create()
{
return new BaseConfiguration();
@ -114,41 +119,49 @@ namespace ZeroLevel
{
return new BaseConfigurationSet(defaultConfiguration);
}
#endregion
#endregion Factory
#region Read configuration
/// <summary>
/// Создание конфигурации из секции AppSettings файла app.config или web.config
/// </summary>
/// <returns>Конфигурация</returns>
public static IConfiguration ReadFromApplicationConfig() { return new ApplicationConfigReader().ReadConfiguration(); }
/// <summary>
/// Создание конфигурации из секции AppSettings файла app.config или web.config, дополняется секцией 'ConnectionStrings'
/// </summary>
/// <returns>Конфигурация</returns>
public static IConfigurationSet ReadSetFromApplicationConfig() { return new ApplicationConfigReader().ReadConfigurationSet(); }
/// <summary>
/// Создание конфигурации из секции AppSettings файла app.config или web.config
/// </summary>
/// <returns>Конфигурация</returns>
public static IConfiguration ReadFromApplicationConfig(string configFilePath) { return new ApplicationConfigReader(configFilePath).ReadConfiguration(); }
/// <summary>
/// Создание конфигурации из секции AppSettings файла app.config или web.config, дополняется секцией 'ConnectionStrings'
/// </summary>
/// <returns>Конфигурация</returns>
public static IConfigurationSet ReadSetFromApplicationConfig(string configFilePath) { return new ApplicationConfigReader(configFilePath).ReadConfigurationSet(); }
/// <summary>
/// Создание конфигурации из ini файла
/// </summary>
/// <param name="path">Путь к ini-файлу</param>
/// <returns>Конфигурация</returns>
public static IConfiguration ReadFromIniFile(string path) { return new IniFileReader(path).ReadConfiguration(); }
/// <summary>
/// Создание конфигурации из ini файла, с учетом секций
/// </summary>
/// <param name="path">Путь к ini-файлу</param>
/// <returns>Конфигурация</returns>
public static IConfigurationSet ReadSetFromIniFile(string path) { return new IniFileReader(path).ReadConfigurationSet(); }
/// <summary>
/// Создание конфигурации из параметров командной строки
/// </summary>
@ -156,22 +169,29 @@ namespace ZeroLevel
/// <returns>Конфигурация</returns>
public static IConfiguration ReadFromCommandLine(string[] args) { return new CommandLineReader(args).ReadConfiguration(); }
public static IConfigurationSet ReadBinary(IBinaryReader reader) { return reader.Read<BaseConfigurationSet>(); }
#endregion
public static IConfigurationSet ReadBinary(IBinaryReader reader)
{
return reader.Read<BaseConfigurationSet>();
}
#endregion Read configuration
#region Write configuration
/// <summary>
/// Запись простой конфигурации в ini-файл
/// </summary>
/// <param name="configuration">Конфигурация</param>
/// <param name="path">Путь к ini-файлу</param>
public static void WriteToIniFile(IConfiguration configuration, string path) { new IniFileWriter(path).WriteConfiguration(configuration); }
/// <summary>
/// Запись полной конфигурации в ini-файл
/// </summary>
/// <param name="configuration">Конфигурация</param>
/// <param name="path">Путь к ini-файлу</param>
public static void WriteSetToIniFile(IConfigurationSet configuration, string path) { new IniFileWriter(path).WriteConfigurationSet(configuration); }
#endregion
#endregion Write configuration
}
}

@ -12,103 +12,128 @@ namespace ZeroLevel
IBinarySerializable
{
#region Properties
/// <summary>
/// Get values by key
/// </summary>
IEnumerable<string> this[string key] { get; }
/// <summary>
/// Keys
/// </summary>
IEnumerable<string> Keys { get; }
/// <summary>
/// Configuration is locked for change when true
/// </summary>
bool Freezed { get; }
#endregion
#endregion Properties
#region Methods
/// <summary>
/// Get values by key
/// </summary>
/// <param name="key">Key</param>
/// <returns>Values list</returns>
IEnumerable<string> Items(string key);
/// <summary>
/// Get first value by key
/// </summary>
string First(string key);
/// <summary>
/// Get first value by key with cast to <typeparamref name="T"/>
/// </summary>
T First<T>(string key);
/// <summary>
/// Get first or default value by key
/// </summary>
string FirstOrDefault(string name, string defaultValue);
/// <summary>
/// Get first or default value by key with cast to <typeparamref name="T"/>
/// </summary>
T FirstOrDefault<T>(string name);
/// <summary>
/// Get first or default value by key with cast to <typeparamref name="T"/>
/// </summary>
T FirstOrDefault<T>(string name, T defaultValue);
/// <summary>
/// Check key exists
/// </summary>
bool Contains(string key);
/// <summary>
/// Check one of key exists
/// </summary>
bool Contains(params string[] keys);
/// <summary>
/// true if exists one or more values by key
/// </summary>
bool ContainsValue(string key, string value);
/// <summary>
/// Count values by key
/// </summary>
int Count(string key);
/// <summary>
/// Do action if key exists, action takes first value
/// </summary>
void DoWithFirst(string key, Action<string> action);
/// <summary>
/// Do action if key exists, action takes first value with cast to <typeparamref name="T"/>
/// </summary>
void DoWithFirst<T>(string key, Action<T> action);
#endregion
#endregion Methods
#region Create, Clean, Delete
/// <summary>
/// Clean
/// </summary>
IConfiguration Clear();
/// <summary>
/// Clean values by key
/// </summary>
IConfiguration Clear(string key);
/// <summary>
/// Remove key and binded values
/// </summary>
IConfiguration Remove(string key);
/// <summary>
/// Append key and value
/// </summary>
IConfiguration Append(string key, string value);
/// <summary>
/// Set key with one value, if any values by key exists, they will be dropped
/// </summary>
IConfiguration SetUnique(string key, string value);
/// <summary>
/// Sets a prohibition on changing
/// </summary>
/// <returns>false - prohibition was set already</returns>
bool Freeze(bool permanent = false);
/// <summary>
/// Remove a prohibition on changing
/// </summary>
bool Unfreeze();
#endregion
#endregion Create, Clean, Delete
}
}

@ -3,6 +3,7 @@
public interface IConfigurationReader
{
IConfiguration ReadConfiguration();
IConfigurationSet ReadConfigurationSet();
}
}

@ -12,66 +12,81 @@ namespace ZeroLevel
IBinarySerializable
{
#region Properties
/// <summary>
/// Default section, always exists
/// </summary>
IConfiguration Default { get; }
/// <summary>
/// Get configuration section by name
/// </summary>
IConfiguration this[string sectionName] { get; }
/// <summary>
/// Get configuration section names
/// </summary>
IEnumerable<string> SectionNames { get; }
/// <summary>
/// Get all sections
/// </summary>
IEnumerable<IConfiguration> Sections { get; }
/// <summary>
/// true if changing disallow
/// </summary>
bool SectionsFreezed { get; }
#endregion
#endregion Properties
#region Methods
/// <summary>
/// Create section
/// </summary>
/// <param name="sectionName">Section name</param>
IConfiguration CreateSection(string sectionName);
/// <summary>
/// Get configuration section by name
/// </summary>
/// <param name="sectionName">Название секции</param>
/// <returns>Секция с данными</returns>
IConfiguration GetSection(string sectionName);
/// <summary>
/// Check for a section by name
/// </summary>
/// <param name="sectionName">Section name</param>
bool ContainsSection(string sectionName);
/// <summary>Remove section by name
/// </summary>
/// <param name="sectionName">Section name</param>
bool RemoveSection(string sectionName);
/// <summary>
/// Sets a prohibition on changing configurations
/// </summary>
bool FreezeConfiguration(bool permanent = false);
/// <summary>
/// Sets a prohibition on changing sections
/// </summary>
bool FreezeSections(bool permanent = false);
/// <summary>
/// Remove a prohibition on changing configurations
/// </summary>
/// <returns>false - если запрет снят</returns>
bool UnfreezeConfiguration();
/// <summary>
/// Sets a prohibition on changing sections
/// </summary>
bool UnfreezeSections();
#endregion
#endregion Methods
}
}

@ -3,6 +3,7 @@
public interface IConfigurationWriter
{
void WriteConfiguration(IConfiguration configuration);
void WriteConfigurationSet(IConfigurationSet configuration);
}
}

@ -5,8 +5,15 @@
{
private readonly AppWebConfigReader _reader;
internal ApplicationConfigReader() { _reader = new AppWebConfigReader(); }
internal ApplicationConfigReader(string configFilePath) { _reader = new AppWebConfigReader(configFilePath); }
internal ApplicationConfigReader()
{
_reader = new AppWebConfigReader();
}
internal ApplicationConfigReader(string configFilePath)
{
_reader = new AppWebConfigReader(configFilePath);
}
public IConfiguration ReadConfiguration()
{

@ -17,6 +17,7 @@ namespace ZeroLevel.Services.Config.Implementation
{
_iniPath = iniPath;
}
/// <summary>
/// Write config to file
/// </summary>
@ -41,6 +42,7 @@ namespace ZeroLevel.Services.Config.Implementation
writer.Flush();
}
}
/// <summary>
/// Write configuration set to file
/// </summary>

@ -6,41 +6,62 @@ namespace ZeroLevel.DocumentObjectModel
{
// Primitives
void ReadText(Text text);
void ReadQuote(Quote quote);
void ReadLink(Link link, int order);
void ReadImage(Image image, int order);
void ReadAudio(Audio audio, int order);
void ReadVideo(Video video, int order);
// Containers
void EnterSection(Section section);
void LeaveSection(Section section);
void EnterParagraph(Paragraph paragraph);
void LeaveParagraph(Paragraph paragraph);
void EnterList(List list);
void EnterListItem(List list, IContentElement item, int order);
void LeaveListItem(List list, IContentElement item, int order);
void LeaveList(List list);
void EnterTable(Table table);
void EnterColumns(Table table);
void ReadColumn(Table table, Column column, int order);
void LeaveColumns(Table table);
void EnterRow(Table table, Row row, int order);
void EnterRowCell(Table table, Row row, IContentElement cell, int order);
void LeaveRowCell(Table table, Row row, IContentElement cell, int order);
void LeaveRow(Table table, Row row, int order);
void LeaveTable(Table table);
void EnterGallery(Gallery gallery);
void LeaveGallery(Gallery gallery);
void EnterAudioplayer(Audioplayer player);
void LeaveAudioplayer(Audioplayer player);
void EnterVideoplayer(Videoplayer player);
void LeaveVideoplayer(Videoplayer player);
// Feature

@ -6,54 +6,91 @@ namespace ZeroLevel.DocumentObjectModel
public interface IMetadataReader<T>
{
void ReadId(Guid Id);
void ReadSummary(string summary);
void ReadHeader(string header);
void EnterIdentifier(Identifier identifier);
void ReadVersion(int version);
void ReadTimestamp(long timestamp);
void ReadDateLabel(string datelabel);
void LeaveIdentifier(Identifier identifier);
void EnterTagsBlock(TagMetadata tagBlock);
void EnterKeywords(IEnumerable<string> keywords);
void ReadKeyword(string keyword, int order);
void LeaveKeywords(IEnumerable<string> keywords);
void EnterPlaces(IEnumerable<Tag> places);
void ReadPlace(Tag place, int order);
void LeavePlaces(IEnumerable<Tag> places);
void EnterCompanies(IEnumerable<Tag> companies);
void ReadCompany(Tag company, int order);
void LeaveCompanies(IEnumerable<Tag> companies);
void EnterPersons(IEnumerable<Tag> persons);
void ReadPerson(Tag person, int order);
void LeavePersons(IEnumerable<Tag> persons);
void LeaveTagsBlock(TagMetadata tagBlock);
void EnterDescriptioveBlock(DescriptiveMetadata metadata);
void ReadAuthors(string byline);
void ReadCopiright(string copyright);
void ReadCreated(DateTime created);
void ReadLanguage(string language);
void ReadPriority(Priority priority);
void ReadSource(Agency source);
void ReadPublisher(Agency publisher);
void ReadOriginal(Tag original);
void EnterHeaders(IEnumerable<Header> headers);
void ReadHeader(Header header, int order);
void LeaveHeaders(IEnumerable<Header> headers);
void LeaveDescriptioveBlock(DescriptiveMetadata metadata);
void EnterAsides(IEnumerable<AttachContent> asides);
void ReadAside(AttachContent aside, int order);
void LeaveAsides(IEnumerable<AttachContent> asides);
void EnterAssotiations(IEnumerable<Assotiation> assotiations);
void ReadAssotiation(Assotiation assotiation, int order);
void LeaveAssotiations(IEnumerable<Assotiation> assotiations);
void EnterCategories(IEnumerable<Category> categories);
void ReadCategory(Category category, int order);
void LeaveCategories(IEnumerable<Category> categories);
T Complete();

@ -22,6 +22,7 @@ namespace DOM.DSL.Contexts
};
public TContext ParentContext { get; protected set; }
public abstract void Read(TStringReader reader);
}
}

@ -1,10 +1,10 @@
using System;
using System.Linq;
using DOM.DSL.Model;
using DOM.DSL.Services;
using DOM.DSL.Tokens;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DOM.DSL.Tokens;
using DOM.DSL.Services;
using DOM.DSL.Model;
namespace DOM.DSL.Contexts
{
@ -47,6 +47,7 @@ namespace DOM.DSL.Contexts
switch (reader.Current)
{
#region Ecsaping
case TChar.Escape:
{
switch (reader.Next)
@ -55,18 +56,22 @@ namespace DOM.DSL.Contexts
text.Append(' ');
reader.Move(2);
break;
case 'r':
text.Append(TChar.CaretReturn);
reader.Move(2);
break;
case 'n':
text.Append(TChar.Newline);
reader.Move(2);
break;
case 't':
text.Append(TChar.Tab);
reader.Move(2);
break;
case '@':
case '(':
case ')':
@ -76,6 +81,7 @@ namespace DOM.DSL.Contexts
text.Append(reader.Next);
reader.Move(2);
break;
default:
text.Append(reader.Current);
reader.Move();
@ -83,7 +89,8 @@ namespace DOM.DSL.Contexts
}
}
break;
#endregion
#endregion Ecsaping
case TChar.FuncArgsEnd:
{
@ -162,6 +169,7 @@ namespace DOM.DSL.Contexts
}
}
break;
default:
{
text.Append(reader.Current);

@ -69,6 +69,7 @@ namespace DOM.DSL.Contexts
switch (reader.Current)
{
#region Ecsaping
case TChar.Escape:
{
switch (reader.Next)
@ -77,18 +78,22 @@ namespace DOM.DSL.Contexts
text.Append(' ');
reader.Move(2);
break;
case 'r':
text.Append(TChar.CaretReturn);
reader.Move(2);
break;
case 'n':
text.Append(TChar.Newline);
reader.Move(2);
break;
case 't':
text.Append(TChar.Tab);
reader.Move(2);
break;
case '@':
case '(':
case ')':
@ -98,6 +103,7 @@ namespace DOM.DSL.Contexts
text.Append(reader.Next);
reader.Move(2);
break;
default:
text.Append(reader.Current);
reader.Move();
@ -105,7 +111,8 @@ namespace DOM.DSL.Contexts
}
}
break;
#endregion
#endregion Ecsaping
case TChar.PropertyIndexEnd:
{
@ -160,6 +167,7 @@ namespace DOM.DSL.Contexts
}
}
break;
default:
{
text.Append(reader.Current);

@ -40,6 +40,7 @@ namespace DOM.DSL.Contexts
switch (reader.Current)
{
#region Ecsaping
case TChar.Escape:
{
switch (reader.Next)
@ -48,18 +49,22 @@ namespace DOM.DSL.Contexts
text.Append(' ');
reader.Move(2);
break;
case 'r':
text.Append(TChar.CaretReturn);
reader.Move(2);
break;
case 'n':
text.Append(TChar.Newline);
reader.Move(2);
break;
case 't':
text.Append(TChar.Tab);
reader.Move(2);
break;
case '@':
case '(':
case ')':
@ -69,6 +74,7 @@ namespace DOM.DSL.Contexts
text.Append(reader.Next);
reader.Move(2);
break;
default:
text.Append(reader.Current);
reader.Move();
@ -76,7 +82,8 @@ namespace DOM.DSL.Contexts
}
}
break;
#endregion
#endregion Ecsaping
case TChar.TokenStart:
{
@ -122,11 +129,13 @@ namespace DOM.DSL.Contexts
}
}
break;
case TChar.CaretReturn:
case TChar.Newline:
case TChar.Tab:
reader.Move();
break;
default:
{
text.Append(reader.Current);

@ -9,12 +9,19 @@ namespace DOM.DSL.Contracts
/// Indicates that a table cell body entry is expected.
/// </summary>
bool WaitCellBody { get; }
void WriteToCell(string part);
void EnterTable(Column[] colunmns);
void EnterRow(int count_columns);
void EnterCell(int order);
void LeaveCell();
void LeaveRow();
void FlushTable(StringBuilder builder);
}
}

@ -25,23 +25,94 @@
public int GalleryId { get; private set; } = -1;
public int ImageId { get; private set; } = -1;
public void IncSectionId() { SectionId++; }
public void IncParagraphId() { ParagraphId++; }
public void IncListId() { ListId++; }
public void IncListItemId() { ListItemId++; }
public void IncTableId() { TableId++; }
public void IncColumnId() { ColumnId++; }
public void IncRowId() { RowId++; }
public void IncCellId() { CellId++; }
public void IncFormId() { FormId++; }
public void IncLinkId() { LinkId++; }
public void IncQuoteId() { QuoteId++; }
public void IncTextId() { TextId++; }
public void IncAudioplayerId() { AudioplayerId++; }
public void IncAudioId() { AudioId++; }
public void IncVideoplayerId() { VideoplayerId++; }
public void IncVideoId() { VideoId++; }
public void IncGalleryId() { GalleryId++; }
public void IncImageId() { ImageId++; }
public void IncSectionId()
{
SectionId++;
}
public void IncParagraphId()
{
ParagraphId++;
}
public void IncListId()
{
ListId++;
}
public void IncListItemId()
{
ListItemId++;
}
public void IncTableId()
{
TableId++;
}
public void IncColumnId()
{
ColumnId++;
}
public void IncRowId()
{
RowId++;
}
public void IncCellId()
{
CellId++;
}
public void IncFormId()
{
FormId++;
}
public void IncLinkId()
{
LinkId++;
}
public void IncQuoteId()
{
QuoteId++;
}
public void IncTextId()
{
TextId++;
}
public void IncAudioplayerId()
{
AudioplayerId++;
}
public void IncAudioId()
{
AudioId++;
}
public void IncVideoplayerId()
{
VideoplayerId++;
}
public void IncVideoId()
{
VideoId++;
}
public void IncGalleryId()
{
GalleryId++;
}
public void IncImageId()
{
ImageId++;
}
}
}

@ -31,6 +31,7 @@ namespace DOM.DSL.Model
TraversElement(item, type, handler);
}
break;
case ContentElementType.Paragraph:
var paragraph = (element as Paragraph);
foreach (var item in paragraph.Parts)
@ -38,6 +39,7 @@ namespace DOM.DSL.Model
TraversElement(item, type, handler);
}
break;
case ContentElementType.List:
var list = (element as List);
foreach (var item in list.Items)
@ -45,6 +47,7 @@ namespace DOM.DSL.Model
TraversElement(item, type, handler);
}
break;
case ContentElementType.Gallery:
var gallery = (element as Gallery);
foreach (var item in gallery.Images)
@ -52,6 +55,7 @@ namespace DOM.DSL.Model
TraversElement(item, type, handler);
}
break;
case ContentElementType.Audioplayer:
var audioplayer = (element as Audioplayer);
foreach (var item in audioplayer.Tracks)
@ -59,6 +63,7 @@ namespace DOM.DSL.Model
TraversElement(item, type, handler);
}
break;
case ContentElementType.Videoplayer:
var videoplayer = (element as Videoplayer);
foreach (var item in videoplayer.Playlist)
@ -66,6 +71,7 @@ namespace DOM.DSL.Model
TraversElement(item, type, handler);
}
break;
case ContentElementType.Table:
var table = (element as Table);
foreach (var column in table.Columns)
@ -90,34 +96,49 @@ namespace DOM.DSL.Model
{
case "section":
return ContentElementType.Section;
case "paragraph":
return ContentElementType.Paragraph;
case "link":
return ContentElementType.Link;
case "list":
return ContentElementType.List;
case "table":
return ContentElementType.Table;
case "audio":
return ContentElementType.Audio;
case "audioplayer":
return ContentElementType.Audioplayer;
case "form":
return ContentElementType.Form;
case "gallery":
return ContentElementType.Gallery;
case "image":
return ContentElementType.Image;
case "video":
return ContentElementType.Video;
case "videoplayer":
return ContentElementType.Videoplayer;
case "quote":
return ContentElementType.Quote;
case "text":
return ContentElementType.Text;
case "column":
return ContentElementType.Column;
case "row":
return ContentElementType.Row;
}
@ -131,7 +152,7 @@ namespace DOM.DSL.Model
var list = new List<IContentElement>();
foreach (var section in _document.Content.Sections)
{
TraversElement(section, type, e=>list.Add(e));
TraversElement(section, type, e => list.Add(e));
}
return list;
}

@ -7,6 +7,7 @@ namespace DOM.DSL.Model
internal sealed class TFlowRules
{
#region Rules
public TBlockToken ListPrefix;
public TBlockToken ListPostfix;
public TBlockToken ListItemPrefix;
@ -55,12 +56,15 @@ namespace DOM.DSL.Model
public TBlockToken VideoplayerPostfix;
public TBlockToken GalleryPrefix;
public TBlockToken GalleryPostfix;
#endregion
#endregion Rules
#region Special table builder
public bool UseSpecialTableBuilder = false;
public ISpecialTableBuilder SpecialTableBuilder;
#endregion
#endregion Special table builder
public void Bootstrap()
{
@ -124,187 +128,230 @@ namespace DOM.DSL.Model
case "prefix":
ListPrefix = rule_token;
break;
case "postfix":
ListPostfix = rule_token;
break;
case "ignore":
ListPostfix = ListPrefix = null;
break;
}
break;
case "listitem":
switch (functionName)
{
case "prefix":
ListItemPrefix = rule_token;
break;
case "postfix":
ListItemPostfix = rule_token;
break;
case "ignore":
ListItemPrefix = ListItemPostfix = null;
break;
}
break;
case "text":
switch (functionName)
{
case "prefix":
TextPrefix = rule_token;
break;
case "template":
TextTemplate = rule_token;
break;
case "postfix":
TextPostfix = rule_token;
break;
case "ignore":
TextPrefix = TextTemplate = TextPostfix = null;
break;
}
break;
case "link":
switch (functionName)
{
case "prefix":
LinkPrefix = rule_token;
break;
case "template":
LinkTemplate = rule_token;
break;
case "postfix":
LinkPostfix = rule_token;
break;
case "ignore":
LinkPrefix = LinkTemplate = LinkPostfix = null;
break;
}
break;
case "image":
switch (functionName)
{
case "prefix":
ImagePrefix = rule_token;
break;
case "template":
ImageTemplate = rule_token;
break;
case "postfix":
ImagePostfix = rule_token;
break;
case "ignore":
ImagePrefix = ImageTemplate = ImagePostfix = null;
break;
}
break;
case "quote":
switch (functionName)
{
case "prefix":
QuotePrefix = rule_token;
break;
case "template":
QuoteTemplate = rule_token;
break;
case "postfix":
QuotePostfix = rule_token;
break;
case "ignore":
QuotePrefix = QuoteTemplate = QuotePostfix = null;
break;
}
break;
case "form":
switch (functionName)
{
case "prefix":
FormPrefix = rule_token;
break;
case "template":
FormTemplate = rule_token;
break;
case "postfix":
FormPostfix = rule_token;
break;
case "ignore":
FormPrefix = FormTemplate = FormPostfix = null;
break;
}
break;
case "video":
switch (functionName)
{
case "prefix":
VideoPrefix = rule_token;
break;
case "template":
VideoTemplate = rule_token;
break;
case "postfix":
VideoPostfix = rule_token;
break;
case "ignore":
VideoPrefix = VideoTemplate = VideoPostfix = null;
break;
}
break;
case "audio":
switch (functionName)
{
case "prefix":
AudioPrefix = rule_token;
break;
case "template":
AudioTemplate = rule_token;
break;
case "postfix":
AudioPostfix = rule_token;
break;
case "ignore":
AudioPrefix = AudioTemplate = AudioPostfix = null;
break;
}
break;
case "section":
switch (functionName)
{
case "prefix":
SectionPrefix = rule_token;
break;
case "postfix":
SectionPostfix = rule_token;
break;
case "ignore":
SectionPrefix = SectionPostfix = null;
break;
}
break;
case "paragraph":
switch (functionName)
{
case "prefix":
ParagraphPrefix = rule_token;
break;
case "postfix":
ParagraphPostfix = rule_token;
break;
case "ignore":
ParagraphPrefix = ParagraphPostfix = null;
break;
}
break;
case "table":
switch (functionName)
{
case "prefix":
TablePrefix = rule_token;
break;
case "postfix":
TablePostfix = rule_token;
break;
case "ignore":
TablePrefix = TablePostfix = null;
break;
case "special": // Using a hardcoded table conversion
//TablePrefix = TablePostfix = null;
ColumnsPrefix = ColumnsPostfix = null;
@ -318,103 +365,124 @@ namespace DOM.DSL.Model
break;
}
break;
case "columns":
switch (functionName)
{
case "prefix":
ColumnsPrefix = rule_token;
break;
case "postfix":
ColumnsPostfix = rule_token;
break;
case "ignore":
ColumnsPrefix = ColumnsPostfix = null;
break;
}
break;
case "column":
switch (functionName)
{
case "prefix":
ColumnPrefix = rule_token;
break;
case "template":
ColumnTemplate = rule_token;
break;
case "postfix":
ColumnPostfix = rule_token;
break;
case "ignore":
ColumnPrefix = ColumnTemplate = ColumnPostfix = null;
break;
}
break;
case "tablerow":
switch (functionName)
{
case "prefix":
RowPrefix = rule_token;
break;
case "postfix":
RowPostfix = rule_token;
break;
case "ignore":
RowPrefix = RowPostfix = null;
break;
}
break;
case "tablecell":
switch (functionName)
{
case "prefix":
CellPrefix = rule_token;
break;
case "postfix":
CellPostfix = rule_token;
break;
case "ignore":
CellPrefix = CellPostfix = null;
break;
}
break;
case "videoplayer":
switch (functionName)
{
case "prefix":
VideoplayerPrefix = rule_token;
break;
case "postfix":
VideoplayerPostfix = rule_token;
break;
case "ignore":
VideoplayerPrefix = VideoplayerPostfix = null;
break;
}
break;
case "audioplayer":
switch (functionName)
{
case "prefix":
AudioplayerPrefix = rule_token;
break;
case "postfix":
AudioplayerPostfix = rule_token;
break;
case "ignore":
AudioplayerPrefix = AudioplayerPostfix = null;
break;
}
break;
case "gallery":
switch (functionName)
{
case "prefix":
GalleryPrefix = rule_token;
break;
case "postfix":
GalleryPostfix = rule_token;
break;
case "ignore":
GalleryPrefix = GalleryPostfix = null;
break;

@ -38,7 +38,7 @@ namespace DOM.DSL.Model
.Select(i => word.Substring(i * max, max)).
ToArray();
int k = 0;
if(current_max > 0) text.Append("\r\n");
if (current_max > 0) text.Append("\r\n");
for (; k < lines.Length - 1; k++)
{
text.Append(lines[k]);

@ -31,6 +31,7 @@ namespace DOM.DSL.Services
public int RowCellIndex = -1;
private StringBuilder _cellBody = new StringBuilder();
public void FlushCell()
{
if (RowCellIndex >= 0)
@ -51,6 +52,7 @@ namespace DOM.DSL.Services
return TextTableRender.Render(Data, options);
}
}
private readonly TextTableRenderOptions _options;
private Stack<TextTableMeta> _textTables = new Stack<TextTableMeta>();

File diff suppressed because it is too large Load Diff

@ -22,6 +22,7 @@ namespace DOM.DSL.Services
c.Reset(value);
return c;
}
internal TContainer Get(object value, int index)
{
Interlocked.Increment(ref _get_count);
@ -30,6 +31,7 @@ namespace DOM.DSL.Services
c.Index = index;
return c;
}
internal void Release(TContainer container)
{
if (container != null)
@ -40,6 +42,7 @@ namespace DOM.DSL.Services
}
public static int GetsCount() => _get_count;
public static int ReleasesCount() => _release_count;
}
}

@ -54,6 +54,7 @@ namespace DOM.DSL.Services
}
#region Primitives
public void ReadAudio(Audio audio, int order)
{
_render.Counter.IncAudioId();
@ -189,9 +190,11 @@ namespace DOM.DSL.Services
WriteText(Resolve(_transformRules.VideoPostfix, video, order));
}
}
#endregion
#endregion Primitives
#region Containers
public void EnterParagraph(Paragraph paragraph)
{
_render.Counter.IncParagraphId();
@ -200,6 +203,7 @@ namespace DOM.DSL.Services
WriteText(Resolve(_transformRules.ParagraphPrefix, paragraph, _render.Counter.ParagraphId));
}
}
public void LeaveParagraph(Paragraph paragraph)
{
if (_transformRules.ParagraphPostfix != null)
@ -207,6 +211,7 @@ namespace DOM.DSL.Services
WriteText(Resolve(_transformRules.ParagraphPostfix, paragraph, _render.Counter.ParagraphId));
}
}
public void EnterSection(Section section)
{
_render.Counter.IncSectionId();
@ -215,6 +220,7 @@ namespace DOM.DSL.Services
WriteText(Resolve(_transformRules.SectionPrefix, section, _render.Counter.SectionId));
}
}
public void LeaveSection(Section section)
{
if (_transformRules.SectionPostfix != null)
@ -222,9 +228,11 @@ namespace DOM.DSL.Services
WriteText(Resolve(_transformRules.SectionPostfix, section, _render.Counter.SectionId));
}
}
#endregion
#endregion Containers
#region Table
public void EnterTable(Table table)
{
_render.Counter.IncTableId();
@ -238,6 +246,7 @@ namespace DOM.DSL.Services
_specialTableBuilder.EnterTable(table.Columns.ToArray());
}
}
public void EnterColumns(Table table)
{
if (_useSpecialTableBuilder == false && _transformRules.ColumnsPrefix != null)
@ -245,6 +254,7 @@ namespace DOM.DSL.Services
_builder.Append(Resolve(_transformRules.ColumnsPrefix, table.Columns, 0));
}
}
public void EnterRow(Table table, Row row, int order)
{
_render.Counter.IncRowId();
@ -257,6 +267,7 @@ namespace DOM.DSL.Services
_builder.Append(Resolve(_transformRules.RowPrefix, row, order));
}
}
public void EnterRowCell(Table table, Row row, IContentElement cell, int order)
{
_render.Counter.IncCellId();
@ -276,6 +287,7 @@ namespace DOM.DSL.Services
}
}
}
public void LeaveColumns(Table table)
{
if (_useSpecialTableBuilder == false && _transformRules.ColumnsPostfix != null)
@ -283,6 +295,7 @@ namespace DOM.DSL.Services
_builder.Append(Resolve(_transformRules.ColumnsPostfix, table.Columns, 0));
}
}
public void LeaveRow(Table table, Row row, int order)
{
if (_useSpecialTableBuilder)
@ -294,6 +307,7 @@ namespace DOM.DSL.Services
_builder.Append(Resolve(_transformRules.RowPostfix, row, order));
}
}
public void LeaveRowCell(Table table, Row row, IContentElement cell, int order)
{
if (_useSpecialTableBuilder)
@ -312,6 +326,7 @@ namespace DOM.DSL.Services
}
}
}
public void LeaveTable(Table table)
{
if (_useSpecialTableBuilder)
@ -323,9 +338,11 @@ namespace DOM.DSL.Services
_builder.Append(Resolve(_transformRules.TablePostfix, table, _render.Counter.TableId));
}
}
#endregion
#endregion Table
#region List
public void EnterList(List list)
{
_render.Counter.IncListId();
@ -334,6 +351,7 @@ namespace DOM.DSL.Services
WriteText(Resolve(_transformRules.ListPrefix, list, 0));
}
}
public void EnterListItem(List list, IContentElement item, int order)
{
_render.Counter.IncListItemId();
@ -342,6 +360,7 @@ namespace DOM.DSL.Services
WriteText(Resolve(_transformRules.ListItemPrefix, item, order));
}
}
public void LeaveList(List list)
{
if (_transformRules.ListPostfix != null)
@ -349,6 +368,7 @@ namespace DOM.DSL.Services
WriteText(Resolve(_transformRules.ListPostfix, list, 0));
}
}
public void LeaveListItem(List list, IContentElement item, int order)
{
if (_transformRules.ListItemPostfix != null)
@ -356,9 +376,11 @@ namespace DOM.DSL.Services
WriteText(Resolve(_transformRules.ListItemPostfix, item, order));
}
}
#endregion
#endregion List
#region Media
public void EnterAudioplayer(Audioplayer player)
{
_render.Counter.IncAudioplayerId();
@ -367,6 +389,7 @@ namespace DOM.DSL.Services
WriteText(Resolve(_transformRules.AudioplayerPrefix, player, 0));
}
}
public void EnterGallery(Gallery gallery)
{
_render.Counter.IncGalleryId();
@ -375,6 +398,7 @@ namespace DOM.DSL.Services
WriteText(Resolve(_transformRules.GalleryPrefix, gallery, 0));
}
}
public void EnterVideoplayer(Videoplayer player)
{
_render.Counter.IncVideoplayerId();
@ -383,6 +407,7 @@ namespace DOM.DSL.Services
WriteText(Resolve(_transformRules.VideoplayerPrefix, player, 0));
}
}
public void LeaveAudioplayer(Audioplayer player)
{
if (_transformRules.AudioplayerPostfix != null)
@ -390,6 +415,7 @@ namespace DOM.DSL.Services
WriteText(Resolve(_transformRules.AudioplayerPostfix, player, 0));
}
}
public void LeaveGallery(Gallery gallery)
{
if (_transformRules.GalleryPostfix != null)
@ -397,6 +423,7 @@ namespace DOM.DSL.Services
WriteText(Resolve(_transformRules.GalleryPostfix, gallery, 0));
}
}
public void LeaveVideoplayer(Videoplayer player)
{
if (_transformRules.VideoplayerPostfix != null)
@ -404,6 +431,7 @@ namespace DOM.DSL.Services
WriteText(Resolve(_transformRules.VideoplayerPostfix, player, 0));
}
}
#endregion
#endregion Media
}
}

@ -238,6 +238,7 @@ namespace DOM.DSL.Services
}
}
break;
case "flow":
{
return new List<TContainer>
@ -356,6 +357,7 @@ namespace DOM.DSL.Services
Log.Debug(args[0].ToString(), args.Skip(1).ToArray());
}
break;
case "validate":
if (args?.Length == 1)
{
@ -364,15 +366,18 @@ namespace DOM.DSL.Services
case "xml":
Options.ValidateAsXml = true;
break;
case "html":
Options.ValidateAsHtml = true;
break;
case "json":
Options.ValidateAsJson = true;
break;
}
}
break;
case "fixwidth":
{
if (args?.Length == 1)

@ -10,6 +10,7 @@
/// Имя элемента
/// </summary>
public string ElementName;
/// <summary>
/// Optionally, next token
/// </summary>

@ -8,16 +8,23 @@ namespace DOM.DSL.Tokens
public abstract class TToken : TCloneable
{
public abstract TToken Clone();
/// <summary>
/// Copying token with set NextToken to null, to break cycle
/// </summary>
/// <returns></returns>
public abstract TToken CloneLocal();
public TElementToken AsElementToken() => this as TElementToken;
public TFunctionToken AsFunctionToken() => this as TFunctionToken;
public TTextToken AsTextToken() => this as TTextToken;
public TBlockToken AsBlockToken() => this as TBlockToken;
public TPropertyToken AsPropertyToken() => this as TPropertyToken;
public TSystemToken AsSystemToken() => this as TSystemToken;
}
}

@ -8,22 +8,43 @@ namespace ZeroLevel.DocumentObjectModel
/// Agency name
/// </summary>
public string Title;
/// <summary>
/// Agency website
/// </summary>
public string Url;
/// <summary>
/// Description
/// </summary>
public string Description;
public Agency() { }
public Agency(IBinaryReader reader) { Deserialize(reader); }
public Agency(string title) { this.Title = title; }
public Agency(string title, string url) { this.Title = title; this.Url = url; }
public Agency(string title, string url, string description) { this.Title = title; this.Url = url; this.Description = description; }
public Agency()
{
}
public Agency(IBinaryReader reader)
{
Deserialize(reader);
}
public Agency(string title)
{
this.Title = title;
}
public Agency(string title, string url)
{
this.Title = title; this.Url = url;
}
public Agency(string title, string url, string description)
{
this.Title = title; this.Url = url; this.Description = description;
}
#region IBinarySerializable
public void Serialize(IBinaryWriter writer)
{
writer.WriteString(this.Title);
@ -37,6 +58,7 @@ namespace ZeroLevel.DocumentObjectModel
this.Url = reader.ReadString();
this.Description = reader.ReadString();
}
#endregion
#endregion IBinarySerializable
}
}

@ -7,25 +7,31 @@ namespace ZeroLevel.DocumentObjectModel
IBinarySerializable
{
#region Fields
/// <summary>
/// Title
/// </summary>
public string Title;
/// <summary>
/// Description
/// </summary>
public string Description;
/// <summary>
/// Binded document reference
/// </summary>
public Guid DocumentId;
/// <summary>
/// Relation type
/// </summary>
public AssotiationRelation Relation;
#endregion
#endregion Fields
#region IBinarySerializable
public void Serialize(IBinaryWriter writer)
{
writer.WriteString(this.Title);
@ -41,6 +47,7 @@ namespace ZeroLevel.DocumentObjectModel
this.DocumentId = reader.ReadGuid();
this.Relation = (AssotiationRelation)reader.ReadInt32();
}
#endregion
#endregion IBinarySerializable
}
}

@ -8,18 +8,22 @@ namespace ZeroLevel.DocumentObjectModel
/// Relation type not defined
/// </summary>
Uncknown = 0,
/// <summary>
/// Mentioned
/// </summary>
Mentions = 1,
/// <summary>
/// It tells about
/// </summary>
About = 2,
/// <summary>
/// Previous version update
/// </summary>
UpdateOf = 3,
/// <summary>
/// Based on
/// </summary>

@ -10,29 +10,41 @@ namespace ZeroLevel.DocumentObjectModel
/// ID
/// </summary>
public string Identity;
/// <summary>
/// Title
/// </summary>
public string Caption;
/// <summary>
/// Description (optional)
/// </summary>
public string Summary;
/// <summary>
/// Content type
/// </summary>
public ContentType ContentType;
/// <summary>
/// Binary content
/// </summary>
public byte[] Payload;
public AttachContent() { }
public AttachContent(IBinaryReader reader) { Deserialize(reader); }
public AttachContent()
{
}
public AttachContent(IBinaryReader reader)
{
Deserialize(reader);
}
public AttachContent(string identity, string caption, string description)
{ Identity = identity; Summary = description; Caption = caption; }
#region IBinarySerializable
public void Serialize(IBinaryWriter writer)
{
writer.WriteString(this.Identity);
@ -50,6 +62,7 @@ namespace ZeroLevel.DocumentObjectModel
this.ContentType = (ContentType)reader.ReadInt32();
this.Payload = reader.ReadBytes();
}
#endregion
#endregion IBinarySerializable
}
}

@ -38,7 +38,7 @@ namespace ZeroLevel.DocumentObjectModel
Deserialize(reader);
}
#endregion
#endregion Ctors
#region Fields
@ -67,7 +67,7 @@ namespace ZeroLevel.DocumentObjectModel
/// </summary>
public bool IsSystem { get; set; }
#endregion
#endregion Fields
#region IBinarySerializable
@ -89,7 +89,7 @@ namespace ZeroLevel.DocumentObjectModel
this.IsSystem = reader.ReadBoolean();
}
#endregion
#endregion IBinarySerializable
#region ICloneable
@ -98,7 +98,7 @@ namespace ZeroLevel.DocumentObjectModel
return new Category(this);
}
#endregion
#endregion ICloneable
#region IEquatable
@ -113,7 +113,7 @@ namespace ZeroLevel.DocumentObjectModel
return true;
}
#endregion
#endregion IEquatable
#region Equals & Hash
@ -131,6 +131,6 @@ namespace ZeroLevel.DocumentObjectModel
IsSystem.GetHashCode();
}
#endregion
#endregion Equals & Hash
}
}

@ -2,7 +2,7 @@
namespace ZeroLevel.DocumentObjectModel
{
public enum ContentType: Int32
public enum ContentType : Int32
{
Raw = 0,
Text = 1,

@ -7,8 +7,15 @@ namespace ZeroLevel.DocumentObjectModel
public sealed class DescriptiveMetadata :
IBinarySerializable
{
public DescriptiveMetadata() { Initialize(); }
public DescriptiveMetadata(IBinaryReader reader) { Deserialize(reader); }
public DescriptiveMetadata()
{
Initialize();
}
public DescriptiveMetadata(IBinaryReader reader)
{
Deserialize(reader);
}
private void Initialize()
{
@ -22,45 +29,56 @@ namespace ZeroLevel.DocumentObjectModel
}
#region Fields
/// <summary>
/// Authors
/// </summary>
public string Byline;
/// <summary>
/// Copyright
/// </summary>
public string CopyrightNotice;
/// <summary>
/// Creation date
/// </summary>
public DateTime Created;
/// <summary>
/// Main language
/// </summary>
public string Language;
/// <summary>
/// Priority
/// </summary>
public Priority Priority;
/// <summary>
/// Document source
/// </summary>
public Agency Source;
/// <summary>
/// Document publisher
/// </summary>
public Agency Publisher;
/// <summary>
/// Reference to original document
/// </summary>
public Tag Original;
/// <summary>
/// Headers (optional)
/// </summary>
public List<Header> Headers;
#endregion
#endregion Fields
#region IBinarySerializable
public void Serialize(IBinaryWriter writer)
{
writer.WriteString(this.Byline);
@ -89,6 +107,7 @@ namespace ZeroLevel.DocumentObjectModel
this.Source = new Agency();
this.Source.Deserialize(reader);
}
#endregion
#endregion IBinarySerializable
}
}

@ -8,6 +8,7 @@ namespace ZeroLevel.DocumentObjectModel
: IBinarySerializable
{
private static readonly Document _empty = new Document();
public static Document Empty
{
get
@ -17,9 +18,21 @@ namespace ZeroLevel.DocumentObjectModel
}
}
public Document() { Id = Guid.NewGuid(); Initialize(); }
public Document(Guid id) { Id = id; Initialize(); }
public Document(IBinaryReader reader) { Deserialize(reader); }
public Document()
{
Id = Guid.NewGuid(); Initialize();
}
public Document(Guid id)
{
Id = id; Initialize();
}
public Document(IBinaryReader reader)
{
Deserialize(reader);
}
public Document(Document other)
{
var data = MessageSerializer.Serialize(other);
@ -44,45 +57,54 @@ namespace ZeroLevel.DocumentObjectModel
/// ID
/// </summary>
public Guid Id;
/// <summary>
/// Short description
/// </summary>
public string Summary;
/// <summary>
/// Title
/// </summary>
public string Header;
/// <summary>
/// Identification block
/// </summary>
public Identifier Identifier;
/// <summary>
/// Content
/// </summary>
public FlowContent Content;
/// <summary>
/// Tags
/// </summary>
public TagMetadata TagMetadata;
/// <summary>
/// Metadata
/// </summary>
public DescriptiveMetadata DescriptiveMetadata;
/// <summary>
/// Attachments
/// </summary>
public List<AttachContent> Attachments;
/// <summary>
/// Binded documents
/// </summary>
public List<Assotiation> Assotiations;
/// <summary>
/// Categories
/// </summary>
public List<Category> Categories;
#region IBinarySerializable
public void Serialize(IBinaryWriter writer)
{
writer.WriteGuid(this.Id);
@ -114,6 +136,7 @@ namespace ZeroLevel.DocumentObjectModel
this.Assotiations = reader.ReadCollection<Assotiation>();
this.Categories = reader.ReadCollection<Category>();
}
#endregion
#endregion IBinarySerializable
}
}

@ -7,10 +7,12 @@ namespace ZeroLevel.DocumentObjectModel.Flow
ContentElement
{
public SourceType Source { get; set; }
/// <summary>
/// Title
/// </summary>
public string Title;
/// <summary>
/// Link or Attachment ID
/// </summary>

@ -15,6 +15,7 @@ namespace ZeroLevel.DocumentObjectModel.Flow
{
this.Caption = caption;
}
public Column(IBinaryReader reader) : base(ContentElementType.Column)
{
Deserialize(reader);

@ -6,6 +6,7 @@ namespace ZeroLevel.DocumentObjectModel.Flow
IContentElement
{
protected ContentElementType _type;
public ContentElementType Type
{
get
@ -20,6 +21,7 @@ namespace ZeroLevel.DocumentObjectModel.Flow
}
public abstract void Serialize(IBinaryWriter writer);
public abstract void Deserialize(IBinaryReader reader);
}
}

@ -6,13 +6,16 @@ namespace ZeroLevel.DocumentObjectModel.Flow
{
// Primitives
Text = 0,
Quote = 1,
Link = 2,
Image = 3,
Audio = 4,
Video = 5,
// Containers
Section = 100,
Paragraph = 101,
List = 102,
Table = 103,
@ -21,8 +24,10 @@ namespace ZeroLevel.DocumentObjectModel.Flow
Videoplayer = 106,
Row = 107,
Column = 108,
// Feature
Form = 200,
Content = 500,
Unknown = 1000
}

@ -11,14 +11,17 @@ namespace ZeroLevel.DocumentObjectModel.Flow
/// None
/// </summary>
None = 0,
/// <summary>
/// Flow: left
/// </summary>
Left = 1,
/// <summary>
/// Flow: right
/// </summary>
Right = 2,
/// <summary>
/// Block
/// </summary>

@ -8,16 +8,17 @@ namespace ZeroLevel.DocumentObjectModel.Flow
{
public SourceType Source { get; set; }
public FlowAlign Align = FlowAlign.None;
/// <summary>
/// Title
/// </summary>
public string Title;
/// <summary>
/// Link or Attachment ID
/// </summary>
public string Identifier;
public Image() : base(ContentElementType.Image)
{
}

@ -35,6 +35,7 @@ namespace ZeroLevel.DocumentObjectModel.Flow
}
#region Serialization
public override void Serialize(IBinaryWriter writer)
{
ContentElementSerializer.WriteCollection(writer, this.Parts);
@ -44,6 +45,7 @@ namespace ZeroLevel.DocumentObjectModel.Flow
{
this.Parts = ContentElementSerializer.ReadCollection(reader);
}
#endregion
#endregion Serialization
}
}

@ -35,6 +35,7 @@ namespace ZeroLevel.DocumentObjectModel.Flow
}
#region Serialization
public override void Serialize(IBinaryWriter writer)
{
ContentElementSerializer.WriteCollection(writer, this.Parts);
@ -44,6 +45,7 @@ namespace ZeroLevel.DocumentObjectModel.Flow
{
this.Parts = ContentElementSerializer.ReadCollection(reader);
}
#endregion
#endregion Serialization
}
}

@ -11,11 +11,13 @@ namespace ZeroLevel.DocumentObjectModel.Flow
public Text() : base(ContentElementType.Text)
{
}
public Text(string value) :
base(ContentElementType.Text)
{
this.Value = value;
}
public Text(IBinaryReader reader) :
base(ContentElementType.Text)
{

@ -7,10 +7,12 @@ namespace ZeroLevel.DocumentObjectModel.Flow
ContentElement
{
public SourceType Source { get; set; }
/// <summary>
/// Title
/// </summary>
public string Title;
/// <summary>
/// Link or Attachment ID
/// </summary>
@ -19,6 +21,7 @@ namespace ZeroLevel.DocumentObjectModel.Flow
public Video() : base(ContentElementType.Video)
{
}
public Video(IBinaryReader reader) :
base(ContentElementType.Video)
{

@ -13,6 +13,7 @@ namespace ZeroLevel.DocumentObjectModel.Flow
base(ContentElementType.Videoplayer)
{
}
public Videoplayer(IBinaryReader reader) :
base(ContentElementType.Videoplayer)
{

@ -10,7 +10,8 @@ namespace ZeroLevel.DocumentObjectModel
public List<Section> Sections = new List<Section>();
public FlowContent() :
base(ContentElementType.Content) { }
base(ContentElementType.Content)
{ }
public FlowContent(IBinaryReader reader) :
base(ContentElementType.Content)

@ -9,11 +9,31 @@ namespace ZeroLevel.DocumentObjectModel
ICloneable
{
#region Ctors
public Header() { }
public Header(string name) { this.Name = name; }
public Header(string name, string value) { this.Name = name; this.Value = value; }
public Header(string name, string value, string type) { this.Name = name; this.Value = value; this.Type = type; }
public Header(string name, string value, string type, string tag) { this.Name = name; this.Value = value; this.Type = type; this.Tag = tag; }
public Header()
{
}
public Header(string name)
{
this.Name = name;
}
public Header(string name, string value)
{
this.Name = name; this.Value = value;
}
public Header(string name, string value, string type)
{
this.Name = name; this.Value = value; this.Type = type;
}
public Header(string name, string value, string type, string tag)
{
this.Name = name; this.Value = value; this.Type = type; this.Tag = tag;
}
public Header(Header other)
{
this.Name = other.Name;
@ -21,16 +41,20 @@ namespace ZeroLevel.DocumentObjectModel
this.Type = other.Type;
this.Value = other.Value;
}
#endregion
#endregion Ctors
#region Fields
public string Name;
public string Value;
public string Type;
public string Tag;
#endregion
#endregion Fields
#region IBinarySerializable
public void Serialize(IBinaryWriter writer)
{
writer.WriteString(Name);
@ -46,9 +70,11 @@ namespace ZeroLevel.DocumentObjectModel
Type = reader.ReadString();
Tag = reader.ReadString();
}
#endregion
#endregion IBinarySerializable
#region IEquatable
public bool Equals(Header other)
{
if (other == null) return false;
@ -58,9 +84,11 @@ namespace ZeroLevel.DocumentObjectModel
if (string.Compare(this.Tag, other.Tag, StringComparison.Ordinal) != 0) return false;
return true;
}
#endregion
#endregion IEquatable
#region Equals & Hash
public override bool Equals(object obj)
{
return this.Equals(obj as Header);
@ -73,13 +101,16 @@ namespace ZeroLevel.DocumentObjectModel
Type.GetHashCode() ^
Tag.GetHashCode();
}
#endregion
#endregion Equals & Hash
#region ICloneable
public object Clone()
{
return new Header(this);
}
#endregion
#endregion ICloneable
}
}

@ -5,25 +5,36 @@ namespace ZeroLevel.DocumentObjectModel
public class Identifier :
IBinarySerializable
{
public Identifier() { }
public Identifier(IBinaryReader reader) { Deserialize(reader); }
public Identifier()
{
}
public Identifier(IBinaryReader reader)
{
Deserialize(reader);
}
#region Fields
/// <summary>
/// Version
/// </summary>
public int Version;
/// <summary>
/// Timestamp ID
/// </summary>
public long Timestamp;
/// <summary>
/// Label with day accurcy
/// </summary>
public string DateLabel;
#endregion
#endregion Fields
#region IBinarySerializable
public void Serialize(IBinaryWriter writer)
{
writer.WriteInt32(this.Version);
@ -37,6 +48,7 @@ namespace ZeroLevel.DocumentObjectModel
this.Timestamp = reader.ReadLong();
this.DateLabel = reader.ReadString();
}
#endregion
#endregion IBinarySerializable
}
}

@ -8,8 +8,10 @@ namespace ZeroLevel.DocumentObjectModel
{
[Description("Normal")]
Normal = 0,
[Description("Express")]
Express = 1,
[Description("Flash")]
Flash = 2
}

@ -6,11 +6,14 @@ namespace ZeroLevel.DocumentObjectModel
IBinarySerializable
{
#region Fields
public string Name;
public string Value;
#endregion
#endregion Fields
#region IBinarySerializable
public void Deserialize(IBinaryReader reader)
{
this.Name = reader.ReadString();
@ -22,6 +25,7 @@ namespace ZeroLevel.DocumentObjectModel
writer.WriteString(this.Name);
writer.WriteString(this.Value);
}
#endregion
#endregion IBinarySerializable
}
}

@ -6,8 +6,15 @@ namespace ZeroLevel.DocumentObjectModel
public sealed class TagMetadata
: IBinarySerializable
{
public TagMetadata() { Initialize(); }
public TagMetadata(IBinaryReader reader) { Deserialize(reader); }
public TagMetadata()
{
Initialize();
}
public TagMetadata(IBinaryReader reader)
{
Deserialize(reader);
}
private void Initialize()
{
@ -18,24 +25,30 @@ namespace ZeroLevel.DocumentObjectModel
}
#region Fields
/// <summary>
/// Placec (city, country, etc)
/// </summary>
public List<Tag> Places;
/// <summary>
/// Companies
/// </summary>
public List<Tag> Companies;
/// <summary>
/// Persons
/// </summary>
public List<Tag> Persons;
/// <summary>Keywords
/// </summary>
public List<string> Keywords;
#endregion
#endregion Fields
#region IBinarySerializable
public void Serialize(IBinaryWriter writer)
{
writer.WriteCollection<Tag>(this.Companies);
@ -51,6 +64,7 @@ namespace ZeroLevel.DocumentObjectModel
this.Places = reader.ReadCollection<Tag>();
this.Persons = reader.ReadCollection<Tag>();
}
#endregion
#endregion IBinarySerializable
}
}

@ -26,7 +26,9 @@ namespace DOM.Services
}
#region Helpers
#region Map
private readonly Dictionary<ContentElementType, HashSet<ContentElementType>> _includingMap =
new Dictionary<ContentElementType, HashSet<ContentElementType>>
{
@ -158,7 +160,9 @@ namespace DOM.Services
}
}
};
#endregion
#endregion Map
/// <summary>
/// Verify that one element can be included as a child of the second element
/// </summary>
@ -166,6 +170,7 @@ namespace DOM.Services
{
return _includingMap[elementType].Contains(containerType);
}
/// <summary>
/// Writing element to content, dependent on current context.
/// </summary>
@ -182,15 +187,19 @@ namespace DOM.Services
case ContentElementType.Section:
(current as Section).Parts.Add(element);
break;
case ContentElementType.Paragraph:
(current as Paragraph).Parts.Add(element);
break;
case ContentElementType.List:
(current as List).Items.Add(element);
break;
case ContentElementType.Row:
(current as Row).Cells.Add(element);
break;
case ContentElementType.Audioplayer:
if (element.Type == ContentElementType.Text)
{
@ -201,6 +210,7 @@ namespace DOM.Services
(current as Audioplayer).Tracks.Add(element as Audio);
}
break;
case ContentElementType.Videoplayer:
if (element.Type == ContentElementType.Text)
{
@ -211,6 +221,7 @@ namespace DOM.Services
(current as Videoplayer).Playlist.Add(element as Video);
}
break;
case ContentElementType.Gallery:
if (element.Type == ContentElementType.Text)
{
@ -221,6 +232,7 @@ namespace DOM.Services
(current as Gallery).Images.Add(element as Image);
}
break;
case ContentElementType.Table:
if (element.Type == ContentElementType.Column)
{
@ -254,35 +266,45 @@ namespace DOM.Services
case ContentElementType.Section:
LeaveSection();
break;
case ContentElementType.Paragraph:
LeaveParagraph();
break;
case ContentElementType.Audioplayer:
LeaveAudioplayer();
break;
case ContentElementType.Videoplayer:
LeaveVideoplayer();
break;
case ContentElementType.Gallery:
LeaveGallery();
break;
case ContentElementType.List:
LeaveList();
break;
case ContentElementType.Table:
LeaveTable();
break;
case ContentElementType.Row:
LeaveRow();
break;
default:
throw new Exception($"Uncknown container type {current.Type}");
}
}
}
#endregion
#endregion Helpers
#region Containers
public void EnterSection()
{
ReduceContainers();
@ -379,9 +401,11 @@ namespace DOM.Services
}
WriteElement(videoplayer);
}
#endregion
#endregion Containers
#region List
public void EnterList()
{
if (_containers.Count == 0) EnterSection();
@ -403,9 +427,11 @@ namespace DOM.Services
}
WriteElement(list);
}
#endregion
#endregion List
#region Table
public void EnterTable(string name, string summary)
{
if (_containers.Count == 0) EnterSection();
@ -449,9 +475,11 @@ namespace DOM.Services
}
WriteElement(table);
}
#endregion
#endregion Table
#region Primitives
public void WriteColumn(Column column)
{
if (column == null)
@ -469,18 +497,22 @@ namespace DOM.Services
}
WriteElement(text);
}
public void WriteText(string text)
{
WriteElement(new Text(text));
}
public void WriteText(string text, TextStyle style)
{
WriteElement(new Text(text) { Style = style });
}
public void WriteHeader(string text)
{
WriteElement(new Text(text) { Style = new TextStyle { Size = TextSize.MediumHeader, Formatting = TextFormatting.None } });
}
public void WriteQuote(Quote quote)
{
if (quote == null)
@ -489,10 +521,12 @@ namespace DOM.Services
}
WriteElement(quote);
}
public void WriteQuote(string quote)
{
WriteElement(new Quote(quote));
}
public void WriteLink(Link link)
{
if (link == null)
@ -501,10 +535,12 @@ namespace DOM.Services
}
WriteElement(link);
}
public void WriteLink(string href, string value)
{
WriteElement(new Link(href, value));
}
public void WriteForm(FormContent form)
{
if (form == null)
@ -513,6 +549,7 @@ namespace DOM.Services
}
WriteElement(form);
}
public void WriteImage(Image image)
{
if (image == null)
@ -521,6 +558,7 @@ namespace DOM.Services
}
WriteElement(image);
}
public void WriteAudio(Audio audio)
{
if (audio == null)
@ -529,6 +567,7 @@ namespace DOM.Services
}
WriteElement(audio);
}
public void WriteVideo(Video video)
{
if (video == null)
@ -537,7 +576,8 @@ namespace DOM.Services
}
WriteElement(video);
}
#endregion
#endregion Primitives
public void Complete()
{

@ -19,31 +19,43 @@ namespace DOM.Services
// Primitives
case ContentElementType.Text:
return new ZeroLevel.DocumentObjectModel.Flow.Text(reader);
case ContentElementType.Quote:
return new Quote(reader);
case ContentElementType.Link:
return new Link(reader);
case ContentElementType.Image:
return new Image(reader);
case ContentElementType.Audio:
return new Audio(reader);
case ContentElementType.Video:
return new Video(reader);
// Containers
case ContentElementType.Row:
return new Row(reader);
case ContentElementType.Paragraph:
return new Paragraph(reader);
case ContentElementType.Section:
return new Section(reader);
case ContentElementType.List:
return new List(reader);
case ContentElementType.Table:
return new Table(reader);
case ContentElementType.Gallery:
return new Gallery(reader);
case ContentElementType.Audioplayer:
return new Audioplayer(reader);
case ContentElementType.Videoplayer:
return new Videoplayer(reader);
// Feature

@ -19,25 +19,31 @@ namespace DOM.Services
case ContentElementType.Text:
reader.ReadText(element as ZeroLevel.DocumentObjectModel.Flow.Text);
break;
case ContentElementType.Quote:
reader.ReadQuote(element as Quote);
break;
case ContentElementType.Link:
counter.IncLinkId();
reader.ReadLink(element as Link, counter.LinkId);
break;
case ContentElementType.Image:
counter.IncImageId();
reader.ReadImage(element as Image, counter.ImageId);
break;
case ContentElementType.Audio:
counter.IncAudioId();
reader.ReadAudio(element as Audio, counter.AudioId);
break;
case ContentElementType.Video:
counter.IncVideoId();
reader.ReadVideo(element as Video, counter.VideoId);
break;
case ContentElementType.Form:
reader.ReadForm(element as FormContent);
break;
@ -52,6 +58,7 @@ namespace DOM.Services
}
}
break;
case ContentElementType.Section:
var section = (element as Section);
reader.EnterSection(section);
@ -61,6 +68,7 @@ namespace DOM.Services
}
reader.LeaveSection(section);
break;
case ContentElementType.Paragraph:
var paragraph = (element as Paragraph);
reader.EnterParagraph(paragraph);
@ -70,6 +78,7 @@ namespace DOM.Services
}
reader.LeaveParagraph(paragraph);
break;
case ContentElementType.List:
var list = (element as List);
reader.EnterList(list);
@ -81,6 +90,7 @@ namespace DOM.Services
}
reader.LeaveList(list);
break;
case ContentElementType.Gallery:
var gallery = (element as Gallery);
reader.EnterGallery(gallery);
@ -90,6 +100,7 @@ namespace DOM.Services
}
reader.LeaveGallery(gallery);
break;
case ContentElementType.Audioplayer:
var audioplayer = (element as Audioplayer);
reader.EnterAudioplayer(audioplayer);
@ -99,6 +110,7 @@ namespace DOM.Services
}
reader.LeaveAudioplayer(audioplayer);
break;
case ContentElementType.Videoplayer:
var videoplayer = (element as Videoplayer);
reader.EnterVideoplayer(videoplayer);
@ -108,6 +120,7 @@ namespace DOM.Services
}
reader.LeaveVideoplayer(videoplayer);
break;
case ContentElementType.Table:
var table = (element as Table);
reader.EnterTable(table);
@ -133,6 +146,7 @@ namespace DOM.Services
break;
}
}
/// <summary>
/// Reading metadata items
/// </summary>
@ -214,6 +228,7 @@ namespace DOM.Services
reader.LeaveCategories(doc.Categories);
return reader.Complete();
}
/// <summary>
/// Reading content elements
/// </summary>

@ -12,6 +12,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
IContainer
{
#region Activator
private static object Activate(Type type, object[] args)
{
var flags = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public;
@ -78,11 +79,14 @@ namespace ZeroLevel.Patterns.DependencyInjection
Compose(instance);
return instance;
}
#endregion
#endregion Activator
#region Caching
private readonly ReaderWriterLockSlim _rwLock =
new ReaderWriterLockSlim();
/// <summary>
/// Map - contract - dependency resolving
/// </summary>
@ -90,14 +94,17 @@ namespace ZeroLevel.Patterns.DependencyInjection
new Dictionary<Type, List<ResolveTypeInfo>>();
private readonly object _constructorCacheeLocker = new object();
/// <summary>
/// Types constructors cache
/// </summary>
private readonly Dictionary<Type, IEnumerable<ConstructorMetadata>> _constructorCachee =
new Dictionary<Type, IEnumerable<ConstructorMetadata>>();
#endregion
#endregion Caching
#region Private
/// <summary>
/// Creating an instance of an object at the specified dependency resolution
/// </summary>
@ -126,6 +133,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
}
return sessionInstance;
}
/// <summary>
/// Creating an instance of the object at the specified dependency resolution, for a generic type of contract
/// </summary>
@ -170,6 +178,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
}
return sessionInstance;
}
/// <summary>
/// Collecting properties of the type marked with attribute dependency resolution
/// </summary>
@ -180,6 +189,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
return type.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.FlattenHierarchy).
Where(p => p.GetCustomAttribute<ResolveAttribute>() != null);
}
/// <summary>
/// Collecting fields of type marked with an attribute of dependency resolution
/// </summary>
@ -190,6 +200,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
return type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.FlattenHierarchy).
Where(p => p.GetCustomAttribute<ResolveAttribute>() != null);
}
/// <summary>
/// Search for dependency resolution
/// </summary>
@ -229,6 +240,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
}
throw new KeyNotFoundException($"Can't resolve dependency by type '{type.FullName}' and dependency name '{resolveName}'");
}
/// <summary>
/// Resolving dependency on attribute "Resolve
/// </summary>
@ -258,6 +270,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
throw new Exception($"Can't create type '{type.FullName}' instance for contract type {type.FullName}. Dependency key: '{resolveAttribute?.ResolveName}'", ex);
}
}
/// <summary>
/// Collection of interfaces and abstract classes from which the type is inherited
/// </summary>
@ -275,6 +288,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
}
return interfaces;
}
/// <summary>
/// Getting a list of metadata by type constructors
/// </summary>
@ -297,6 +311,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
}
return _constructorCachee[type];
}
/// <summary>
/// Creating an instance of an object, including with non-public constructors
/// </summary>
@ -327,6 +342,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
return Activator.CreateInstance(type, flags, null, args, culture);*/
}
}
/// <summary>
/// Dependency resolution registration
/// </summary>
@ -377,9 +393,11 @@ namespace ZeroLevel.Patterns.DependencyInjection
_rwLock.ExitUpgradeableReadLock();
}
}
#endregion
#endregion Private
#region Register
public void Register<TContract, TImplementation>()
{
var resolveType = new ResolveTypeInfo
@ -475,9 +493,13 @@ namespace ZeroLevel.Patterns.DependencyInjection
};
Register(contractType, resolveType);
}
#endregion
#endregion Register
#region Register with parameters
public void ParameterizedRegister<TContract, TImplementation>(object[] constructorParameters)
{
var resolveType = new ResolveTypeInfo
@ -581,9 +603,11 @@ namespace ZeroLevel.Patterns.DependencyInjection
};
Register(contractType, resolveType);
}
#endregion
#endregion Register with parameters
#region Register instance
/// <summary>
/// Register singletone
/// </summary>
@ -601,6 +625,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
};
Register(typeof(TContract), resolveType);
}
public void Register(Type contractType, object implementation)
{
var resolveType = new ResolveTypeInfo
@ -613,6 +638,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
};
Register(contractType, resolveType);
}
public void Register<TContract>(TContract implementation, string resolveName)
{
var resolveType = new ResolveTypeInfo
@ -625,6 +651,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
};
Register(typeof(TContract), resolveType);
}
public void Register(Type contractType, string resolveName, object implementation)
{
var resolveType = new ResolveTypeInfo
@ -637,9 +664,11 @@ namespace ZeroLevel.Patterns.DependencyInjection
};
Register(contractType, resolveType);
}
#endregion
#endregion Register instance
#region Safe register
public bool TryRegister<TContract, TImplementation>(Action<Exception> fallback = null)
{
try
@ -751,9 +780,11 @@ namespace ZeroLevel.Patterns.DependencyInjection
return false;
}
}
#endregion
#endregion Safe register
#region Safe register with parameters
public bool TryParameterizedRegister<TContract, TImplementation>(object[] constructorParameters, Action<Exception> fallback = null)
{
try
@ -865,9 +896,11 @@ namespace ZeroLevel.Patterns.DependencyInjection
return false;
}
}
#endregion
#endregion Safe register with parameters
#region Resolving
public object Resolve(Type type, bool compose = true)
{
return Resolve(type, string.Empty, null, compose);
@ -971,9 +1004,11 @@ namespace ZeroLevel.Patterns.DependencyInjection
throw new Exception($"Can't create instance for type {type.FullName} for resolved dependency {type.FullName} by key {resolveName}", ex);
}
}
#endregion
#endregion Resolving
#region Safe resolving
public object TryResolve(Type type, out object result, bool compose = true)
{
return TryResolve(type, string.Empty, null, out result, compose);
@ -1066,9 +1101,11 @@ namespace ZeroLevel.Patterns.DependencyInjection
result = null;
return false;
}
#endregion
#endregion Safe resolving
#region Composition
/// <summary>
/// Filling in the fields and properties of an object with auto-set values flagged from the container parameters
/// </summary>
@ -1162,9 +1199,11 @@ namespace ZeroLevel.Patterns.DependencyInjection
}
return false;
}
#endregion
#endregion Composition
#region IDisposable
public void Dispose()
{
try
@ -1190,7 +1229,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
{
(gitem as IDisposable)?.Dispose();
}
catch(Exception ex)
catch (Exception ex)
{
Log.SystemError(ex, $"[Container] Generic singletone dispose error. Instance: '{gitem?.GetType()?.FullName ?? string.Empty}'");
}
@ -1208,9 +1247,11 @@ namespace ZeroLevel.Patterns.DependencyInjection
_rwLock.ExitWriteLock();
}
}
#endregion
#endregion IDisposable
#region IEverythingStorage
private readonly Lazy<IEverythingStorage> _everything =
new Lazy<IEverythingStorage>(EverythingStorage.Create);
@ -1218,18 +1259,22 @@ namespace ZeroLevel.Patterns.DependencyInjection
{
_everything.Value.Add<T>(key, value);
}
public void Remove<T>(string key)
{
_everything.Value.Remove<T>(key);
}
public bool Contains<T>(string key)
{
return _everything.Value.ContainsKey<T>(key);
}
public bool TrySave<T>(string key, T value)
{
return _everything.Value.TryAdd<T>(key, value);
}
public bool TryRemove<T>(string key)
{
return _everything.Value.TryRemove<T>(key);
@ -1265,6 +1310,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
return _everything.Value.Get<T>(key);
return defaultValue;
}
#endregion
#endregion IEverythingStorage
}
}

@ -8,6 +8,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
public sealed class ContainerFactory : IContainerFactory
{
#region Private
private bool _disposed = false;
private static string GetKey(string key)
@ -21,9 +22,11 @@ namespace ZeroLevel.Patterns.DependencyInjection
private readonly ConcurrentDictionary<string, IContainer> _containers =
new ConcurrentDictionary<string, IContainer>();
#endregion
#endregion Private
#region Public
public IContainer this[string containerName]
{
get
@ -105,9 +108,11 @@ namespace ZeroLevel.Patterns.DependencyInjection
}
return false;
}
#endregion
#endregion Public
#region IDisposable
public void Dispose()
{
if (false == _disposed)
@ -120,6 +125,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
_containers.Clear();
}
}
#endregion
#endregion IDisposable
}
}

@ -6,17 +6,20 @@
public interface ICompositionProvider
{
#region Composition
/// <summary>
/// Object compositions, insert contract implementation
/// </summary>
/// <param name="instanse">Object instance</param>
void Compose(object instanse, bool recursive = true);
/// <summary>
/// Object compositions, insert contract implementation
/// </summary>
/// <param name="instanse">Object instance</param>
/// /// <returns>false if composition fault</returns>
bool TryCompose(object instanse, bool recursive = true);
#endregion
#endregion Composition
}
}

@ -11,8 +11,11 @@ namespace ZeroLevel.Patterns.DependencyInjection
IDisposable
{
bool IsResolvingExists<T>();
bool IsResolvingExists<T>(string resolveName);
bool IsResolvingExists(Type type);
bool IsResolvingExists(Type type, string resolveName);
}
}

@ -6,16 +6,23 @@ namespace ZeroLevel.Patterns.DependencyInjection
public interface IContainerFactory : IDisposable
{
#region Properties
IContainer this[string containerName] { get; }
IEnumerable<string> ContainerNames { get; }
IEnumerable<IContainer> Containers { get; }
#endregion
#endregion Properties
#region Methods
IContainer CreateContainer(string containerName);
IContainer GetContainer(string containerName);
bool Contains(string containerName);
bool Remove(string containerName);
#endregion
#endregion Methods
}
}

@ -9,12 +9,14 @@ namespace ZeroLevel.Patterns.DependencyInjection
public interface IContainerInstanceRegister
{
#region Register instance
/// <summary>
/// Register instance for contract <typeparamref name="TContract"/>. (singletone)
/// </summary>
/// <typeparam name="TContract">Contract</typeparam>
/// <param name="implementation">Instance</param>
void Register<TContract>(TContract implementation);
/// <summary>
/// Register instance for contract <typeparamref name="TContract"/>. (singletone)
/// </summary>
@ -22,12 +24,14 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="implementation">Instance</param>
/// <param name="resolveName">Dependency name</param>
void Register<TContract>(TContract implementation, string resolveName);
/// <summary>
/// Register instance for contract (singletone)
/// </summary>
/// <param name="contractType">Contract</param>
/// <param name="implementation">Instance</param>
void Register(Type contractType, object implementation);
/// <summary>
/// Register instance for contract (singletone)
/// </summary>
@ -35,6 +39,8 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="resolveName">Dependency name</param>
/// <param name="implementation">Instance</param>
void Register(Type contractType, string resolveName, object implementation);
#endregion
#endregion Register instance
}
}

@ -9,12 +9,14 @@ namespace ZeroLevel.Patterns.DependencyInjection
public interface IContainerRegister : IDisposable
{
#region Register
/// <summary>
/// Dependency resolution registration
/// </summary>
/// <typeparam name="TContract">Contract</typeparam>
/// <typeparam name="TImplementation">Dependency resolution</typeparam>
void Register<TContract, TImplementation>();
/// <summary>
/// Dependency resolution registration
/// </summary>
@ -22,6 +24,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <typeparam name="TImplementation">Dependency resolution</typeparam>
/// <param name="resolveName">Dependency name</param>
void Register<TContract, TImplementation>(string resolveName);
/// <summary>
/// Dependency resolution registration
/// </summary>
@ -29,6 +32,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <typeparam name="TImplementation">Dependency resolution</typeparam>
/// <param name="shared">true - for singletone</param>
void Register<TContract, TImplementation>(bool shared);
/// <summary>
/// Dependency resolution registration
/// </summary>
@ -44,6 +48,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="contractType">Contract</param>
/// <param name="implementationType">Dependency resolution</param>
void Register(Type contractType, Type implementationType);
/// <summary>
/// Dependency resolution registration
/// </summary>
@ -51,6 +56,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="implementationType">Dependency resolution</param>
/// <param name="resolveName">Dependency name</param>
void Register(Type contractType, Type implementationType, string resolveName);
/// <summary>
/// Dependency resolution registration
/// </summary>
@ -58,6 +64,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="implementationType">Dependency resolution</param>
/// <param name="shared">true - for singletone</param>
void Register(Type contractType, Type implementationType, bool shared);
/// <summary>
/// Dependency resolution registration
/// </summary>
@ -66,9 +73,11 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="resolveName">Dependency name</param>
/// <param name="shared">true - for singletone</param>
void Register(Type contractType, Type implementationType, string resolveName, bool shared);
#endregion
#endregion Register
#region Register with parameters
/// <summary>
/// Dependency resolution registration with constructor parameters
/// </summary>
@ -76,6 +85,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <typeparam name="TImplementation">Dependency resolution</typeparam>
/// <param name="constructorParameters">Ctor args</param>
void ParameterizedRegister<TContract, TImplementation>(object[] constructorParameters);
/// <summary>
/// Dependency resolution registration with constructor parameters
/// </summary>
@ -84,6 +94,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="resolveName">Dependency name</param>
/// <param name="constructorParameters">Ctor args</param>
void ParameterizedRegister<TContract, TImplementation>(string resolveName, object[] constructorParameters);
/// <summary>
/// Dependency resolution registration with constructor parameters
/// </summary>
@ -92,6 +103,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="shared">true - for singletone</param>
/// <param name="constructorParameters">Ctor args</param>
void ParameterizedRegister<TContract, TImplementation>(bool shared, object[] constructorParameters);
/// <summary>
/// Dependency resolution registration with constructor parameters
/// </summary>
@ -101,6 +113,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="shared">true - for singletone</param>
/// <param name="constructorParameters">Ctor args</param>
void ParameterizedRegister<TContract, TImplementation>(string resolveName, bool shared, object[] constructorParameters);
/// <summary>
/// Dependency resolution registration with constructor parameters
/// </summary>
@ -108,6 +121,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="implementationType">Dependency resolution</param>
/// <param name="constructorParameters">Ctor args</param>
void ParameterizedRegister(Type contractType, Type implementationType, object[] constructorParameters);
/// <summary>
/// Dependency resolution registration with constructor parameters
/// </summary>
@ -116,6 +130,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="resolveName">Dependency name</param>
/// <param name="constructorParameters">Ctor args</param>
void ParameterizedRegister(Type contractType, Type implementationType, string resolveName, object[] constructorParameters);
/// <summary>
/// Dependency resolution registration with constructor parameters
/// </summary>
@ -124,6 +139,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="shared">true - for singletone</param>
/// <param name="constructorParameters">Ctor args</param>
void ParameterizedRegister(Type contractType, Type implementationType, bool shared, object[] constructorParameters);
/// <summary>
/// Dependency resolution registration with constructor parameters
/// </summary>
@ -133,9 +149,11 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="shared">true - for singletone</param>
/// <param name="constructorParameters">Ctor args</param>
void ParameterizedRegister(Type contractType, Type implementationType, string resolveName, bool shared, object[] constructorParameters);
#endregion
#endregion Register with parameters
#region Safe register
/// <summary>
/// Safe dependency resolution registration
/// </summary>
@ -144,6 +162,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryRegister<TContract, TImplementation>(Action<Exception> fallback = null);
/// <summary>
/// Safe dependency resolution registration
/// </summary>
@ -153,6 +172,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryRegister<TContract, TImplementation>(string resolveName, Action<Exception> fallback = null);
/// <summary>
/// Safe dependency resolution registration
/// </summary>
@ -162,6 +182,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryRegister<TContract, TImplementation>(bool shared, Action<Exception> fallback = null);
/// <summary>
/// Safe dependency resolution registration
/// </summary>
@ -172,6 +193,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryRegister<TContract, TImplementation>(string resolveName, bool shared, Action<Exception> fallback = null);
/// <summary>
/// Safe dependency resolution registration
/// </summary>
@ -180,6 +202,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryRegister(Type contractType, Type implementationType, Action<Exception> fallback = null);
/// <summary>
/// Safe dependency resolution registration
/// </summary>
@ -189,6 +212,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryRegister(Type contractType, Type implementationType, string resolveName, Action<Exception> fallback = null);
/// <summary>
/// Safe dependency resolution registration
/// </summary>
@ -198,6 +222,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryRegister(Type contractType, Type implementationType, bool shared, Action<Exception> fallback = null);
/// <summary>
/// Safe dependency resolution registration
/// </summary>
@ -208,9 +233,11 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryRegister(Type contractType, Type implementationType, string resolveName, bool shared, Action<Exception> fallback = null);
#endregion
#endregion Safe register
#region Safe register with parameters
/// <summary>
/// Safe dependency resolution registration with constructor parameters
/// </summary>
@ -220,6 +247,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryParameterizedRegister<TContract, TImplementation>(object[] constructorParameters, Action<Exception> fallback = null);
/// <summary>
/// Safe dependency resolution registration with constructor parameters
/// </summary>
@ -230,6 +258,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryParameterizedRegister<TContract, TImplementation>(string resolveName, object[] constructorParameters, Action<Exception> fallback = null);
/// <summary>
/// Safe dependency resolution registration with constructor parameters
/// </summary>
@ -240,6 +269,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryParameterizedRegister<TContract, TImplementation>(bool shared, object[] constructorParameters, Action<Exception> fallback = null);
/// <summary>
/// Safe dependency resolution registration with constructor parameters
/// </summary>
@ -251,6 +281,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryParameterizedRegister<TContract, TImplementation>(string resolveName, bool shared, object[] constructorParameters, Action<Exception> fallback = null);
/// <summary>
/// Safe dependency resolution registration with constructor parameters
/// </summary>
@ -260,6 +291,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryParameterizedRegister(Type contractType, Type implementationType, object[] constructorParameters, Action<Exception> fallback = null);
/// <summary>
/// Safe dependency resolution registration with constructor parameters
/// </summary>
@ -270,6 +302,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryParameterizedRegister(Type contractType, Type implementationType, string resolveName, object[] constructorParameters, Action<Exception> fallback = null);
/// <summary>
/// Safe dependency resolution registration with constructor parameters
/// </summary>
@ -280,6 +313,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryParameterizedRegister(Type contractType, Type implementationType, bool shared, object[] constructorParameters, Action<Exception> fallback = null);
/// <summary>
/// Safe dependency resolution registration with constructor parameters
/// </summary>
@ -291,6 +325,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="fallback">Error handler</param>
/// <returns>true - registration successfully completed</returns>
bool TryParameterizedRegister(Type contractType, Type implementationType, string resolveName, bool shared, object[] constructorParameters, Action<Exception> fallback = null);
#endregion
#endregion Safe register with parameters
}
}

@ -8,6 +8,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
public interface IParameterStorage
{
#region IEverythingStorage
/// <summary>
/// Save parameter
/// </summary>
@ -15,6 +16,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="key">Key</param>
/// <param name="value">Parameter value</param>
void Save<T>(string key, T value);
/// <summary>
/// Save or update parameter
/// </summary>
@ -22,6 +24,7 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="key">Key</param>
/// <param name="value">Parameter value</param>
void SaveOrUpdate<T>(string key, T value);
/// <summary>
/// Safe save parameter
/// </summary>
@ -29,18 +32,21 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="key">Key</param>
/// <param name="value">Parameter value</param>
bool TrySave<T>(string key, T value);
/// <summary>
/// Remove parameter by key
/// </summary>
/// <typeparam name="T">Parameter type</typeparam>
/// <param name="key">Key</param>
void Remove<T>(string key);
/// <summary>
/// Safe remove parameter by key
/// </summary>
/// <typeparam name="T">Parameter type</typeparam>
/// <param name="key">Key</param>
bool TryRemove<T>(string key);
/// <summary>
/// Get parameter value by key
/// </summary>
@ -48,8 +54,11 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="key">Key</param>
/// <returns>Parameter value</returns>
T Get<T>(string key);
T GetOrDefault<T>(string key);
T GetOrDefault<T>(string key, T defaultValue);
/// <summary>
/// Get parameter value by key
/// </summary>
@ -57,12 +66,14 @@ namespace ZeroLevel.Patterns.DependencyInjection
/// <param name="key">Key</param>
/// <returns>Parameter value</returns>
object Get(Type type, string key);
/// <summary>
/// Check for parameter existence by key
/// </summary>
/// <typeparam name="T">Parameter type</typeparam>
/// <param name="key">Key</param>
bool Contains<T>(string key);
#endregion
#endregion IEverythingStorage
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save

Powered by TurnKey Linux.