public static void ProcLog2Procedure(IScriptCallContext context)
 {
     //context.Setup(ProcLog2ForceAlways, ContextLogOption.ForceAlways, true);
     if (context.LoggingEnabled)
     {
         context.Logger.Log("Step 2.1", "Normal");
     }
     if (context.LoggingEnabled && context.Logger.IsDebugging)
     {
         context.Logger.Log("Step 2.2", "Debugging");
     }
     foreach (ContextLogOption lo in Enum.GetValues(typeof(ContextLogOption)))
     {
         context.Logger.Log("Step 2.3", "Mode: " + lo.ToString());
         using (var callcontext = context.EnterNewScriptContext(ProcLog3ForceAlways, lo, false).Disposer())
         {
             ProcLog3Procedure(callcontext.Value);
         }
         using (var callcontext = context.EnterNewScriptContext(ProcLog3Normal, lo, false).Disposer())
         {
             ProcLog3Procedure(callcontext.Value);
         }
         using (var callcontext = context.EnterNewScriptContext(ProcLog3DebugOnly, lo, false).Disposer())
         {
             ProcLog3Procedure(callcontext.Value);
         }
         using (var callcontext = context.EnterNewScriptContext(ProcLog3Disabled, lo, false).Disposer())
         {
             ProcLog3Procedure(callcontext.Value);
         }
     }
 }
        public static long MyFirstProcedure(IScriptCallContext context, TimeSpan time)
        {
            //context.Setup(MyFirst, ContextLogOption.Normal, true);
            long   v1 = 17L;
            string v2 = "Mette";

            context.Logger.Log("Step 1", "");

            using (var callcontext = context.EnterNewScriptContext(MySecond, ContextLogOption.Normal, false).Disposer())
            {
                MySecondProcedure(callcontext.Value, v1, v2);
            }

            context.Logger.Log("Step 2", "");

            using (var loopStatus = context.StatusUpdater.CreateProgressReporter("Loop", TimeSpan.FromSeconds(20), 10L, p => String.Format("Iteration #{0}", p + 1L)))
            {
                for (long i = 0L; i < 10L; i++)
                {
                    context.Logger.Log("Step 3", String.Format("Loop iteration #{0}", i + 1));
                    loopStatus.UpdateStatus(progress: i + 1L);
                    using (var callcontext = context.EnterNewScriptContext(MyThird, ContextLogOption.Normal, false).Disposer())
                    {
                        MyThirdProcedure(callcontext.Value, false);
                        v1 += 2;
                    }
                }
            }

            return(v1);
        }
 public static void ProcL2Procedure(IScriptCallContext context)
 {
     if (context.LoggingEnabled)
     {
         context.Logger.Log("Step 2.1", "Normal");
     }
     if (context.LoggingEnabled && context.Logger.IsDebugging)
     {
         context.Logger.Log("Step 2.2", "Debugging");
     }
     using (var callcontext = context.EnterNewScriptContext(ProcL3, ContextLogOption.Disabled, false).Disposer())
     {
         ProcL3Procedure(callcontext.Value);
     }
 }
        public static object DynamicProcedureCall(
            this IProcedureReference procedure,
            IScriptCallContext context,
            PropertyBlock propertyBlock,
            object[] sequencialFirstArguments,
            ArgumentList namedArguments,
            object[] sequencialLastArguments)
        {
            if (procedure == null)
            {
                throw new ArgumentNullException("procedure");
            }


            IScriptCallContext subContext = null;

            try
            {
                subContext = context.EnterNewScriptContext(procedure, Logging.ContextLogOption.Normal, true);

                var methodInfo = ((FileProcedure)procedure.ProcedureData).DelegateType.GetMethod("Invoke");
                var arguments  = new List <object>();
                int i          = 0;
                foreach (var p in methodInfo.GetParameters())
                {
                    if (i == 0)
                    {
                        arguments.Add(subContext);
                    }
                    i++;
                }
                Delegate runtimeProcedure = ((FileProcedure)procedure.ProcedureData).RuntimeProcedure;
                return(runtimeProcedure.DynamicInvoke(arguments.ToArray()));
            }
            catch (Exception ex)
            {
                context.ReportError("Exception in dynamic procedure call.", exception: ex);
                return(null);
            }
            finally
            {
                subContext.InternalDispose();
            }
        }