public JSParserResult Process(ICodeProvider codeProvider, bool skipHashCheck = false)
        {
            Code = codeProvider;
            string docName = Path.Combine(Code.Path, Code.Name);

            if (!CheckExt(docName))
            {
                return(null);
            }

            var code = Code.LoadCode();
            var hash = Convert.ToBase64String(MD5.Create().ComputeHash(Encoding.Default.GetBytes(code)));

            if (!skipHashCheck && _loadedCodeHash == hash)
            {
                return(new JSParserResult());
            }
            _loadedCodeHash = hash;

            var parserSettings = new JavascriptParserSettings
            {
                MaxParametersLength = _settings.MaxParametersLength,
                MaxParametersLengthInFunctionChain = _settings.MaxParametersLengthInFunctionChain,
                SkipAnonymousFuntions = _settings.HideAnonymousFunctions,
                Filename                 = docName,
                ScriptStripEnabled       = _settings.ScriptStripEnabled,
                ScriptStripExtensions    = _settings.ScriptStripExtensions.OfType <string>().ToArray(),
                ToDoKeyWords             = _settings.ToDoKeywords.OfType <string>().ToArray(),
                FixAspNetTags            = _settings.FixAspNetTags,
                FixAspNetTagsExtensions  = _settings.FixAspNetTagsExtensions.OfType <string>().ToArray(),
                FixRazorSyntax           = _settings.FixRazorSyntax,
                FixRazorSyntaxExtensions = _settings.FixRazorSyntaxExtensions.OfType <string>().ToArray(),
            };

            var result = (new JavascriptParser(parserSettings)).Parse(code);

            result.FileName = docName;
            return(result);
        }
示例#2
0
        public JSParserResult Process(ICodeProvider codeProvider, bool skipHashCheck = false)
        {
            Code = codeProvider;
            string docName = Path.Combine(Code.Path, Code.Name);

            if (!CheckExt(docName))
            {
                return null;
            }

            var code = Code.LoadCode();
            var hash = Convert.ToBase64String(MD5.Create().ComputeHash(Encoding.Default.GetBytes(code)));
            if (!skipHashCheck && _loadedCodeHash == hash)
            {
                return new JSParserResult();
            }
            _loadedCodeHash = hash;

            var parserSettings = new JavascriptParserSettings
            {
                MaxParametersLength = _settings.MaxParametersLength,
                MaxParametersLengthInFunctionChain = _settings.MaxParametersLengthInFunctionChain,
                SkipAnonymousFuntions = _settings.HideAnonymousFunctions,
                Filename = docName,
                ScriptStripEnabled = _settings.ScriptStripEnabled,
                ScriptStripExtensions = _settings.ScriptStripExtensions.OfType<string>().ToArray(),
                ToDoKeyWords = _settings.ToDoKeywords.OfType<string>().ToArray(),
                FixAspNetTags = _settings.FixAspNetTags,
                FixAspNetTagsExtensions = _settings.FixAspNetTagsExtensions.OfType<string>().ToArray(),
                FixRazorSyntax = _settings.FixRazorSyntax,
                FixRazorSyntaxExtensions = _settings.FixRazorSyntaxExtensions.OfType<string>().ToArray(),
            };

            var result = (new JavascriptParser(parserSettings)).Parse(code);
            result.FileName = docName;
            return result;
        }
示例#3
0
        public JSParserResult Process(ICodeProvider codeProvider, bool skipHashCheck = false)
        {
            Code = codeProvider;
            string docName = Path.Combine(Code.Path, Code.Name);

            if (!CheckExt(docName))
            {
                return(null);
            }

            var code = Code.LoadCode();
            var hash = Convert.ToBase64String(MD5.Create().ComputeHash(Encoding.Default.GetBytes(code)));

            if (!skipHashCheck && _loadedCodeHash == hash)
            {
                return(new JSParserResult());
            }
            _loadedCodeHash = hash;

            var result = (new JavascriptParser(_settings)).Parse(code, docName);

            result.FileName = docName;
            return(result);
        }