// Token: 0x0600001A RID: 26 RVA: 0x00002CCC File Offset: 0x00000ECC
 private static void HandleDisconnectPerformanceCounters()
 {
     TransportService.logger.LogEvent(TransportEventLogConstants.Tuple_DisconnectingPerformanceCounters, null, new object[0]);
     foreach (string text in TransportService.TransportPerformanceCounterCategories)
     {
         try
         {
             TransportService.RemoveAllInstancesForProcess(text);
         }
         catch (FileMappingNotFoundException ex)
         {
             ExTraceGlobals.ServiceTracer.TraceDebug <string, string>(0L, "Failed to disconnect perf counters from their old process in category {0}, FileMappingNotFoundException: {1}", text, ex.Message);
         }
         catch (Exception ex2)
         {
             ExTraceGlobals.ServiceTracer.TraceDebug <string, string>(0L, "Failed to disconnect perf counters from their old process in category {0}, Exception: {1}", text, ex2.Message);
             TransportService.logger.LogEvent(TransportEventLogConstants.Tuple_FailedToDisconnectPerformanceCounters, null, new object[]
             {
                 text,
                 ex2
             });
         }
     }
 }
        // Token: 0x06000005 RID: 5 RVA: 0x00002158 File Offset: 0x00000358
        internal static void Main(string[] args)
        {
            List <string> list = new List <string>();

            list.Add("SeAuditPrivilege");
            list.Add("SeChangeNotifyPrivilege");
            list.Add("SeCreateGlobalPrivilege");
            list.Add("SeImpersonatePrivilege");
            bool isSystem;

            using (WindowsIdentity current = WindowsIdentity.GetCurrent())
            {
                isSystem = current.IsSystem;
            }
            if (isSystem)
            {
                list.Add("SeIncreaseQuotaPrivilege");
                list.Add("SeAssignPrimaryTokenPrivilege");
            }
            int num = Privileges.RemoveAllExcept(list.ToArray());

            if (num != 0)
            {
                Environment.Exit(num);
            }
            Globals.InitializeSinglePerfCounterInstance();
            ExWatson.Register();
            bool flag  = !Environment.UserInteractive;
            bool flag2 = false;
            bool flag3 = false;

            foreach (string text in args)
            {
                if (text.StartsWith("-?", StringComparison.OrdinalIgnoreCase))
                {
                    TransportService.Usage();
                    Environment.Exit(0);
                }
                else if (text.StartsWith("-console", StringComparison.OrdinalIgnoreCase))
                {
                    flag2 = true;
                }
                else if (text.StartsWith("-wait", StringComparison.OrdinalIgnoreCase))
                {
                    flag3 = true;
                }
            }
            if (!flag)
            {
                if (!flag2)
                {
                    TransportService.Usage();
                    Environment.Exit(0);
                }
                Console.WriteLine("Starting {0}, running in console mode.", Assembly.GetExecutingAssembly().GetName().Name);
                if (flag3)
                {
                    Console.WriteLine("Press ENTER to continue.");
                    Console.ReadLine();
                }
            }
            SettingOverrideSync.Instance.Start(true);
            if (!VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Transport.ADExceptionHandling.Enabled)
            {
                TransportService.adConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 324, "Main", "f:\\15.00.1497\\sources\\dev\\Transport\\src\\TransportService\\TransportService.cs");
            }
            else
            {
                ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
                {
                    TransportService.adConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 334, "Main", "f:\\15.00.1497\\sources\\dev\\Transport\\src\\TransportService\\TransportService.cs");
                }, 0);
                if (!adoperationResult.Succeeded)
                {
                    ExTraceGlobals.ServiceTracer.TraceError <Exception>(0L, "Error when getting AD configuration session: {0}", adoperationResult.Exception);
                    TransportService.logger.LogEvent(TransportEventLogConstants.Tuple_MSExchangeTransportInitializationFailure, null, new object[]
                    {
                        adoperationResult.Exception.ToString()
                    });
                    Environment.Exit(1);
                }
            }
            TransportService.transportService = new TransportService(flag);
            if (!TransportService.transportService.Initialize())
            {
                ExTraceGlobals.ServiceTracer.TraceError(0L, "Failed to initialize the service. Exiting.");
                ProcessManagerService.StopService();
            }
            if (!flag)
            {
                TransportService.transportService.OnStartInternal(args);
                bool flag4 = false;
                while (!flag4)
                {
                    Console.WriteLine("Enter 'q' to shutdown.");
                    string text2 = Console.ReadLine();
                    if (string.IsNullOrEmpty(text2))
                    {
                        break;
                    }
                    switch (text2[0])
                    {
                    case 'q':
                        flag4 = true;
                        break;

                    case 'r':
                        TransportService.transportService.OnCustomCommandInternal(200);
                        break;

                    case 'u':
                        TransportService.transportService.OnCustomCommandInternal(201);
                        break;
                    }
                }
                Console.WriteLine("Shutting down ...");
                TransportService.transportService.OnStopInternal();
                Console.WriteLine("Done.");
                return;
            }
            ServiceBase.Run(TransportService.transportService);
        }
        // Token: 0x06000017 RID: 23 RVA: 0x00002C58 File Offset: 0x00000E58
        private static void HandleWorkerExited()
        {
            TransportServerAlivePerfCountersInstance serverAlivePerfCounterInstance = TransportService.GetServerAlivePerfCounterInstance();

            if (serverAlivePerfCounterInstance != null)
            {
                serverAlivePerfCounterInstance.ServerAlive.RawValue = 0L;
            }
        }
 // Token: 0x06000001 RID: 1 RVA: 0x000020D0 File Offset: 0x000002D0
 internal TransportService(bool runningAsService) : base("MSExchangeTransport", TransportService.GetWorkerProcessPathName(TransportService.workerProcessName), TransportService.jobObjectName, true, 30, runningAsService, ExTraceGlobals.ServiceTracer, TransportService.serviceLogger)
 {
     base.CanPauseAndContinue = true;
 }