MCPcopy Create free account
hub / github.com/Autodesk/AutomaticComponentToolkit / buildCSharpExample

Function buildCSharpExample

Source/buildbindingcsharp.go:1088–1129  ·  view source on GitHub ↗
(componentdefinition ComponentDefinition, w LanguageWriter, outputFolder string)

Source from the content-addressed store, hash-verified

1086}
1087
1088func buildCSharpExample(componentdefinition ComponentDefinition, w LanguageWriter, outputFolder string) {
1089 NameSpace := componentdefinition.NameSpace
1090 global := componentdefinition.Global
1091
1092 w.Writeln("")
1093 w.Writeln("using System;")
1094 w.Writeln("namespace %s_Example", NameSpace)
1095 w.Writeln("{")
1096 w.Writeln(" class %s_Example", NameSpace)
1097 w.Writeln(" {")
1098 w.Writeln(" static void Main()")
1099 w.Writeln(" {")
1100 w.Writeln(" try")
1101 w.Writeln(" {")
1102 w.Writeln(" UInt32 nMajor, nMinor, nMicro;")
1103 //w.Writeln(" SetDllDirectory(\"\"); // TODO add the location of the shared library binary here")
1104 w.Writeln(" %s.Wrapper.%s(out nMajor, out nMinor, out nMicro);", NameSpace, componentdefinition.Global.VersionMethod)
1105 //w.Writeln(" SetDllDirectory(null);")
1106 w.Writeln(" string versionString = string.Format(\"%s.version = {0}.{1}.{2}\", nMajor, nMinor, nMicro);", NameSpace)
1107 if len(global.PrereleaseMethod) > 0 {
1108 w.Writeln(" string sPreReleaseInfo;")
1109 w.Writeln(" if (%s.Wrapper.%s(out sPreReleaseInfo))", NameSpace, global.PrereleaseMethod)
1110 w.Writeln(" versionString = versionString + '-' + sPreReleaseInfo;")
1111 }
1112 if len(global.BuildinfoMethod) > 0 {
1113 w.Writeln(" string sBuildInfo;")
1114 w.Writeln(" if (%s.Wrapper.%s(out sBuildInfo))", NameSpace, global.BuildinfoMethod)
1115 w.Writeln(" versionString = versionString + '-' + sBuildInfo;")
1116 }
1117 w.Writeln(" Console.WriteLine(versionString);")
1118 w.Writeln(" }")
1119 w.Writeln(" catch (Exception e)")
1120 w.Writeln(" {")
1121 w.Writeln(" Console.WriteLine(\"Exception: \\\"\" + e.Message + \"\\\"\");")
1122 w.Writeln(" }")
1123 w.Writeln(" Console.WriteLine(\"Press any key to exit.\");")
1124 w.Writeln(" Console.ReadKey();")
1125 w.Writeln(" }")
1126 w.Writeln(" }")
1127 w.Writeln("}")
1128 w.Writeln("")
1129}
1130
1131// newUUID generates a random UUID according to RFC 4122
1132// taken from https://play.golang.org/p/4FkNSiUDMg to not rely on external dependencies

Callers 1

BuildBindingCSharpFunction · 0.85

Calls 1

WritelnMethod · 0.80

Tested by

no test coverage detected