private async Task <CodeResult> ExecuteInternally()
        {
            CodeResult result = null;

            // Preprocess this code
            if (!Flags.HasFlag(CodeFlags.IsPreProcessed))
            {
                result = await Interception.Intercept(this, InterceptionMode.Pre);

                Flags |= CodeFlags.IsPreProcessed;

                if (result != null)
                {
                    InternallyExecuted = true;
                    return(await OnCodeExecuted(result));
                }
            }

            // Attempt to process the code internally
            switch (Type)
            {
            case CodeType.GCode:
                result = await GCodes.Process(this);

                break;

            case CodeType.MCode:
                result = await MCodes.Process(this);

                break;

            case CodeType.TCode:
                result = await TCodes.Process(this);

                break;
            }

            if (result != null)
            {
                InternallyExecuted = true;
                return(await OnCodeExecuted(result));
            }

            // If the could not be interpreted, post-process it
            if (!Flags.HasFlag(CodeFlags.IsPostProcessed))
            {
                result = await Interception.Intercept(this, InterceptionMode.Post);

                Flags |= CodeFlags.IsPostProcessed;

                if (result != null)
                {
                    InternallyExecuted = true;
                    return(await OnCodeExecuted(result));
                }
            }

            // Code has not been interpreted yet
            return(null);
        }
Exemple #2
0
        private async Task <bool> ProcessInternally()
        {
            // Pre-process this code
            if (!Flags.HasFlag(CodeFlags.IsPreProcessed))
            {
                bool intercepted = await Interception.Intercept(this, InterceptionMode.Pre);

                Flags |= CodeFlags.IsPreProcessed;

                if (intercepted)
                {
                    InternallyProcessed = true;
                    return(true);
                }
            }

            // Attempt to process the code internally
            switch (Type)
            {
            case CodeType.GCode:
                Result = await GCodes.Process(this);

                break;

            case CodeType.MCode:
                Result = await MCodes.Process(this);

                break;

            case CodeType.TCode:
                Result = await TCodes.Process(this);

                break;
            }

            if (Result != null)
            {
                InternallyProcessed = true;
                return(true);
            }

            // If the code could not be interpreted internally, post-process it
            if (!Flags.HasFlag(CodeFlags.IsPostProcessed))
            {
                bool intercepted = await Interception.Intercept(this, InterceptionMode.Post);

                Flags |= CodeFlags.IsPostProcessed;

                if (intercepted)
                {
                    InternallyProcessed = true;
                    return(true);
                }
            }

            // Code has not been interpreted yet - let RRF deal with it
            return(false);
        }