This commit is contained in:
Даниил Заикин
2026-06-17 20:44:53 +03:00
parent 9d153773c2
commit b133e7c656
1880 changed files with 244545 additions and 0 deletions
@@ -0,0 +1,20 @@
namespace QFSW.QC
{
/// <summary>
/// Creates a Preprocessor that is loaded and used by the QuantumConsoleProcessor.
/// </summary>
public interface IQcPreprocessor
{
/// <summary>
/// The priority of this preprocessor to resolve processing order.
/// </summary>
int Priority { get; }
/// <summary>
/// Processes the provided text.
/// </summary>
/// <param name="text">The text to process.</param>
/// <returns>The processed text.</returns>
string Process(string text);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 982c71777d2ff0148ba45412ef409334
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace QFSW.QC
{
/// <summary>
/// Handles preprocessing of console input.
/// </summary>
public class QuantumPreprocessor
{
private readonly IQcPreprocessor[] _preprocessors;
/// <summary>
/// Creates a Quantum Preprocessor with a custom set of preprocessors.
/// </summary>
/// <param name="preprocessors">The IQcPreprocessors to use in this Quantum Preprocessor.</param>
public QuantumPreprocessor(IEnumerable<IQcPreprocessor> preprocessors)
{
_preprocessors = preprocessors.OrderByDescending(x => x.Priority)
.ToArray();
}
/// <summary>
/// Creates a Quantum Preprocessor with the default injected preprocessors
/// </summary>
public QuantumPreprocessor() : this(new InjectionLoader<IQcPreprocessor>().GetInjectedInstances())
{
}
/// <summary>
/// Processes the provided text.
/// </summary>
/// <param name="text">The text to process.</param>
/// <returns>The processed text.</returns>
public string Process(string text)
{
foreach (IQcPreprocessor preprocessor in _preprocessors)
{
try
{
text = preprocessor.Process(text);
}
catch (Exception e)
{
throw new Exception($"Preprocessor {preprocessor} failed:\n{e.Message}", e);
}
}
return text;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ca234287b4b55cb45bf0ecea07ef2703
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: