Projekt neu angelegt.
This commit is contained in:
commit
56ab363fba
32
.gitignore
vendored
Normal file
32
.gitignore
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
#Ignore thumbnails created by Windows
|
||||||
|
Thumbs.db
|
||||||
|
#Ignore files built by Visual Studio
|
||||||
|
*.obj
|
||||||
|
*.exe
|
||||||
|
*.pdb
|
||||||
|
*.user
|
||||||
|
*.aps
|
||||||
|
*.pch
|
||||||
|
*.vspscc
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*.ncb
|
||||||
|
*.suo
|
||||||
|
*.tlb
|
||||||
|
*.tlh
|
||||||
|
*.bak
|
||||||
|
*.cache
|
||||||
|
*.ilk
|
||||||
|
*.log
|
||||||
|
[Bb]in
|
||||||
|
[Dd]ebug*/
|
||||||
|
*.lib
|
||||||
|
*.sbr
|
||||||
|
obj/
|
||||||
|
[Rr]elease*/
|
||||||
|
_ReSharper*/
|
||||||
|
[Tt]est[Rr]esult*
|
||||||
|
.vs/
|
||||||
|
#Nuget packages folder
|
||||||
|
packages/
|
||||||
25
Test_EnvSetzen.sln
Normal file
25
Test_EnvSetzen.sln
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 16
|
||||||
|
VisualStudioVersion = 16.0.29806.167
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_EnvSetzen", "Test_EnvSetzen\Test_EnvSetzen.csproj", "{7FD1CE85-E6D6-41D9-9C94-A5406F012F09}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{7FD1CE85-E6D6-41D9-9C94-A5406F012F09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{7FD1CE85-E6D6-41D9-9C94-A5406F012F09}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{7FD1CE85-E6D6-41D9-9C94-A5406F012F09}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{7FD1CE85-E6D6-41D9-9C94-A5406F012F09}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {51CAE2EF-2B56-4C78-8182-EBACDEDCE8E9}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
6
Test_EnvSetzen/App.config
Normal file
6
Test_EnvSetzen/App.config
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
123
Test_EnvSetzen/Form1.Designer.cs
generated
Normal file
123
Test_EnvSetzen/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
namespace Test_EnvSetzen
|
||||||
|
{
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Erforderliche Designervariable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Verwendete Ressourcen bereinigen.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Vom Windows Form-Designer generierter Code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Erforderliche Methode für die Designerunterstützung.
|
||||||
|
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.buttonSetEnv = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.labelEnv = new System.Windows.Forms.Label();
|
||||||
|
this.labelNewEnv = new System.Windows.Forms.Label();
|
||||||
|
this.labelParse = new System.Windows.Forms.Label();
|
||||||
|
this.labelNewEnvValue = new System.Windows.Forms.Label();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonSetEnv
|
||||||
|
//
|
||||||
|
this.buttonSetEnv.Location = new System.Drawing.Point(12, 142);
|
||||||
|
this.buttonSetEnv.Name = "buttonSetEnv";
|
||||||
|
this.buttonSetEnv.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonSetEnv.TabIndex = 0;
|
||||||
|
this.buttonSetEnv.Text = "ENV setzen";
|
||||||
|
this.buttonSetEnv.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSetEnv.Click += new System.EventHandler(this.buttonSetEnv_Click);
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(368, 142);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonCancel.TabIndex = 1;
|
||||||
|
this.buttonCancel.Text = "Cancel";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||||
|
//
|
||||||
|
// labelEnv
|
||||||
|
//
|
||||||
|
this.labelEnv.AutoSize = true;
|
||||||
|
this.labelEnv.Location = new System.Drawing.Point(9, 22);
|
||||||
|
this.labelEnv.Name = "labelEnv";
|
||||||
|
this.labelEnv.Size = new System.Drawing.Size(16, 13);
|
||||||
|
this.labelEnv.TabIndex = 2;
|
||||||
|
this.labelEnv.Text = "...";
|
||||||
|
//
|
||||||
|
// labelNewEnv
|
||||||
|
//
|
||||||
|
this.labelNewEnv.AutoSize = true;
|
||||||
|
this.labelNewEnv.Location = new System.Drawing.Point(9, 74);
|
||||||
|
this.labelNewEnv.Name = "labelNewEnv";
|
||||||
|
this.labelNewEnv.Size = new System.Drawing.Size(16, 13);
|
||||||
|
this.labelNewEnv.TabIndex = 3;
|
||||||
|
this.labelNewEnv.Text = "...";
|
||||||
|
//
|
||||||
|
// labelParse
|
||||||
|
//
|
||||||
|
this.labelParse.AutoSize = true;
|
||||||
|
this.labelParse.Location = new System.Drawing.Point(9, 9);
|
||||||
|
this.labelParse.Name = "labelParse";
|
||||||
|
this.labelParse.Size = new System.Drawing.Size(430, 13);
|
||||||
|
this.labelParse.TabIndex = 4;
|
||||||
|
this.labelParse.Text = "Wert in der Umgebungsvariablen NXTOOLS_SYSDIR nach dem Parsen der ugii_env.dat:";
|
||||||
|
//
|
||||||
|
// labelNewEnvValue
|
||||||
|
//
|
||||||
|
this.labelNewEnvValue.AutoSize = true;
|
||||||
|
this.labelNewEnvValue.Location = new System.Drawing.Point(9, 61);
|
||||||
|
this.labelNewEnvValue.Name = "labelNewEnvValue";
|
||||||
|
this.labelNewEnvValue.Size = new System.Drawing.Size(355, 13);
|
||||||
|
this.labelNewEnvValue.TabIndex = 5;
|
||||||
|
this.labelNewEnvValue.Text = "Wert nach dem neu Setzen der Umgebungsvariable NXTOOLS_SYSDIR:";
|
||||||
|
//
|
||||||
|
// Form1
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(455, 177);
|
||||||
|
this.Controls.Add(this.labelNewEnvValue);
|
||||||
|
this.Controls.Add(this.labelParse);
|
||||||
|
this.Controls.Add(this.labelNewEnv);
|
||||||
|
this.Controls.Add(this.labelEnv);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSetEnv);
|
||||||
|
this.Name = "Form1";
|
||||||
|
this.Text = "Form1";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Button buttonSetEnv;
|
||||||
|
private System.Windows.Forms.Button buttonCancel;
|
||||||
|
private System.Windows.Forms.Label labelEnv;
|
||||||
|
private System.Windows.Forms.Label labelNewEnv;
|
||||||
|
private System.Windows.Forms.Label labelParse;
|
||||||
|
private System.Windows.Forms.Label labelNewEnvValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
53
Test_EnvSetzen/Form1.cs
Normal file
53
Test_EnvSetzen/Form1.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Test_EnvSetzen
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSetEnv_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//ENV setzen
|
||||||
|
SetEnv();
|
||||||
|
|
||||||
|
string newValue = @"C:\temp\NxTools12.0";
|
||||||
|
Environment.SetEnvironmentVariable("NXTOOLS_SYSDIR", newValue);
|
||||||
|
|
||||||
|
labelNewEnv.Text = Environment.GetEnvironmentVariable("NXTOOLS_SYSDIR");
|
||||||
|
labelNewEnv.Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetEnv()
|
||||||
|
{
|
||||||
|
string filename = @"M:\ug\NX12_NXTC\global\00_DEFAULTS\UGII\ugii_env.dat";
|
||||||
|
|
||||||
|
var setUgii = new UgiiEnvParser(filename);
|
||||||
|
|
||||||
|
//string call = @"/c M:\ug\NX12_NXTC\global\00_DEFAULTS\UGII\ugii_env.dat";
|
||||||
|
|
||||||
|
//Process.Start("cmd.exe", call);
|
||||||
|
|
||||||
|
labelEnv.Text = Environment.GetEnvironmentVariable("NXTOOLS_SYSDIR");
|
||||||
|
labelEnv.Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
120
Test_EnvSetzen/Form1.resx
Normal file
120
Test_EnvSetzen/Form1.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
22
Test_EnvSetzen/Program.cs
Normal file
22
Test_EnvSetzen/Program.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Test_EnvSetzen
|
||||||
|
{
|
||||||
|
static class Program
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Der Haupteinstiegspunkt für die Anwendung.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
Application.EnableVisualStyles();
|
||||||
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
Application.Run(new Form1());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Test_EnvSetzen/Properties/AssemblyInfo.cs
Normal file
36
Test_EnvSetzen/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||||
|
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||||
|
// die einer Assembly zugeordnet sind.
|
||||||
|
[assembly: AssemblyTitle("Test_EnvSetzen")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Test_EnvSetzen")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
|
||||||
|
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
|
||||||
|
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
|
||||||
|
[assembly: Guid("7fd1ce85-e6d6-41d9-9c94-a5406f012f09")]
|
||||||
|
|
||||||
|
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||||
|
//
|
||||||
|
// Hauptversion
|
||||||
|
// Nebenversion
|
||||||
|
// Buildnummer
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||||
|
// indem Sie "*" wie unten gezeigt eingeben:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
71
Test_EnvSetzen/Properties/Resources.Designer.cs
generated
Normal file
71
Test_EnvSetzen/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Dieser Code wurde von einem Tool generiert.
|
||||||
|
// Laufzeitversion: 4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn
|
||||||
|
// der Code neu generiert wird.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace Test_EnvSetzen.Properties
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
||||||
|
/// </summary>
|
||||||
|
// Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse
|
||||||
|
// über ein Tool wie ResGen oder Visual Studio automatisch generiert.
|
||||||
|
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
|
||||||
|
// mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources
|
||||||
|
{
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if ((resourceMan == null))
|
||||||
|
{
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Test_EnvSetzen.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
|
||||||
|
/// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
117
Test_EnvSetzen/Properties/Resources.resx
Normal file
117
Test_EnvSetzen/Properties/Resources.resx
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
30
Test_EnvSetzen/Properties/Settings.Designer.cs
generated
Normal file
30
Test_EnvSetzen/Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace Test_EnvSetzen.Properties
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||||
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||||
|
{
|
||||||
|
|
||||||
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
|
public static Settings Default
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return defaultInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
7
Test_EnvSetzen/Properties/Settings.settings
Normal file
7
Test_EnvSetzen/Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||||
|
<Profiles>
|
||||||
|
<Profile Name="(Default)" />
|
||||||
|
</Profiles>
|
||||||
|
<Settings />
|
||||||
|
</SettingsFile>
|
||||||
192
Test_EnvSetzen/ReplaceVariable.cs
Normal file
192
Test_EnvSetzen/ReplaceVariable.cs
Normal file
@ -0,0 +1,192 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Test_EnvSetzen
|
||||||
|
{
|
||||||
|
class ReplaceVariable
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Replaces variables in a string with values.
|
||||||
|
/// If a variable is not found, an exception is thrown
|
||||||
|
/// </summary>
|
||||||
|
public ReplaceVariable()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Replaces all variables in the transferred string with values.
|
||||||
|
/// Variable names are not case sensitive.
|
||||||
|
/// Locally defined variables take precedence over environment variables.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">Text with variables. Variables must have DOS or Unix format. E.g.: %dos% or ${unix}</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string ExtractVariable(string text)
|
||||||
|
{
|
||||||
|
string startSign = "";
|
||||||
|
string endSign = "";
|
||||||
|
string newText = "";
|
||||||
|
|
||||||
|
//Wenn im Text eine bekannte Variable enthalten ist, dann gegen den aktuellen Wert tauschen
|
||||||
|
if (!string.IsNullOrEmpty(text))
|
||||||
|
{
|
||||||
|
while (text.Contains("%") || text.Contains("{"))
|
||||||
|
{
|
||||||
|
if (text.Contains("%"))
|
||||||
|
{
|
||||||
|
startSign = "%";
|
||||||
|
endSign = "%";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
startSign = "${";
|
||||||
|
endSign = "}";
|
||||||
|
}
|
||||||
|
|
||||||
|
newText = ReplaceVariableThroughText(text, startSign, endSign); //ENV-Variablen extrahieren
|
||||||
|
|
||||||
|
//Abbrechen wenn die Umgebungsvariable nicht gefunden wurde
|
||||||
|
if (String.IsNullOrEmpty(newText))
|
||||||
|
{
|
||||||
|
text = "";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text = newText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ReplaceVariableThroughText(string text, string startSign, string endSign)
|
||||||
|
{
|
||||||
|
string textTemp = "";
|
||||||
|
string textAnfang = "";
|
||||||
|
string textEnde = "";
|
||||||
|
string variableName = "";
|
||||||
|
string variableValue = "";
|
||||||
|
|
||||||
|
//'Textanfang' extrahieren
|
||||||
|
textAnfang = text.Remove(text.IndexOf(startSign));
|
||||||
|
|
||||||
|
textTemp = text.Remove(0, text.IndexOf(startSign));
|
||||||
|
|
||||||
|
//Variable extrahieren
|
||||||
|
variableName = textTemp.Remove(0, textTemp.IndexOf(startSign) + startSign.Length); //'startSign' entfernen
|
||||||
|
variableName = variableName.Remove(variableName.IndexOf(endSign)); //'endSign' und nachfolgenden Text entfernen
|
||||||
|
|
||||||
|
//Textende extrahieren
|
||||||
|
textEnde = textTemp.Remove(0, startSign.Length); //'startSign' entfernen
|
||||||
|
textEnde = textEnde.Remove(0, textEnde.IndexOf(endSign) + 1); //Alle Zeichen bis zum 'endSign' entfernen
|
||||||
|
|
||||||
|
//Variable umwandeln und Text wieder zusammenbauen
|
||||||
|
variableValue = ConvertVariableToString(variableName);
|
||||||
|
|
||||||
|
if (String.IsNullOrEmpty(variableValue))
|
||||||
|
{
|
||||||
|
text = ""; //Wenn die Variable nicht konvertiert werden konnte, dann einen leeren Text zurückgeben
|
||||||
|
// throw new VariableValueNotFoundException(variableName); //Wird diese Zeile auskommentiert, dann wird ein leerer Text zurückgegeben
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text = String.Concat(textAnfang, variableValue, textEnde); //Text zusammensetzen
|
||||||
|
}
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ConvertVariableToString(string variableName)
|
||||||
|
{
|
||||||
|
string variableValue = "";
|
||||||
|
bool localVariableExist = false;
|
||||||
|
|
||||||
|
//Sind lokale Variablen definiert, dann zuerst diese durchsuchen
|
||||||
|
if (variables != null)
|
||||||
|
{
|
||||||
|
foreach (var varName in variables)
|
||||||
|
{
|
||||||
|
if (varName.VariableName.ToUpper() == variableName.ToUpper())
|
||||||
|
{
|
||||||
|
variableValue = varName.VariableValue;
|
||||||
|
localVariableExist = true;
|
||||||
|
break; //Wurde eine Entsprechung gefunden, dann nicht mehr weitersuchen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Wurde in den lokalen Variablen nichts gefunden, dann die Umgebungsvariablen durchsuchen
|
||||||
|
if (!localVariableExist)
|
||||||
|
{
|
||||||
|
if (!localVariableExist & Environment.GetEnvironmentVariable(variableName) != null)
|
||||||
|
{
|
||||||
|
variableValue = Environment.GetEnvironmentVariable(variableName); //Wert aus Umgebungsvariable holen
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
variableValue = ""; //Wenn es keine passende Variable gibt, dann einen leeren Wert übergeben
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return variableValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Variable variable = new Variable();
|
||||||
|
static List<Variable> variables = new List<Variable>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a local defined variable to the variable list.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="variableName">A valid variable Name.</param>
|
||||||
|
/// <param name="variableValue">A valid variable value.</param>
|
||||||
|
public void Add(string variableName, string variableValue)
|
||||||
|
{
|
||||||
|
Variable tempVariable = new Variable();
|
||||||
|
tempVariable.VariableName = variableName;
|
||||||
|
tempVariable.VariableValue = variableValue;
|
||||||
|
variables.Add(tempVariable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the first variable found with the specified name from the list.
|
||||||
|
/// The variable name is not case sensitive.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="variableName">A valid variable Name.</param>
|
||||||
|
public void Remove(string variableName)
|
||||||
|
{
|
||||||
|
foreach (var varName in variables)
|
||||||
|
{
|
||||||
|
if (varName.VariableName.ToUpper() == variableName.ToUpper())
|
||||||
|
{
|
||||||
|
variables.Remove(varName);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Empty the complete variable list.
|
||||||
|
/// </summary>
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
variables.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Exception
|
||||||
|
public class VariableValueNotFoundException : ApplicationException
|
||||||
|
{
|
||||||
|
public VariableValueNotFoundException()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
public VariableValueNotFoundException(string message) : base(message)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
public VariableValueNotFoundException(string message, Exception inner) : base(message, inner)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
86
Test_EnvSetzen/Test_EnvSetzen.csproj
Normal file
86
Test_EnvSetzen/Test_EnvSetzen.csproj
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{7FD1CE85-E6D6-41D9-9C94-A5406F012F09}</ProjectGuid>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<RootNamespace>Test_EnvSetzen</RootNamespace>
|
||||||
|
<AssemblyName>Test_EnvSetzen</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Deployment" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Form1.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Form1.Designer.cs">
|
||||||
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="ReplaceVariable.cs" />
|
||||||
|
<Compile Include="UgiiEnvParser.cs" />
|
||||||
|
<Compile Include="Variable.cs" />
|
||||||
|
<EmbeddedResource Include="Form1.resx">
|
||||||
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<None Include="Properties\Settings.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
|
<Compile Include="Properties\Settings.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
87
Test_EnvSetzen/UgiiEnvParser.cs
Normal file
87
Test_EnvSetzen/UgiiEnvParser.cs
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Test_EnvSetzen
|
||||||
|
{
|
||||||
|
class UgiiEnvParser
|
||||||
|
{
|
||||||
|
public UgiiEnvParser(string filename)
|
||||||
|
{
|
||||||
|
ParseUgiiEnv(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ParseUgiiEnv(string filename)
|
||||||
|
{
|
||||||
|
//ugii_env-Parser
|
||||||
|
string line;
|
||||||
|
System.IO.StreamReader file = new System.IO.StreamReader(filename);
|
||||||
|
|
||||||
|
string ifValue = "";
|
||||||
|
string env = "";
|
||||||
|
string value = "";
|
||||||
|
|
||||||
|
while ((line = file.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
if (line.ToLower().StartsWith("#if"))
|
||||||
|
{
|
||||||
|
if (line.ToLower().Contains("file"))
|
||||||
|
{
|
||||||
|
ifValue = ReplaceVariableThroughValue(line.Remove(0, line.ToLower().IndexOf("file") + 5));
|
||||||
|
|
||||||
|
if (File.Exists(ifValue))
|
||||||
|
{
|
||||||
|
line = file.ReadLine();
|
||||||
|
|
||||||
|
if (line.Contains("="))
|
||||||
|
{
|
||||||
|
env = line.Remove(line.IndexOf("="));
|
||||||
|
value = ReplaceVariableThroughValue(line.Remove(0, line.IndexOf("=") + 1));
|
||||||
|
Environment.SetEnvironmentVariable(env, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((line = file.ReadLine().ToLower()) != "#endif")
|
||||||
|
{
|
||||||
|
//Bis zum Ende der If-Anweisung einlesen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
line = file.ReadLine(); //Wertezeile nach der If-Anweisung
|
||||||
|
line = file.ReadLine(); //Zeile nach der Wertezeile
|
||||||
|
|
||||||
|
if (line.ToLower() == "else")
|
||||||
|
{
|
||||||
|
line = file.ReadLine();
|
||||||
|
|
||||||
|
env = line.Remove(line.IndexOf("="));
|
||||||
|
value = ReplaceVariableThroughValue(line.Remove(0, line.IndexOf("=") + 1));
|
||||||
|
Environment.SetEnvironmentVariable(env, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (line.Contains("=") & !line.StartsWith("#"))
|
||||||
|
{
|
||||||
|
env = line.Remove(line.IndexOf("="));
|
||||||
|
value = ReplaceVariableThroughValue(line.Remove(0, line.IndexOf("=") + 1));
|
||||||
|
Environment.SetEnvironmentVariable(env, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
file.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ReplaceVariableThroughValue(string value)
|
||||||
|
{
|
||||||
|
var rv = new ReplaceVariable();
|
||||||
|
return rv.ExtractVariable(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
Test_EnvSetzen/Variable.cs
Normal file
14
Test_EnvSetzen/Variable.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Test_EnvSetzen
|
||||||
|
{
|
||||||
|
class Variable
|
||||||
|
{
|
||||||
|
public string VariableName { get; set; }
|
||||||
|
public string VariableValue { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user