public VersionDefineExpression GetExpression(string expression)
        {
            if (string.IsNullOrEmpty(expression))
            {
                throw new ArgumentNullException(nameof(expression));
            }

            ExpressionParsedData parsedExpressionData = ParseExpression(expression);

            if (m_ExpressionTypes.ContainsKey(parsedExpressionData.GenerateExpressionTypeKey))
            {
                ExpressionTypeValue expressionTypeValue = m_ExpressionTypes[parsedExpressionData.GenerateExpressionTypeKey];

                return(new VersionDefineExpression(expressionTypeValue.IsValid, parsedExpressionData.leftSemVersion, parsedExpressionData.rightSemVersion)
                {
                    AppliedRule = expressionTypeValue.AppliedRule,
                });
            }
            throw new ArgumentException("Not Found");
        }
示例#2
0
        public VersionDefineExpression <TVersion> GetExpression(string expression)
        {
            if (string.IsNullOrEmpty(expression))
            {
                throw new ArgumentNullException(nameof(expression));
            }

            ExpressionParsedData parsedExpressionData = ParseExpression(expression);

            if (m_ExpressionTypes.ContainsKey(parsedExpressionData.GenerateExpressionTypeKey))
            {
                ExpressionTypeValue <TVersion> expressionTypeValue = m_ExpressionTypes[parsedExpressionData.GenerateExpressionTypeKey];

                return(new VersionDefineExpression <TVersion>(expressionTypeValue.IsValid, parsedExpressionData.leftVersion, parsedExpressionData.rightVersion)
                {
                    AppliedRule = expressionTypeValue.AppliedRule,
                });
            }
            throw new ExpressionNotValidException($"'{expression}' is not a valid expression");
        }