private bool ExecuteCode(string code, CompiledCodeProperties compiledCodeProperties, string programInput,
                          SupportedProgrammingLanguages.Languages language)
 {
     try
     {
         if (compiledCodeProperties.IsCompiledSuccessfully)
         {
             CodeEvaluationInitiater codeEvaluation = new CodeEvaluationInitiater();
             _executedCodeProperties = codeEvaluation.InitiateCodeExecution(
                 GetProgramProperties(code, language, programInput),
                 compiledCodeProperties
                 );
             _executedCodeProperties.ExecutedSuccessfully = true;
         }
         else
         {
             _executedCodeProperties.CompiledCodeProp = compiledCodeProperties;
         }
     }
     catch (MissingProgramPropertiesValueException ex)
     {
         _executedCodeProperties.ExecutedSuccessfully = false;
         return(false);
     }
     catch (Exception ex)
     {
         _executedCodeProperties.ExecutedSuccessfully = false;
         return(false);
     }
     return(true);
 }
Beispiel #2
0
    /// <summary>
    /// Compile & execute code, return compilation status, return error message for failure and result after successfull execution
    /// </summary>
    public ExecutedCodeProperties InitiateCodeExecution(ProgramProperties programProperties,
                                                        CompiledCodeProperties compiledCodeProperties)
    {
        if (compiledCodeProperties == null)
        {
            throw new NullReferenceException("ExecutedCodeProperties can't be null");
        }

        if (!compiledCodeProperties.IsCompiledSuccessfully || compiledCodeProperties.SuccessfulluyCompiledObject == null)
        {
            throw new Exception("Ensure that code has been already compiled successfully.");
        }
        _excecutedCodeProperties.CompiledCodeProp = compiledCodeProperties;
        return(Execute(programProperties));
    }
        private void CompileCode(string code, SupportedProgrammingLanguages.Languages language)
        {
            CodeEvaluationInitiater codeEvaluation = new CodeEvaluationInitiater();

            _compiledCodeProperties = codeEvaluation.InitiateCompilation(GetProgramProperties(code, language));
        }
 public CsharpCodeCompiler(CompiledCodeProperties compiledCodeProperties)
 {
     _compiledCodeProperties = compiledCodeProperties;
 }