コード例 #1
0
ファイル: MFsh.cs プロジェクト: goelalex/Eir.MFSH
        VariablesBlock StartNewFrag(MIFragment frag,
                                    out String name)
        {
            name = frag.Name;
            if (name.Contains('.'))
            {
                name = name.Substring(name.LastIndexOf('.') + 1);
            }

            VariablesBlock localVb = new VariablesBlock();

            localVb.Add("%Id%", name);
            localVb.Add("%FragmentId%", name);
            localVb.Add("%FParent%", frag.Parent);
            localVb.Add("%FTitle%", frag.Title);
            localVb.Add("%FDescription%", frag.Description);
            String fragmentUrl = $"{this.BaseUrl}/StructureDefinition/{name}";

            localVb.Add("%FUrl%", fragmentUrl);

            //this.appliedMacros.Clear();
            //this.incompatibleMacros.Clear();
            return(localVb);
        }
コード例 #2
0
ファイル: MFsh.cs プロジェクト: goelalex/Eir.MFSH
        void ProcessApplyMacro(MIApply apply,
                               FileData fd,
                               MIMacro macro,
                               List <VariablesBlock> local)
        {
            const String fcn = "ProcessApplyMacro";

            if (macro.Parameters.Count != apply.Parameters.Count)
            {
                String fullMsg = $"{apply.SourceFile}, line {apply.LineNumber} Macro {apply.Name} requires {macro.Parameters.Count} parameters, called with {apply.Parameters.Count}.";
                fullMsg += this.ApplyLongStackTrace();
                this.ConversionError(ClassName, fcn, fullMsg);
                return;
            }

            macro.AppliedFlag = true;
            bool firstFlag = false;

            if (this.appliedMacros.Contains(apply.Name) == false)
            {
                this.appliedMacros.Add(apply.Name);
                firstFlag = true;
            }

            if ((macro.OnceFlag == true) && (firstFlag == false))
            {
                return;
            }

            if (this.incompatibleMacros.Contains(apply.Name))
            {
                String fullMsg = $"{apply.SourceFile}, line {apply.LineNumber} Macro {apply.Name} has been marked as incompatible with this profile";
                fullMsg += this.ApplyLongStackTrace();
                this.ConversionError(ClassName, fcn, fullMsg);
                return;
            }

            local.Insert(0, macro.ApplicableVariables);
            VariablesBlock vbParameters = new VariablesBlock();

            for (Int32 i = 0; i < apply.Parameters.Count; i++)
            {
                String pName  = macro.Parameters[i];
                String pValue = apply.Parameters[i];
                if (this.variableBlocks != null)
                {
                    pValue = this.variableBlocks.ReplaceText(pValue);
                }
                vbParameters.Add(pName, pValue);
            }

            vbParameters.Add("%ApplySourceFile%", apply.SourceFile.Replace("\\", "/"));
            vbParameters.Add("%ApplyLineNumber%", apply.LineNumber.ToString());

            local.Insert(0, vbParameters);

            FileData macroData = fd;

            if (String.IsNullOrEmpty(macro.Redirect) == false)
            {
                if (this.skipRedirects == true)
                {
                    return;
                }
                this.GetFileData(macro.Redirect, local, out macroData);
            }

            this.applyStack.Push(apply);                    // this is for stack tracing during errors
            vbParameters.Add("%ApplyStackFrame%", this.ApplyShortStackTrace().Replace("\\", "/"));
            this.Process(macro.Items, macroData, local);
            this.applyStack.Pop();
        }