Esempio n. 1
0
        void BuildExtension(ElementTreeSlice extensionSlice)
        {
            this.itemCodeBlocks.LocalUsings = this.codeBlocks.LocalUsings;
            BuildMemberExtension bme = new BuildMemberExtension(this.defineBase,
                                                                this.itemCodeBlocks,
                                                                extensionSlice,
                                                                extensionSlice.ElementDefinition.SliceName.ToMachineName());

            bme.Build();
        }
Esempio n. 2
0
        public override void Build()
        {
            const String fcn = "Build";

            this.CSBuilder.ConversionInfo(this.GetType().Name,
                                          fcn,
                                          $"Building {this.fragBase.StructDef.Url.LastUriPart()}");

            base.Build();

            //{
            //    if (this.fragBase.SnapNodes.TryGetElementNode("Extension.extension", out ElementTreeNode extensionNode) == false)
            //        throw new Exception($"Extension.extension node is missing");
            //    BuildItemExtension bmv = new BuildItemExtension(this, this.fragBase.CodeBlocks);
            //    bmv.Build(CSMisc.ClassName(this.fragBase), extensionNode);
            //}
            {
                BuildMembers.BuildMemberExtension bm = new BuildMembers.BuildMemberExtension(this,
                                                                                             this.fragBase.CodeBlocks,
                                                                                             this.fragBase.SnapNodes.DefaultSlice,
                                                                                             CSMisc.ClassName(this.fragBase));
                bm.Build();
            }
        }
        void BuildExtensionItemClass()
        {
            ClassCodeBlocks itemClassBlocks = new ClassCodeBlocks();

            this.itemCode
            .AppendCode($"#region {this.pathName} Member Class")
            .SummaryOpen()
            .Summary($"Extension class for {this.extensionName}.")
            .SummaryClose()
            .AppendCode($"public class {this.ElementGetName}")
            .OpenBrace()
            .AppendCode($"// Definitions")
            .DefineBlock(out itemClassBlocks.LocalClassDefs)
            .AppendCode($"// Properties")
            .DefineBlock(out itemClassBlocks.ClassProperties)
            .BlankLine()
            .SummaryOpen()
            .Summary($"Constructor")
            .SummaryClose()
            .AppendCode($"public {this.ElementGetName}()")
            .OpenBrace()
            .DefineBlock(out itemClassBlocks.ClassConstructor)
            .CloseBrace()

            .BlankLine()
            .AppendCode($"// Methods")
            .DefineBlock(out itemClassBlocks.ClassMethods)

            .BlankLine()
            .SummaryOpen()
            .Summary("Write item as a fhir element.")
            .SummaryClose()
            .AppendCode($"public Extension WriteMember(BreastRadiologyDocument doc)")
            .OpenBrace()
            .AppendCode($"List<Extension> extensionList = new List<Extension>();")
            .DefineBlock(out itemClassBlocks.ClassWriteCode)
            .AppendCode($"return new {this.FhirClassName}")
            .OpenBrace()
            .AppendCode($"Url = ExtensionUrl,")
            .AppendCode($"Extension = extensionList")
            .CloseBrace(";")
            .CloseBrace()

            .BlankLine()
            .SummaryOpen()
            .Summary("Read from fhir element into member item.")
            .SummaryClose()
            .AppendCode($"public void ReadMember(BreastRadiologyDocument doc, Extension extension)")
            .OpenBrace()
            .AppendCode($"if (extension.Url != ExtensionUrl)")
            .AppendCode($"    throw new Exception($\"Invalid extension url '{{extension.Url}}', expected '{{ExtensionUrl}}'\");")
            .AppendCode($"List<Extension> extensionList = extension.Extension;")
            .DefineBlock(out itemClassBlocks.ClassReadCode)
            .CloseBrace()

            .CloseBrace()
            .AppendCode($"#endregion")
            ;

            ElementTreeNode extension = this.extensionSlice.Nodes.GetItem("extension");

            foreach (var extensionSlice in extension.Slices.Skip(1))
            {
                itemClassBlocks.LocalUsings = this.codeBlocks.LocalUsings;
                BuildMemberExtension bm = new BuildMemberExtension(this.defineBase,
                                                                   itemClassBlocks,
                                                                   extensionSlice,
                                                                   extensionSlice.ElementDefinition.SliceName);
                bm.Build();
            }
        }