public static object ExecuteDynamicObjectMethod(
     IScriptCallContext context,
     IDynamicStepBroObject instance,
     string name,
     object[] arguments)
 {
     try
     {
         if (context != null && context.LoggingEnabled)
         {
             context.Log($"Calling dynamic method \"{name}\".");
         }
         return(instance.TryInvokeMethod(name, arguments));
     }
     catch (DynamicMethodNotFoundException)
     {
         if (context != null)
         {
             context.ReportError(
                 $"Method named '{name}' was not found on the object of type '{instance.GetType().Name}'.",
                 new DynamicMethodNotFoundError());
         }
         throw;
     }
     catch (Exception ex)
     {
         if (context != null)
         {
             context.ReportError(
                 $"Exception executing method '{name}' on the object of type '{instance.GetType().Name}'.",
                 exception: ex);
         }
         throw;
     }
 }
 public static IAsyncResult <object> ExecuteDynamicAsyncObjectMethod(
     IScriptCallContext context,
     IDynamicAsyncStepBroObject instance,
     string name,
     object[] arguments)
 {
     try
     {
         var result = instance.TryInvokeMethod(name, arguments);
         if (result != null)
         {
             if (context != null && context.LoggingEnabled)
             {
                 context.Log($"Called method \"{name}\" on object of type '{instance.GetType().Name}'.");
             }
         }
         else
         {
             if (context != null && context.LoggingEnabled)
             {
                 context.Log($"Null value returned from method \"{name}\" on object of type '{instance.GetType().Name}'.");
             }
         }
         return(result);
     }
     catch (DynamicMethodNotFoundException)
     {
         if (context != null)
         {
             context.ReportError(
                 $"Method named '{name}' was not found on the object of type '{instance.GetType().Name}'.",
                 new DynamicMethodNotFoundError());
         }
         throw;
     }
     catch (Exception ex)
     {
         if (context != null)
         {
             context.ReportError(
                 $"Exception executing method '{name}' on the object of type '{instance.GetType().Name}'.",
                 exception: ex);
         }
         throw;
     }
 }
 public static void LogList(IScriptCallContext context, IEnumerable <string> list)
 {
     if (list != null)
     {
         foreach (string s in list)
         {
             context.Log(s);
         }
     }
 }