示例#1
0
 private void AssureSymbolsAreLoaded()
 {
     if (this.isLoaded)
     {
         return;
     }
     lock (this.loadLock)
     {
         if (!this.isLoaded)
         {
             Exception ex = null;
             try
             {
                 this.LoadSymbols();
             }
             catch (IOException ex2)
             {
                 ex = ex2;
             }
             catch (UnauthorizedAccessException ex3)
             {
                 ex = ex3;
             }
             if (ex != null)
             {
                 OwaServerLogger.AppendToLog(SymbolMapLoadLogEvent.CreateForError(ex));
             }
             this.isLoaded = true;
         }
     }
 }
        // Token: 0x06002437 RID: 9271 RVA: 0x00082F3C File Offset: 0x0008113C
        public JavaScriptSymbolsMap <T> Load()
        {
            Dictionary <string, List <T> > symbolMaps      = new Dictionary <string, List <T> >(20, StringComparer.InvariantCultureIgnoreCase);
            Dictionary <uint, string>      sourceFileIdMap = new Dictionary <uint, string>(1024);
            ClientWatsonFunctionNamePool   clientWatsonFunctionNamePool = new ClientWatsonFunctionNamePool();

            foreach (string filePath in this.symbolMapFiles)
            {
                Stopwatch stopwatch = Stopwatch.StartNew();
                Exception ex        = null;
                try
                {
                    this.LoadSymbolsMapFromFile(filePath, symbolMaps, sourceFileIdMap, clientWatsonFunctionNamePool);
                }
                catch (XmlException ex2)
                {
                    ex = ex2;
                }
                catch (IOException ex3)
                {
                    ex = ex3;
                }
                catch (SecurityException ex4)
                {
                    ex = ex4;
                }
                finally
                {
                    stopwatch.Stop();
                }
                SymbolMapLoadLogEvent logEvent;
                if (ex == null)
                {
                    logEvent = SymbolMapLoadLogEvent.CreateForSuccess(filePath, stopwatch.Elapsed);
                }
                else
                {
                    logEvent = SymbolMapLoadLogEvent.CreateForError(filePath, ex, stopwatch.Elapsed);
                }
                OwaServerLogger.AppendToLog(logEvent);
            }
            return(new JavaScriptSymbolsMap <T>(symbolMaps, sourceFileIdMap, clientWatsonFunctionNamePool.ToArray()));
        }
 private void AssureSymbolsAreLoaded()
 {
     if (this.symbolsLoaded)
     {
         return;
     }
     lock (this.loadLock)
     {
         try
         {
             this.UnsafeAssureSymbolsAreLoaded();
         }
         catch (IOException e)
         {
             OwaServerLogger.AppendToLog(SymbolMapLoadLogEvent.CreateForError(e));
         }
         finally
         {
             this.symbolsLoaded = true;
         }
     }
 }
        private void UnsafeAssureSymbolsAreLoaded()
        {
            if (this.symbolsLoaded)
            {
                return;
            }
            Stopwatch stopwatch = Stopwatch.StartNew();

            foreach (string path in ConsolidationSymbolsMap.ConsolidationMapFileNames)
            {
                string text = Path.Combine(this.symbolsMapFolder, path);
                using (TextReader textReader = new StreamReader(text, Encoding.UTF8))
                {
                    Dictionary <string, int> dictionary = new Dictionary <string, int>(40, StringComparer.InvariantCultureIgnoreCase);
                    string text2;
                    while ((text2 = textReader.ReadLine()) != null)
                    {
                        if (!string.IsNullOrEmpty(text2))
                        {
                            if (text2.StartsWith("#"))
                            {
                                string[] array = text2.Split(new char[]
                                {
                                    ' ',
                                    ','
                                });
                                string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(array[1]);
                                if (this.VerifyChecksum(fileNameWithoutExtension, array[2]))
                                {
                                    this.symbolMaps.Add(fileNameWithoutExtension, new List <ConsolidationSymbolsMap.ConsolidationSymbol>(1024));
                                }
                                else
                                {
                                    this.scriptsOutOfSync.Add(fileNameWithoutExtension);
                                }
                            }
                            else
                            {
                                string[] array2 = text2.Split(new char[]
                                {
                                    ','
                                });
                                string fileNameWithoutExtension2 = Path.GetFileNameWithoutExtension(array2[0]);
                                int    count;
                                if (!dictionary.TryGetValue(fileNameWithoutExtension2, out count))
                                {
                                    count = this.sourceFileIds.Count;
                                    dictionary.Add(fileNameWithoutExtension2, count);
                                    this.sourceFileIds.Add(fileNameWithoutExtension2);
                                }
                                string fileNameWithoutExtension3 = Path.GetFileNameWithoutExtension(array2[5]);
                                if (this.symbolMaps.ContainsKey(fileNameWithoutExtension3))
                                {
                                    ConsolidationSymbolsMap.ConsolidationSymbol item = new ConsolidationSymbolsMap.ConsolidationSymbol
                                    {
                                        SourceStartLine   = int.Parse(array2[1]),
                                        SourceStartColumn = int.Parse(array2[2]),
                                        SourceEndLine     = int.Parse(array2[3]),
                                        SourceEndColumn   = int.Parse(array2[4]),
                                        ScriptStartLine   = int.Parse(array2[6]),
                                        ScriptStartColumn = int.Parse(array2[7]),
                                        ScriptEndLine     = int.Parse(array2[8]),
                                        ScriptEndColumn   = int.Parse(array2[9]),
                                        SourceFileId      = count
                                    };
                                    this.symbolMaps[fileNameWithoutExtension3].Add(item);
                                }
                            }
                        }
                    }
                }
                OwaServerLogger.AppendToLog(SymbolMapLoadLogEvent.CreateForSuccess(text, stopwatch.Elapsed));
            }
            foreach (List <ConsolidationSymbolsMap.ConsolidationSymbol> list in this.symbolMaps.Values)
            {
                list.TrimExcess();
            }
        }