Initial implementation

This commit is contained in:
Simon Gruber
2023-08-10 09:04:36 +02:00
commit 4c4ed48e38
95 changed files with 4142 additions and 0 deletions
@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
namespace Process.Interface.Configuration;
/// <summary>
/// Configuration interface for <see cref="IProcessorChain"/>s
/// </summary>
/// <typeparam name="TInput"><see cref="IProcessor{TInput,TOutput}"/> input type</typeparam>
/// <typeparam name="TOutput"><see cref="IProcessor{TInput,TOutput}"/> output type</typeparam>
public interface IProcessorChainConfiguration<TInput, TOutput> : IProcessorChain<TInput, TOutput>
{
/// <summary>
/// Add the specified <paramref name="processor"/> to <see cref="IProcessor{TInput,TOutput}"/> chain
/// </summary>
/// <param name="processor">The <see cref="IProcessor{TInput,TOutput}"/> to add to the chain</param>
/// <returns>The <see cref="IProcessorChainConfiguration{TInput,TOutput}"/> for fluent chaining of method calls</returns>
IProcessorChainConfiguration<T, TOutput, TInput, TOutput> Use<T>(
IProcessor<TInput, T> processor
);
/// <inheritdoc cref="Use{T}(IProcessor{TInput,T})"/>
IProcessorChainConfiguration<T, TOutput, TInput, TOutput> Use<T>(
Func<IEnumerable<TInput>, IEnumerable<T>> processorFunc
);
/// <summary>
/// Ends the configuration process and converts the
/// <see cref="IProcessorChainConfiguration{TInput,TOutput}"/>
/// to a <see cref="IProcessorChain"/>
/// </summary>
/// <param name="processor">The <see cref="IProcessor{TInput,TOutput}"/> to add to the chain</param>
/// <returns>The configured <see cref="IProcessorChain{TInput,TOutput}"/></returns>
IProcessorChainConfiguration<TInput, TOutput> Complete(
IProcessor<TInput, TOutput> processor
);
/// <inheritdoc cref="Complete(IProcessor{TInput,TOutput})"/>
IProcessorChainConfiguration<TInput, TOutput> Complete(
Func<IEnumerable<TInput>, IEnumerable<TOutput>> processorFunc
);
}
/// <summary>
/// Interface for configuring sub-steps of <see cref="IProcessorChain{TInput,TOutput}"/>s
/// </summary>
/// <typeparam name="TInput"><see cref="IProcessor{TInput,TOutput}"/> input type</typeparam>
/// <typeparam name="TOutput"><see cref="IProcessor{TInput,TOutput}"/> output type</typeparam>
/// <typeparam name="TInChain">Input type of the base <see cref="IProcessorChainConfiguration{TInput,TOutput}"/></typeparam>
/// <typeparam name="TOutChain">Output type of the base <see cref="IProcessorChainConfiguration{TInput,TOutput}"/></typeparam>
public interface IProcessorChainConfiguration<TInput, TOutput, TInChain, TOutChain>
{
/// <summary>
/// Add the specified <paramref name="processor"/> to <see cref="IProcessor{TInput,TOutput}"/>
/// </summary>
/// <param name="processor">The <see cref="IProcessor{TInput,TOutput}"/> to add to the chain</param>
/// <returns>The <see cref="IProcessorChainConfiguration{TInput,TOutput, TInChain, TOutChain}"/> for fluent chaining of method calls</returns>
IProcessorChainConfiguration<T, TOutput, TInChain, TOutChain> Use<T>(
IProcessor<TInput, T> processor
);
/// <inheritdoc cref="Use{T}(IProcessor{TInput,T})"/>
IProcessorChainConfiguration<T, TOutput, TInChain, TOutChain> Use<T>(
Func<IEnumerable<TInput>, IEnumerable<T>> processorFunc
);
/// <summary>
/// Ends the configuration process and returns the base <see cref="IProcessorChainConfiguration{TInput,TOutput}"/>
/// to a <see cref="IProcessorChain"/>
/// </summary>
/// <param name="processor">The <see cref="IProcessor{TInput,TOutput}"/> to add to the chain</param>
/// <returns>The configured <see cref="IProcessorChain{TInput,TOutput}"/></returns>
IProcessorChain<TInChain, TOutChain> Complete(
IProcessor<TInput, TOutput> processor
);
/// <inheritdoc cref="Complete(IProcessor{TInput,TOutput})"/>
IProcessorChain<TInChain, TOutChain> Complete(
Func<IEnumerable<TInput>, IEnumerable<TOutput>> processorFunc
);
}
+40
View File
@@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
namespace Process.Interface;
/// <summary>
/// Common interface for <see cref="IProcessor"/>s, which
/// are able to manipulate input data and generate an output
/// </summary>
public interface IProcessor
{
/// <summary>
/// Returns an <seealso cref="IEnumerable"/>,
/// containing the manipulated data after this processing step
/// </summary>
/// <returns>The processed data</returns>
IEnumerable Process(IEnumerable inputs);
}
/// <summary>
/// Common interface for <see cref="IProcessor"/>s, which
/// are able to manipulate <typeparamref name="TInput"/> data and generate an <typeparamref name="TOutput"/>
/// </summary>
/// <typeparam name="TInput">The data type to input</typeparam>
/// <typeparam name="TOutput">The resulting data type</typeparam>
public interface IProcessor<in TInput, out TOutput> : IProcessor
{
/// <summary>
/// Returns an <seealso cref="IEnumerable{T}"/>,
/// containing the manipulated <typeparamref name="TInput"/> data after this processing step
/// </summary>
/// <returns>The processed <typeparamref name="TOutput"/> data</returns>
IEnumerable<TOutput> Process(IEnumerable<TInput> inputs);
/// <inheritdoc cref="IProcessor.Process(IEnumerable)"/>
new IEnumerable Process(IEnumerable inputs)
{
return Process((IEnumerable<TInput>)inputs);
}
}
@@ -0,0 +1,20 @@
using System.Collections.Generic;
namespace Process.Interface;
/// <summary>
/// <see cref="IProcessor"/>, allows to process values through many sub-<see cref="IProcessor"/>s
/// </summary>
public interface IProcessorChain : IProcessor
{
/// <summary>
/// Collection containing the applicable <see cref="IProcessor"/>s for this <see cref="IProcessorChain"/>
/// </summary>
ICollection<IProcessor> Processors { get; }
}
/// <inheritdoc cref="IProcessorChain" />
public interface IProcessorChain<in TInput, out TOutput>
: IProcessorChain, IProcessor<TInput, TOutput>
{
}
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<IncludeSymbols>True</IncludeSymbols>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>
</Project>
+2
View File
@@ -0,0 +1,2 @@
# Ocr.Process