Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
DSLExecutor/dev/Manisero.DSLExecutor/ExpressionExecution/ExpressionExecutor.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
53 lines (43 sloc)
1.96 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Manisero.DSLExecutor.Domain.ExpressionsDomain; | |
using Manisero.DSLExecutor.ExpressionExecution.SpecificExpressionExecution; | |
namespace Manisero.DSLExecutor.ExpressionExecution | |
{ | |
public interface IExpressionExecutor | |
{ | |
object Execute(IExpression expression); | |
} | |
public class ExpressionExecutor : IExpressionExecutor | |
{ | |
private readonly IConstantExpressionExecutor _constantExpressionExecutor; | |
private readonly IFunctionExpressionExecutor _functionExpressionExecutor; | |
private readonly IBatchExpressionExecutor _batchExpressionExecutor; | |
public ExpressionExecutor(IConstantExpressionExecutor constantExpressionExecutor, | |
IFunctionExpressionExecutor functionExpressionExecutor, | |
IBatchExpressionExecutor batchExpressionExecutor) | |
{ | |
_constantExpressionExecutor = constantExpressionExecutor; | |
_functionExpressionExecutor = functionExpressionExecutor; | |
_batchExpressionExecutor = batchExpressionExecutor; | |
} | |
public object Execute(IExpression expression) | |
{ | |
var constantExpression = expression as IConstantExpression; | |
if (constantExpression != null) | |
{ | |
return _constantExpressionExecutor.Execute(constantExpression); | |
} | |
var functionExpression = expression as IFunctionExpression; | |
if (functionExpression != null) | |
{ | |
return _functionExpressionExecutor.Execute(functionExpression); | |
} | |
var batchExpression = expression as IBatchExpression; | |
if (batchExpression != null) | |
{ | |
return _batchExpressionExecutor.Execute(batchExpression); | |
} | |
throw new NotSupportedException($"Not supported expression type: {expression.GetType().FullName}."); | |
} | |
} | |
} |