<#
.SYNOPSIS 
    PTB_MATH_Thread3D C# class builder
.Description
    Helper script to download xml schemas for the PTB_MATH_Thread3D test and build the according C# classes
#>
# set path to the xsd.exe tool
[string] $xsd_name = ${Env:ProgramFiles(x86)}+'\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\xsd.exe'
# remove old cs-files
rm "*.cs"
# download all schema files needed from the tracim server
$client = new-object System.Net.WebClient

$client.DownloadFile("http://n191001:7778/tracim/api/schema/PTB_MATH_Thread3D_v1_test.xsd","PTB_MATH_Thread3D_v1_test.xsd")
$client.DownloadFile("http://n191001:7778/tracim/api/schema/PTB_MATH_Thread3D_v1_result.xsd","PTB_MATH_Thread3D_v1_result.xsd")
$client.DownloadFile("http://n191001:7778/tracim/api/schema/tracim.xsd","tracim.xsd")
$client.DownloadFile("https://www.vdi.de/fileadmin/xml/2610/V3-1/GDE_3_1.xsd","GDE_3_1.xsd")

# start building of classes
$ps = new-object System.Diagnostics.Process
$ps.StartInfo.Filename = $xsd_name
$ps.StartInfo.Arguments = 'tracim.xsd PTB_MATH_Thread3D_v1_test.xsd PTB_MATH_Thread3D_v1_result.xsd /classes /namespace:tracimPTB_Thread3D /language:CS'
$ps.StartInfo.RedirectStandardOutput = $True
$ps.StartInfo.UseShellExecute = $false
$ps.start()
$ps.WaitForExit()
[string] $Out = $ps.StandardOutput.ReadToEnd();
# move and rename created class file to the project directory
[string] $csfile = dir "*.cs"
mv $csfile "..\tracimPTB_Thread3D.cs" -confirm -force
