public CSInfo(CodeSystem cs) { this.CodeSystem = cs; this.ClassCode = new CodeEditor(); this.ClassCode.TryAddUserMacro("ClassName", CSMisc.CodeSystemName(this)); this.ClassCode.Load(Path.Combine("Templates", "CodeSystem.txt")); }
void BuildValueSet(VSInfo vi) { vi.ClassCode.Blocks.Find("Fields") .DefineBlock(out CodeBlockNested fieldsBlock) ; vi.ClassCode.Blocks.Find("Methods") .DefineBlock(out CodeBlockNested methodBlock) ; if (vi.ValueSet.Compose.Exclude.Count > 0) { throw new NotImplementedException("Have not implemented ValueSet.Compose.Exclude"); } methodBlock .AppendCode($"public static IEnumerable<TCoding> Codes()") .OpenBrace() ; foreach (ValueSet.ConceptSetComponent component in vi.ValueSet.Compose.Include) { if (component.Filter.Count > 0) { throw new NotImplementedException("Have not implemented ValueSet.Compose.Include.Filter"); } foreach (ValueSet.ConceptReferenceComponent concept in component.Concept) { if (this.CodeSystems.TryGetValue(component.System, out CSInfo ci) == false) { throw new Exception($"CodeSystem {component.System} not found"); } String codeName = CSMisc.CodeName(concept.Code); String codingReference = $"{CSMisc.CodeSystemName(ci)}.{codeName}"; fieldsBlock .AppendCode($"public static TCoding {codeName} = new TCoding({codingReference});") ; methodBlock .AppendCode($"yield return {codeName};") ; } } methodBlock .CloseBrace() ; }
void SaveAll() { this.resourceFactoryEditor.Save(); this.fc.Mark(this.resourceFactoryEditor.SavePath); foreach (SDInfo fi in this.SDFragments.Values) { this.Save(fi.InterfaceEditor, Path.Combine(this.OutputDir, "Generated", "Interfaces", $"{CSMisc.InterfaceName(fi)}.cs")); if (fi.ClassEditor != null) { if ( (fi.IsFragment() == true) || (fi.StructDef.BaseDefinition == Global.ExtensionUrl) ) { this.Save(fi.ClassEditor, Path.Combine(this.OutputDir, "Generated", "Class", $"{CSMisc.ClassName(fi)}.txt")); } else { this.Save(fi.ClassEditor, Path.Combine(this.OutputDir, "Generated", "Class", $"{CSMisc.ClassName(fi)}.cs")); } } if (fi.SubClassEditor != null) { this.Save(fi.SubClassEditor, Path.Combine(this.OutputDir, "Generated", "Class", $"{CSMisc.ClassName(fi)}Local.cs")); } } foreach (CSInfo ci in this.CodeSystems.Values) { this.Save(ci.ClassCode, Path.Combine(this.OutputDir, "Generated", "CodeSystems", $"{CSMisc.CodeSystemName(ci)}.cs")); } foreach (VSInfo vi in this.ValueSets.Values) { this.Save(vi.ClassCode, Path.Combine(this.OutputDir, "Generated", "ValueSets", $"{CSMisc.ValueSetName(vi)}.cs")); } }