示例#1
0
        void CheckLanguageAndConvert(string Script, UUID ownerID, out IScriptConverter converter,
                                     out string compileScript)
        {
            compileScript = Script;
            converter     = null;
            string language = DefaultCompileLanguage;

            foreach (
                IScriptConverter convert in
                converters.Where(
                    convert => Script.StartsWith("//" + convert.Name, true, CultureInfo.InvariantCulture)))
            {
                language = convert.Name;
            }

            if (!AllowedCompilers.ContainsKey(language))
            {
                // Not allowed to compile to this language!
                AddError("The compiler for language \"" + language +
                         "\" is not in list of allowed compilers. Script will not be executed!");

                return;
            }

            if (m_scriptEngine.Scene != null && !m_scriptEngine.Scene.Permissions.CanCompileScript(ownerID, language))
            {
                // Not allowed to compile to this language!
                AddError(ownerID +
                         " is not in list of allowed users for this scripting language. Script will not be executed!");
                return;
            }

            AllowedCompilers.TryGetValue(language, out converter);
            converter.Convert(Script, out compileScript, out PositionMap);
        }
示例#2
0
        private void CheckLanguageAndConvert(string Script, UUID ownerID, out IScriptConverter converter,
            out string compileScript)
        {
            compileScript = Script;
            converter = null;
            string language = DefaultCompileLanguage;

            foreach (
                IScriptConverter convert in
                    converters.Where(
                        convert => Script.StartsWith("//" + convert.Name, true, CultureInfo.InvariantCulture)))
            {
                language = convert.Name;
            }

            if (!AllowedCompilers.ContainsKey(language))
            {
                // Not allowed to compile to this language!
                AddError("The compiler for language \"" + language +
                         "\" is not in list of allowed compilers. Script will not be executed!");

                return;
            }

            if (m_scriptEngine.Scene != null && !m_scriptEngine.Scene.Permissions.CanCompileScript(ownerID, language))
            {
                // Not allowed to compile to this language!
                AddError(ownerID +
                         " is not in list of allowed users for this scripting language. Script will not be executed!");
                return;
            }

            AllowedCompilers.TryGetValue(language, out converter);
            converter.Convert(Script, out compileScript, out PositionMap);
        }