示例#1
0
        public SDInfo(IConversionInfo ci, StructureDefinition sd)
        {
            this.StructDef = sd;
            ElementTreeLoader l = new ElementTreeLoader(ci);

            if (sd.Snapshot == null)
            {
                SnapshotCreator.Create(sd);
            }

            this.DiffNodes = l.Create(sd.Differential.Element);
            this.SnapNodes = l.Create(sd.Snapshot.Element);

            this.InterfaceEditor = new CodeEditor();
            this.InterfaceEditor.TryAddUserMacro("ClassName", CS.CSMisc.ClassName(this));
            this.InterfaceEditor.TryAddUserMacro("InterfaceName", CS.CSMisc.InterfaceName(this));
            this.InterfaceEditor.Load(Path.Combine("Templates", "Interface.txt"));
            this.AddMacros(this.InterfaceEditor, this);

            this.SubClassEditor = new CodeEditor();
            this.AddMacros(this.SubClassEditor, this);
            this.SubClassEditor.TryAddUserMacro("FhirBase", this.StructDef.BaseDefinition.LastUriPart());
            this.SubClassEditor.TryAddUserMacro("BaseClass", CS.CSMisc.ClassName(this));
            this.SubClassEditor.Load(Path.Combine("Templates", "SubClass.txt"));

            this.ClassEditor = new CodeEditor();
            this.AddMacros(this.ClassEditor, this);
            this.ClassEditor.TryAddUserMacro("ClassName", CS.CSMisc.ClassName(this));
            if (this.IsFragment())
            {
                this.ClassEditor.Load(Path.Combine("Templates", "Fragment.txt"));
            }
            else
            {
                this.ClassEditor.Load(Path.Combine("Templates", "Class.txt"));
            }

            this.CodeBlocks = ClassCodeBlocks.Create(this.InterfaceEditor,
                                                     this.ClassEditor,
                                                     this.SubClassEditor);
        }
        public static ClassCodeBlocks Create(CodeEditor interfaceEditor,
                                             CodeEditor classEditor,
                                             CodeEditor subClassEditor)
        {
            ClassCodeBlocks retVal = new ClassCodeBlocks();

            retVal.ClassProperties        = classEditor?.Blocks.Find("Properties", false);
            retVal.ClassConstructor       = classEditor?.Blocks.Find("Constructor", false);
            retVal.ClassMethods           = classEditor?.Blocks.Find("Methods", false);
            retVal.ClassValidateCodeStart = classEditor?.Blocks.Find("ValidateCodeStart", false);
            retVal.ClassValidateCode      = classEditor?.Blocks.Find("ValidateCode", false);
            retVal.ClassWriteCode         = classEditor?.Blocks.Find("WriteCode", false);
            retVal.ClassReadCode          = classEditor?.Blocks.Find("ReadCode", false);

            retVal.LocalClassDefs = subClassEditor?.Blocks.Find("LocalClassDefs", false);
            retVal.LocalUsings    = subClassEditor?.Blocks.Find("Usings", false);

            retVal.InterfaceProperties = interfaceEditor?.Blocks.Find("Properties", false);
            retVal.InterfaceMethods    = interfaceEditor?.Blocks.Find("Methods", false);

            return(retVal);
        }