<#
.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
#>


# get working directory
[string]$act_dir = $PWD
# set path to the xsd.exe
[string] $xsd_name = ${Env:ProgramFiles(x86)}+'\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\xsd.exe'
# remove old cs-files
rm "*.cs"
#[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;
## download all schema files needed from the tracim server
#$client = new-object System.Net.WebClient

#$url = "https://tracim.ptb.de/tracim/api/schema/PTB_MATH_SWTG_v1_test.xsd"
#$output = $act_dir + '\PTB_MATH_SWTG_v1_test.xsd'
#Invoke-WebRequest -Uri $url -OutFile $output

#$url = "https://tracim.ptb.de/tracim/api/schema/PTB_MATH_SWTG_v1_result.xsd"
#$output = $act_dir + '\PTB_MATH_SWTG_v1_result.xsd'
#Invoke-WebRequest -Uri $url -OutFile $output

#$url = "https://tracim.ptb.de/tracim/api/schema/tracim.xsd"
#$output = $act_dir + '\tracim.xsd'
#Invoke-WebRequest -Uri $url -OutFile $output


# start building of classes
$ps = new-object System.Diagnostics.Process
$ps.StartInfo.Filename = $xsd_name
$ps.StartInfo.Arguments = $act_dir + '\tracim.xsd ' +  $act_dir + '\GDE_3_3.xsd ' +   $act_dir + '\PTB_MATH_SWTG_v1_test.xsd ' +  $act_dir + '\PTB_MATH_SWTG_v1_result.xsd /classes /namespace:tracimPTB_SWTGear /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_SWTGear.cs" -confirm -force
