コード例 #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();
        }
コード例 #2
0
 public PackageService(BuildService builds, IPackageStore store, IPackageCompiler compiler, ILogger <PackageService> logger)
 {
     _builds   = builds;
     _store    = store;
     _compiler = compiler;
     _logger   = logger;
 }
コード例 #3
0
        public void Compile()
        {
            // Get compilers that we can use to compile data
            Dictionary <Type, Type> compilers = new Dictionary <Type, Type>();

            foreach (Type t in this.GetType().Assembly.GetTypes())
            {
                if (t.GetInterface("MohawkCollege.EHR.gpmr.Pipeline.Compiler.IPackageCompiler") != null &&
                    t.Namespace == "MohawkCollege.EHR.gpmr.Pipeline.Compiler.Mif20.Compilers")
                {
                    IPackageCompiler c = (IPackageCompiler)this.GetType().Assembly.CreateInstance(t.FullName);
                    compilers.Add(c.PackageType, t);
                }
            }

            // Prepare for compile
            repository.Sort(new PackageArtifact.Comparator());

            // Parse the sorted list
            foreach (PackageArtifact pkg in repository)
            {
                if (compilers.ContainsKey(pkg.GetType()))
                {
                    IPackageCompiler pkc = (IPackageCompiler)this.GetType().Assembly.CreateInstance(compilers[pkg.GetType()].FullName);
                    pkc.ClassRepository   = this.ClassRepository;
                    pkc.Package           = pkg;
                    pkc.PackageRepository = repository;
                    pkc.Compile();
                }
                else
                {
                    System.Diagnostics.Trace.WriteLine(string.Format("Can't compile '{0}', no compiler understands {1}", pkg.PackageLocation.ToString(MifCompiler.NAME_FORMAT), pkg.GetType().Name), "warn");
                }
            }
        }