• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Install.InstallContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Install

    // Perform the installation process, saving the previous
    // state in the "stateSaver" object.
    public override void Install(IDictionary stateSaver)
			{
				// Make sure that we have a context.
				if(Context == null)
				{
					Context = new InstallContext("con", new String [0]);
				}

				// Log the start of the transaction.
				Context.LogLine(S._("Installer_BeginInstallTransaction"));
				try
				{
					// Run the installation process.
					try
					{
						Context.LogLine(S._("Installer_BeginInstall"));
						base.Install(stateSaver);
					}
					catch(SystemException)
					{
						// Roll back the transaction.
						Context.LogLine(S._("Installer_BeginRollback"));
						try
						{
							Rollback(stateSaver);
						}
						catch(SystemException)
						{
							// Ignore errors during rollback.
						}
						Context.LogLine(S._("Installer_EndRollback"));
	
						// Notify the caller about the rollback.
						throw new InvalidOperationException
							(S._("Installer_RollbackPerformed"));
					}
	
					// Commit the transaction.
					Context.LogLine(S._("Installer_BeginCommit"));
					try
					{
						Commit(stateSaver);
					}
					finally
					{
						Context.LogLine(S._("Installer_EndCommit"));
					}
				}
				finally
				{
					Context.LogLine(S._("Installer_EndInstallTransaction"));
				}
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:55,代码来源:TransactedInstaller.cs


示例17: SetUp

	public void SetUp ()
	{
		string logFile = "./InstallContextTestLog.txt";
		string[] param = new string[] {
		    "/Option1=value1", 
		    "-Option2=value2",
		    "-Option3",
		    "Option4",
		    "/Option5=True",
		    "/Option6=no"
		};
		ic = new InstallContext (logFile, param);
	}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:13,代码来源:InstallContextTest.cs


示例18: ItPersistsArgumentsInFile

        public void ItPersistsArgumentsInFile(
            string consulDomain, string consulIps, Uri cfEtcdCluster, string loggregatorSharedSecret,
            string redundancyZone, string stack, string machineIp)
        {
            var context = new InstallContext();
            var consulEncryptFile = Path.Combine(sourceDirectory.ToString(), "encrypt_key");
            File.WriteAllText(consulEncryptFile, "content");

            context.Parameters.Add("CONSUL_DOMAIN", consulDomain);
            context.Parameters.Add("CONSUL_IPS", consulIps);
            context.Parameters.Add("CF_ETCD_CLUSTER", cfEtcdCluster.ToString());
            context.Parameters.Add("LOGGREGATOR_SHARED_SECRET", loggregatorSharedSecret);
            context.Parameters.Add("REDUNDANCY_ZONE", redundancyZone);
            context.Parameters.Add("STACK", stack);
            context.Parameters.Add("MACHINE_IP", machineIp);
            context.Parameters.Add("CONSUL_ENCRYPT_FILE", consulEncryptFile);
            context.Parameters.Add("REP_REQUIRE_TLS", false.ToString());
            configurationManager.Context = context;
            configurationManager.OnBeforeInstall(null);

            DirectorySecurity directoryAcl = Directory.GetAccessControl(tempDirectory.ToString());
            AuthorizationRuleCollection accessRules = directoryAcl.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);

            FileSecurity fileAcl = File.GetAccessControl(Path.Combine(tempDirectory.ToString(), "encrypt_key"));
            accessRules = fileAcl.GetAccessRules(true, true, typeof (SecurityIdentifier));
            Assert.Equal(accessRules.Count, 1);
            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 JavaScriptSerializer();
            string parametersPath = Path.Combine(tempDirectory.ToString(), "parameters.json");
            string jsonString = File.ReadAllText(parametersPath);
            var hash = javaScriptSerializer.Deserialize<Dictionary<string, string>>(jsonString);
            Assert.Equal(hash["CONSUL_DOMAIN"], consulDomain);
            Assert.Equal(hash["CONSUL_IPS"], consulIps);
            Assert.Equal(hash["CF_ETCD_CLUSTER"], cfEtcdCluster.ToString());
            Assert.Equal(hash["LOGGREGATOR_SHARED_SECRET"], loggregatorSharedSecret);
            Assert.Equal(hash["REDUNDANCY_ZONE"], redundancyZone);
            Assert.Equal(hash["STACK"], stack);
            Assert.Equal(hash["MACHINE_IP"], machineIp);
            Assert.Equal(hash["CONSUL_ENCRYPT_FILE"], Path.Combine(tempDirectory.ToString(), "encrypt_key"));
            Assert.Equal(hash["REP_REQUIRE_TLS"], false.ToString());
        }
开发者ID:cloudfoundry,项目名称:diego-windows-release,代码行数:51,代码来源:ConfigurationManagerTest.cs


示例19: Main

        static void Main( string[] args )
        {
            InstallContext context = new InstallContext();

            context.Parameters["assemblypath"] = typeof( ProjectInstaller ).Assembly.CodeBase.Substring( 8 ).Replace( '/', '\\' );
            context.Parameters["Mode"] = "1";

            using (ProjectInstaller installer = new ProjectInstaller { AutoTestMode = true, Context = context })
            {
                Dictionary<string, string> items = new Dictionary<string, string>();

                installer.Install( items );
            }
        }
开发者ID:davinx,项目名称:DVB.NET---VCR.NET,代码行数:14,代码来源:Program.cs


示例20: UnInstall

        public virtual void UnInstall(string serviceName)
        {
            Logger.Info("Uninstalling {0} service", serviceName);

            Stop(serviceName);
            
            var serviceInstaller = new ServiceInstaller();

            var context = new InstallContext("service_uninstall.log", null);
            serviceInstaller.Context = context;
            serviceInstaller.ServiceName = serviceName;
            serviceInstaller.Uninstall(null);

            Logger.Info("{0} successfully uninstalled", serviceName);
        }
开发者ID:realpatriot,项目名称:NzbDrone,代码行数:15,代码来源:ServiceProvider.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Install.InstallEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# Install.AssemblyInstaller类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap