/// <summary> /// Perform local processing of container class. /// </summary> protected override void BuildContainerClassLocal(ClassCodeBlocks itemCodeBlocks) { base.BuildContainerClassLocal(itemCodeBlocks); this.sectionCodeMethodName = $"SectionCode"; FhirConstruct.Construct(itemCodeBlocks.ClassMethods, this.sectionCode, this.sectionCodeMethodName, out String dummy); }
/// <summary> /// Perform local processing of container class. /// </summary> protected override void BuildContainerClassLocal(ClassCodeBlocks itemCodeBlocks) { base.BuildContainerClassLocal(itemCodeBlocks); this.componentCodeMethodName = $"{this.sliceName.ToMachineName()}_ComponentCode"; FhirConstruct.Construct(itemCodeBlocks.ClassMethods, this.componentCode, this.componentCodeMethodName, out String dummy, "private static"); }
public String DefineFixed(String path, Element fixedValue) { if (this.fragBase.StructDef.Url.LastUriPart().Contains("ObservedFeature") == true) { Trace.WriteLine("xxyyz"); } this.fragBase.ClassMethods .SummaryOpen() .Summary($"Method to create fixed value") .SummaryClose() ; String methodName = $"FixedValue_{path}".ToMachineName(); FhirConstruct.Construct(this.fragBase.ClassMethods, fixedValue, methodName, out String propertyType); return(methodName); }
public void FhirConstructB() { CodeEditor editor = new CodeEditor(); CodeBlockNested main = editor.Blocks.AppendBlock(); main .AppendLine($"using System;") .AppendLine($"using System.Linq;") .AppendLine($"using System.Collections.Generic;") .AppendLine($"using System.Reflection;") .AppendLine($"using System.Text;") .AppendLine($"using FhirKhit.ProfGen.PGShared;") .AppendLine($"using FhirKhit.ProfGen.PGShared.CodeGen.CSApi.Extensions;") .AppendLine($"using FhirKhit.Tools;") .AppendLine($"using Hl7.Fhir.Introspection;") .AppendLine($"using Hl7.Fhir.Model;") .AppendLine($"using Hl7.Fhir.Support.Model;") .AppendLine($"using System.Diagnostics;") .AppendLine($"using Hl7.FhirPath;") .BlankLine() .AppendLine($"namespace FhirKhit.ProfGen.GenTests") .OpenBrace() .AppendCode($"public class FhirConstructUse") .OpenBrace() ; CodeBlockNested construct = main.AppendBlock(); CodeBlockNested methods = main.AppendBlock(); main .CloseBrace() .CloseBrace() ; construct .AppendLine($"/// <summary>") .AppendLine($"/// generate code for eqch fhri element. Makes sure it compiles.") .AppendLine($"/// </summary>") .AppendCode($"public void Use()") .OpenBrace() .BlankLine() ; Int32 varNum = 0; foreach (FHIRAllTypes fhirType in Enum.GetValues(typeof(FHIRAllTypes)).OfType <FHIRAllTypes>()) { Trace.WriteLine($"fhirType {fhirType}"); String fhirTypeName = ModelInfo.FhirTypeToFhirTypeName(fhirType); Type fhirCSType = ModelInfo.GetTypeForFhirType(fhirTypeName); if (ModelInfo.IsPrimitive(fhirType)) { String varName1 = $"x{++varNum}"; String methodName1 = $"Method{++varNum}"; construct .AppendCode($"{fhirCSType} {varName1} = {methodName1}();") ; Element fix = CreateFix(fhirCSType); FhirConstruct.Construct(methods, fix, methodName1, out String propertyType1); } else if (ModelInfo.IsDataType(fhirType)) { if (Ignore(fhirType) == false) { String varName1 = $"x{++varNum}"; String methodName1 = $"Method{++varNum}"; construct .AppendCode($"{fhirCSType} {varName1} = {methodName1}();") ; Element fix = CreateFix(fhirCSType); FhirConstruct.Construct(methods, fix, methodName1, out String propertyType1); } } } construct .CloseBrace() ; #if FHIR_R2 String outputPath = Path.Combine(DirHelper.FindParentDir("Projects"), "ProfGen", "R2", "FhirKhit.ProfGen.GenTests.R2", "Generated", "FhirConstructUse.cs"); #elif FHIR_R3 String outputPath = Path.Combine(DirHelper.FindParentDir("Projects"), "ProfGen", "R3", "FhirKhit.ProfGen.GenTests.R3", "Generated", "FhirConstructUse.cs"); #elif FHIR_R4 String outputPath = Path.Combine(DirHelper.FindParentDir("Projects"), "ProfGen", "R4", "FhirKhit.ProfGen.GenTests.R4", "Generated", "FhirConstructUse.cs"); #endif editor.Save(outputPath); }