当前位置: 首页>>代码示例>>C#>>正文


C# Install.InstallContext类代码示例

本文整理汇总了C#中System.Configuration.Install.InstallContext的典型用法代码示例。如果您正苦于以下问题:C# InstallContext类的具体用法?C# InstallContext怎么用?C# InstallContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InstallContext类属于System.Configuration.Install命名空间,在下文中一共展示了InstallContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Install

        public virtual void Install(string serviceName)
        {
            Logger.Info("Installing service '{0}'", serviceName);


            var installer = new ServiceProcessInstaller
                                {
                                    Account = ServiceAccount.LocalSystem
                                };

            var serviceInstaller = new ServiceInstaller();


            String[] cmdline = { @"/assemblypath=" + Process.GetCurrentProcess().MainModule.FileName };

            var context = new InstallContext("service_install.log", cmdline);
            serviceInstaller.Context = context;
            serviceInstaller.DisplayName = serviceName;
            serviceInstaller.ServiceName = serviceName;
            serviceInstaller.Description = "NzbDrone Application Server";
            serviceInstaller.StartType = ServiceStartMode.Automatic;
            serviceInstaller.ServicesDependedOn = new[] { "EventLog", "Tcpip" };

            serviceInstaller.Parent = installer;

            serviceInstaller.Install(new ListDictionary());

            Logger.Info("Service Has installed successfully.");
        }
开发者ID:Kiljoymccoy,项目名称:NzbDrone,代码行数:29,代码来源:ServiceProvider.cs

示例2: ItPersistsArgumentsInFile

        public void ItPersistsArgumentsInFile(
            string containerDirectory, string machineIp, string syslogHostIp, string syslogPort, string machineName)
        {
            var context = new InstallContext();
            context.Parameters.Add("CONTAINER_DIRECTORY", containerDirectory);
            context.Parameters.Add("MACHINE_IP", machineIp);
            context.Parameters.Add("SYSLOG_HOST_IP", syslogHostIp);
            context.Parameters.Add("SYSLOG_PORT", syslogPort);
            context.Parameters.Add("MACHINE_NAME", machineName);
            configurationManager.Context = context;
            configurationManager.OnBeforeInstall(null);

            var acl = Directory.GetAccessControl(tempDirectory.ToString());
            var accessRules = acl.GetAccessRules(true, true, typeof(SecurityIdentifier));
            Assert.Equal(accessRules.Count, 1);
            var rule = (FileSystemAccessRule)accessRules[0];
            Assert.Equal(rule.AccessControlType, AccessControlType.Allow);
            Assert.Equal(new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null), rule.IdentityReference);
            Assert.Equal(rule.FileSystemRights, FileSystemRights.FullControl);

            var javaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            var parametersPath = Path.Combine(tempDirectory.ToString(), "parameters.json");
            var jsonString = File.ReadAllText(parametersPath);
            var hash = javaScriptSerializer.Deserialize<Dictionary<string, string>>(jsonString);
            Assert.Equal(hash["CONTAINER_DIRECTORY"], containerDirectory);
            Assert.Equal(hash["MACHINE_IP"], machineIp);
            Assert.Equal(hash["SYSLOG_HOST_IP"], syslogHostIp);
            Assert.Equal(hash["SYSLOG_PORT"], syslogPort);
            Assert.Equal(hash["MACHINE_NAME"], machineName);
        }
开发者ID:cloudfoundry,项目名称:garden-windows-release,代码行数:30,代码来源:ConfigurationManagerTest.cs

示例3: Main

 static void Main(string[] args)
 {
     string opt = null;
     if (args.Length >= 1)
     {
         opt = args[0].ToLower();
     }
     if (opt == "/install" || opt == "/uninstall")
     {
         TransactedInstaller ti = new TransactedInstaller();
         MonitorInstaller mi = new MonitorInstaller("OPC_FILE_WATCHER");
         ti.Installers.Add(mi);
         string path = String.Format("/assemblypath={0}", Assembly.GetExecutingAssembly().Location);
         string[] cmdline = { path };
         InstallContext ctx = new InstallContext("", cmdline);
         ti.Context = ctx;
         if (opt == "/install")
         {
             Console.WriteLine("Installing");
             ti.Install(new Hashtable());
         }
         else if (opt == "/uninstall")
         {
             Console.WriteLine("Uninstalling");
                 try { ti.Uninstall(null); } catch (InstallException ie) { Console.WriteLine(ie.ToString()); }
         }
     }
     else
     {
         ServiceBase[] services;
         services = new ServiceBase[] { new OPCDataParser() }; ServiceBase.Run(services);
     }
 }
开发者ID:kelldog,项目名称:OPCLoggin,代码行数:33,代码来源:Program.cs

