Exemplo n.º 1
0
 public static void Signal(uint configFileContentHash, string tagIdentifier, InternalBypassTrace tracer)
 {
     try
     {
         string text = TraceConfigSync.CreateConfigLoadSyncEventName(AppDomain.CurrentDomain.FriendlyName, tagIdentifier, configFileContentHash);
         bool   flag = false;
         using (EventWaitHandle eventWaitHandle = TraceConfigSync.CreateOrOpenConfigLoadEvent(text, out flag))
         {
             if (!flag)
             {
                 eventWaitHandle.Set();
                 eventWaitHandle.Dispose();
                 tracer.TraceDebug(47663, 0L, "Signalled event {0} to let the test code know that the configuration document has been loaded", new object[]
                 {
                     text
                 });
             }
             else
             {
                 tracer.TraceDebug(47663, 0L, "Event {0} didn't exist, and so no synchronization with the test code was performed", new object[]
                 {
                     text
                 });
             }
         }
     }
     catch (WaitHandleCannotBeOpenedException)
     {
     }
     catch (UnauthorizedAccessException)
     {
     }
 }
        private void FaultInjectionConfigUpdate()
        {
            ConfigurationDocument configurationDocument = ConfigurationDocument.LoadFaultInjectionFromFile(ConfigFiles.FaultInjection.ConfigFilePath);

            this.faultInjectionConfiguration = configurationDocument.FaultInjectionConfig;
            InternalBypassTrace.FaultInjectionConfigurationTracer.TraceDebug(64047, 0L, "New FI configuration took effect", new object[0]);
            TraceConfigSync.Signal(configurationDocument.FileContentHash, this.ComponentInjection(), InternalBypassTrace.FaultInjectionConfigurationTracer);
        }
        private void InMemoryTraceConfigUpdate()
        {
            ConfigurationDocument configurationDocument = ConfigurationDocument.LoadFromFile(ConfigFiles.InMemory.ConfigFilePath);

            this.UpdateInMemory(configurationDocument);
            InternalBypassTrace.TracingConfigurationTracer.TraceDebug(49839, 0L, "New in-memory tracing configuration took effect", new object[0]);
            TraceConfigSync.Signal(configurationDocument.FileContentHash, this.ComponentInjection(), InternalBypassTrace.TracingConfigurationTracer);
        }
        protected void LoadLines(string configFileName, ConfigurationDocument.LineProcessor processLine)
        {
            Stream stream = null;

            InternalBypassTrace.TracingConfigurationTracer.TraceDebug(0, 0L, "Trying to load trace file: {0}", new object[]
            {
                configFileName
            });
            int num = 20;

            while (num >= 0 && stream == null)
            {
                try
                {
                    stream = this.GetStreamFromFile(configFileName);
                    break;
                }
                catch (FileNotFoundException)
                {
                    InternalBypassTrace.TracingConfigurationTracer.TraceError(0, 0L, "File does not exist", new object[0]);
                    throw;
                }
                catch (UnauthorizedAccessException)
                {
                    InternalBypassTrace.TracingConfigurationTracer.TraceError(0, 0L, "Failed to load file, UnauthorizedAccessException", new object[0]);
                    if (num == 0)
                    {
                        throw;
                    }
                }
                catch (SecurityException)
                {
                    InternalBypassTrace.TracingConfigurationTracer.TraceError(0, 0L, "Failed to load file, SecurityException", new object[0]);
                    if (num == 0)
                    {
                        throw;
                    }
                }
                catch (IOException)
                {
                    InternalBypassTrace.TracingConfigurationTracer.TraceError(0, 0L, "Failed to load file, IOException", new object[0]);
                    if (num == 0)
                    {
                        throw;
                    }
                }
                InternalBypassTrace.TracingConfigurationTracer.TraceError(0, 0L, "Retrying file load in 500 ms", new object[0]);
                Thread.Sleep(500);
                num--;
            }
            byte[] array;
            using (BinaryReader binaryReader = new BinaryReader(stream))
            {
                array = binaryReader.ReadBytes((int)stream.Length);
            }
            this.FileContentHash = TraceConfigSync.ComputeContentHash(array);
            using (TextReader textReader = new StringReader(ConfigurationDocument.Encoding.GetString(array, 0, array.Length)))
            {
                string processedLine;
                while ((processedLine = textReader.ReadLine()) != null)
                {
                    this.currentLine++;
                    processLine(processedLine);
                }
            }
            InternalBypassTrace.TracingConfigurationTracer.TraceDebug(0, 0L, "Done reading config file: {0}, {1} lines were processed", new object[]
            {
                configFileName,
                this.currentLine
            });
        }