Exemplo n.º 1
0
        internal static void Parse(string PackageName, PackageRepository mifRepo, ClassRepository repo)
        {
            // Find the package that contains the class we want
            Package pkg = mifRepo.Find(p => p.PackageLocation.ToString(MifCompiler.NAME_FORMAT) == PackageName) as Package;
            
            if (pkg == null) // Check if package was found
            {
                System.Diagnostics.Trace.WriteLine(string.Format("Could not find static model '{0}'. Any dependent models may not be rendered correctly!", PackageName), "warn");
                return;
            }

            // Process the package
            IPackageCompiler comp = null;
            if (pkg is GlobalStaticModel)
                comp = new StaticModelCompiler();
            else if (pkg is SerializedStaticModel)
                comp = new SerializedStaticModelCompiler();
            else
            {
                System.Diagnostics.Trace.WriteLine(String.Format("Can't find an appropriate compiler for package '{0}'... Package will not be parsed", PackageName), "error");
                return;
            }
            comp.ClassRepository = repo;
            comp.Package = pkg;
            comp.PackageRepository = pkg.MemberOfRepository;
            comp.Compile();
        }
Exemplo n.º 2
0
        internal static void ParseClassFromPackage(string ClassName, PackageRepository mifRepo, ClassRepository repo)
        {
            // Class and package location
            string classNamePart = ClassName.Substring(ClassName.IndexOf(".") + 1);
            string packageLocationPart = ClassName.Substring(0, ClassName.IndexOf("."));

            // Find the package that contains the class we want
            GlobalStaticModel pkg = mifRepo.Find(p => (p is GlobalStaticModel) &&
                (p as GlobalStaticModel).OwnedClass.Find(c => c.Choice is MohawkCollege.EHR.HL7v3.MIF.MIF20.StaticModel.Flat.Class &&
                    (c.Choice as MohawkCollege.EHR.HL7v3.MIF.MIF20.StaticModel.Flat.Class).Name == classNamePart) != null &&
                p.PackageLocation.ToString(MifCompiler.NAME_FORMAT) == packageLocationPart) as GlobalStaticModel;


            // Process the package
            if (pkg == null)
                throw new InvalidOperationException(string.Format("Can't find '{0}' in the package repository, cannot continue processing", ClassName));

            StaticModelCompiler comp = new StaticModelCompiler();
            comp.ClassRepository = repo;
            comp.Package = pkg;
            comp.PackageRepository = pkg.MemberOfRepository;
            comp.Compile();
        }