示例4: CustomInstaller

        public CustomInstaller(Service service)
        {
            _service = service;
            Installers.Add(GetServiceInstaller());
            Installers.Add(GetServiceProcessInstaller());
            var baseDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs");
            Context = new InstallContext(
                null,
                new[]
                    {
                        "/LogToConsole=true",
                        "/InstallStateDir=" + Path.Combine(baseDir, "service-install.state"),
                        "/LogFile=" + Path.Combine(baseDir, "service-install.log")
                    });

            foreach (string key in Context.Parameters.Keys)
            {
                Writer.WriteLine("{0}={1}", key, Context.Parameters[key]);
            }

            if (_service.StartMode == ServiceStartMode.Automatic)
            {
                Committed += (sender, args) => new ServiceController(service.ServiceName).Start();
            }
        }
开发者ID:drewburlingame,项目名称:MultiCommandConsole,代码行数:25,代码来源:CustomInstaller.cs

示例5: RunPrecompiler

        public void RunPrecompiler()
        {
            var appBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
            var targetFile = Path.Combine(appBase, "RunPrecompiler.dll");
            File.Delete(targetFile);

            var parent = new ParentInstaller();
            var precompile = new PrecompileInstaller();

            precompile.TargetAssemblyFile = targetFile;
            precompile.ViewPath = "MonoRail.Tests.Views";
            precompile.DescribeBatch += ((sender, e) => e.Batch.For<StubController>().Include("*").Include("_*"));

            var context = new InstallContext();
            var state = new Hashtable();

            parent.Installers.Add(precompile);
            parent.Install(state);
            parent.Commit(state);

            Assert.That(File.Exists(targetFile), "File exists");

            var result = Assembly.LoadFrom(targetFile);
            Assert.AreEqual(3, result.GetTypes().Count());
        }
开发者ID:Eilon,项目名称:spark,代码行数:25,代码来源:PrecompileInstallerTests.cs

示例6: ItPersistsArgumentsInFile

        public void ItPersistsArgumentsInFile(
            string containerDirectory, string machineIp, string syslogHostIp, string syslogPort, string machineName)
        {
            using(var tempDirectory = new TempDirectory())
            {
                var configurationManager = new ConfigurationManagerTest();
                var context = new InstallContext();
                context.Parameters.Add("CONTAINER_DIRECTORY", containerDirectory);
                context.Parameters.Add("MACHINE_IP", machineIp);
                context.Parameters.Add("SYSLOG_HOST_IP", syslogHostIp);
                context.Parameters.Add("SYSLOG_PORT", syslogPort);
                context.Parameters.Add("assemblypath", tempDirectory.ToString());
                context.Parameters.Add("MACHINE_NAME", machineName);
                configurationManager.Context = context;
                configurationManager.OnBeforeInstall(null);

                var javaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                var jsonString = File.ReadAllText(Path.Combine(tempDirectory.ToString(), @"..\parameters.json"));
                var hash = javaScriptSerializer.Deserialize<Dictionary<string, string>>(jsonString);
                Assert.Equal(hash["CONTAINER_DIRECTORY"], containerDirectory);
                Assert.Equal(hash["MACHINE_IP"], machineIp);
                Assert.Equal(hash["SYSLOG_HOST_IP"], syslogHostIp);
                Assert.Equal(hash["SYSLOG_PORT"], syslogPort);
                Assert.Equal(hash["MACHINE_NAME"], machineName);
            }
        }
开发者ID:stefanschneider,项目名称:garden-windows-release,代码行数:26,代码来源:ConfigurationManagerTest.cs

示例7: FrmConfig

 public FrmConfig(System.Configuration.Install.InstallContext context, InstallController ctrl)
 {
     formContext = context;
     this.ctrl = ctrl;
     InitializeComponent();
     this.CenterToScreen();
 }
开发者ID:WeDoCrm,项目名称:WeDoMessengerInstaller2.0,代码行数:7,代码来源:FrmConfig.cs

示例8: Install

        public override void Install(IDictionary stateSaver)
        {
            string strAssPath = "/assemblypath=\"{0}\" \"" + this.Context.Parameters["path"]+"\"";

            Context = new InstallContext("", new string[] { String.Format(strAssPath, System.Reflection.Assembly.GetExecutingAssembly().Location) });

            base.Install(stateSaver);
        }
开发者ID:ravihuang,项目名称:WindowsService,代码行数:8,代码来源:ProjectInstaller.cs

示例9: DeleteService

 public void DeleteService(string i_ServiceName)
 {
     ServiceInstaller ServiceInstallerObj = new ServiceInstaller();
     InstallContext Context = new InstallContext(AppDomain.CurrentDomain.BaseDirectory + "\\uninstalllog.log", null);
     ServiceInstallerObj.Context = Context;
     ServiceInstallerObj.ServiceName = i_ServiceName;
     ServiceInstallerObj.Uninstall(null);
 }
开发者ID:ddotan,项目名称:AutoDeploy-agent,代码行数:8,代码来源:ServiceUtilities.cs

