public NumberComposition Compose( JObject input, Path parentPath) { var xResult = _x.Compose( input, parentPath); if (!xResult.IsSuccess) { throw new NotImplementedException("handle possible problems"); } var yResult = _y.Compose( input, parentPath); if (!yResult.IsSuccess) { throw new NotImplementedException("handle possible problems"); } return(new NumberComposition.Success( (decimal)Math.Pow( (double)xResult.Value, (double)yResult.Value))); }
private static int?TryExtractIndexValue( INumberComposer composer, JObject input, Path parentPath) { if (composer == null) { return(null); } var composition = composer.Compose( input, parentPath); if (!composition.IsSuccess) { throw new NotImplementedException("handle possible problems"); } if (composition.GetDecimal().IsInteger(out var value)) { return(value); } throw new NotImplementedException("handle floating point value problem"); }
public Option <PickIndexElementComposition> Compose( JObject input, Path parentPath, int index) { var conditionResult = _condition.Evaluate( input); if (!conditionResult.IsSuccess) { return(new PickIndexElementComposition.Failure( index, new PickIndexElementCompositionFailed( innerErrors: conditionResult.Errors))); } if (!conditionResult.Value) { return(Option <PickIndexElementComposition> .None); } var composition = _valueComposer.Compose( input, parentPath); if (composition.GetDecimal().IsInteger(out var value)) { return(new PickIndexElementComposition.Success( index, new[] { value })); } throw new NotImplementedException(); }
public NumberComposition Compose( JObject input, Path parentPath) { var xResult = _x.Compose( input, parentPath); return(new NumberComposition.Success( xResult.GetDecimal() * -1)); }
public Composition Compose( JObject input, Path parentPath) { var number = _number.Compose( input, parentPath); if (!number.IsSuccess) { throw new NotImplementedException("handle possible problems"); } return(new CorrectComposition( new JValue(number.Value))); }
public ConditionResult Evaluate(JObject input) { var left = _left.Compose( input, Path.Root); if (!left.IsSuccess) { return(new ConditionResult.Failure(new[] { new ConditionFailed( left.Errors), })); } var right = _right.Compose( input, Path.Root); if (!right.IsSuccess) { return(new ConditionResult.Failure(new[] { new ConditionFailed( left.Errors), })); } var leftNumber = left.GetDecimal(); var rightNumber = right.GetDecimal(); var conditionResult = EvaluateNumericCondition( leftNumber, rightNumber); return(new ConditionResult.Success(conditionResult)); }