Exemplo n.º 1
0
        //Execute block with stream and error catching data
        public object Execute(MlfBlock block, SnekScope scope, out string stream, out Exception error, params object[] arguments)
        {
            stream = null;
            error  = null;

            if (scope == null)
            {
                scope = defaultScope;
            }

            SnekScriptSource source = (SnekScriptSource)block.GetFormatData("scriptSource");

            if (source == null)
            {
                return(null);
            }

            scope.scriptScope.SetVariable("block", block);

            AddContextsToScope(block.contexts, scope, block, arguments);

            object output = Execute(source.ScriptSource, scope, out stream, out error);

            RemoveContextsFromScope(block.contexts, scope, block);

            scope.scriptScope.RemoveVariable("block");

            return(output);
        }
Exemplo n.º 2
0
        //Execute a block
        public object Execute(MlfBlock block, SnekScope scope, Dictionary <string, MlfProperty> properties = null, params object[] arguments)
        {
            string    stream = null;
            Exception error  = null;

            if (scope == null)
            {
                scope = defaultScope;
            }

            //Find source
            SnekScriptSource source = (SnekScriptSource)block.GetFormatData("scriptSource");

            if (source == null)
            {
                return(null);
            }

            ApplyPropertyList(scope, properties);
            ApplyArgumentList(block, scope, arguments);

            object output = Execute(block, scope, out stream, out error, arguments);

            RemoveArgumentList(block, scope, arguments);
            RemovePropertyList(scope, properties);

            if (stream != null)
            {
                string stackTrace = GetStackTrace(source.ScriptSource, block);
                Log(stream, StackTraceLogType.None, stackTrace);
            }

            if (error != null)
            {
                string stackTrace = GetStackTrace(source.ScriptSource, block, error);
                LogError(error.Message, StackTraceLogType.None, stackTrace);
            }

            return(output);
        }