示例10: uninstallService

 /// <summary>
 /// UnInstalls the Windows service with the given "installer" object.
 /// </summary>
 /// <param name="pi"></param>
 /// <param name="pathToService"></param>
 public static void uninstallService(Installer pi, string pathToService)
 {
     TransactedInstaller ti = new TransactedInstaller ();
     ti.Installers.Add (pi);
     string[] cmdline = {pathToService};
     InstallContext ctx = new InstallContext ("Uninstall.log", cmdline );
     ti.Context = ctx;
     ti.Uninstall ( null );
 }
开发者ID:abhishek-kumar,项目名称:AIGA,代码行数:14,代码来源:ServiceHelper.cs

示例11: InstallService

 /// <summary>
 /// Installs the Windows service with the given "installer" object.
 /// </summary>
 /// <param name="installer">The installer.</param>
 /// <param name="pathToService">The path to service.</param>
 public static void InstallService(Installer installer, string pathToService)
 {
     TransactedInstaller ti = new TransactedInstaller();
     ti.Installers.Add(installer);
     string[] cmdline = { pathToService };
     InstallContext ctx = new InstallContext("Install.log", cmdline);
     ti.Context = ctx;
     ti.Install(new Hashtable());
 }
开发者ID:JamesTryand,项目名称:alchemi,代码行数:14,代码来源:ServiceHelper.cs

示例12: FrmDbInstall

        public FrmDbInstall(System.Configuration.Install.InstallContext context, InstallController ctrl)
        {
            Logger.info("FrmDbInstall");

            formContext = context;
            this.ctrl = ctrl;
            InitializeComponent();
            this.CenterToScreen();
        }
开发者ID:WeDoCrm,项目名称:PreDeployer,代码行数:9,代码来源:FrmDbInstall.cs

示例13: StartForeground

      public void StartForeground(string[] args)
      {
         if (args.Length > 0)
         {
            switch (args[0])
            {
               case "/install":
               case "-install":
               case "--install":
                  {
                     var directory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Barcodes");
                     if (args.Length > 1)
                     {
                        directory = Path.GetFullPath(args[1]);
                     }
                     if (!Directory.Exists(directory))
                        throw new ArgumentException(String.Format("The barcode directory {0} doesn't exists.", directory));
                     
                     var transactedInstaller = new TransactedInstaller();
                     var serviceInstaller = new ServiceInstaller();
                     transactedInstaller.Installers.Add(serviceInstaller);
                     var ctx = new InstallContext();
                     ctx.Parameters["assemblypath"] = String.Format("{0} \"{1}\"", Assembly.GetExecutingAssembly().Location, directory);
                     transactedInstaller.Context = ctx;
                     transactedInstaller.Install(new Hashtable());

                     Console.WriteLine("The service is installed. Barcode images have to be placed into the directory {0}.", directory);
                  }
                  return;
               case "/uninstall":
               case "-uninstall":
               case "--uninstall":
                  {
                     var transactedInstaller = new TransactedInstaller();
                     var serviceInstaller = new ServiceInstaller();
                     transactedInstaller.Installers.Add(serviceInstaller);
                     var ctx = new InstallContext();
                     ctx.Parameters["assemblypath"] = String.Format("{0}", Assembly.GetExecutingAssembly().Location);
                     transactedInstaller.Context = ctx;
                     transactedInstaller.Uninstall(null);

                     Console.WriteLine("The service is uninstalled.");
                  }
                  return;
               default:
                  if (args[0][0] != '/' &&
                      args[0][0] != '-')
                     throw new ArgumentException(String.Format("The argument {0} isn't supported.", args[0]));
                  break;
            }
         }

         OnStart(args);

         Console.ReadLine();
      }
开发者ID:n1rvana,项目名称:ZXing.NET,代码行数:56,代码来源:BarcodeScannerService.cs

示例14: InitializeInstaller

		private TransactedInstaller InitializeInstaller(Dictionary<string, string> parameters)
		{
			SetupParameters(parameters);
			var ti = new TransactedInstaller();
			var ai = new AssemblyInstaller(Path.Combine(_sourcePath, _serviceExecutable), _parameters);
			ti.Installers.Add(ai);
			var ic = new InstallContext("Install.log", _parameters);
			ti.Context = ic;
			return ti;
		}
开发者ID:kendarorg,项目名称:ZakSetup,代码行数:10,代码来源:ServiceInstaller.cs

示例15: SetupPerfmonCounters

        /// <summary>
        /// setup the Babalu perfmon counters
        /// </summary>
        /// <param name="context"></param>
        public static void SetupPerfmonCounters(InstallContext context)
        {
            context.LogMessage("Perfmon Babalu counters installer begins");
            #if !DEBUG
            if (PerformanceCounterCategory.Exists(BabaluCounterDescriptions.CounterCategory))
                PerformanceCounterCategory.Delete(BabaluCounterDescriptions.CounterCategory);
            #endif
            BabaluCounterDescriptions.InstallCounters();

            context.LogMessage("Perfmon Babalu counters installer ends");
        }
开发者ID:CalypsoSys,项目名称:Babalu_rProxy,代码行数:15,代码来源:PerformanceCounterInstaller.cs


注:本文中的System.Configuration.Install.InstallContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。