예제 #1
0
        /// <summary>
        /// Load applets in <paramref name="appletDirectories"/>
        /// </summary>
        private static void LoadApplets(IEnumerable <String> appletDirectories, IAppletManagerService appService)
        {
            foreach (var appletDir in appletDirectories)// Directory.GetFiles(this.m_configuration.GetSection<AppletConfigurationSection>().AppletDirectory)) {
            {
                try
                {
                    if (!Directory.Exists(appletDir) || !File.Exists(Path.Combine(appletDir, "manifest.xml")))
                    {
                        throw new DirectoryNotFoundException($"Applet {appletDir} not found");
                    }

                    String appletPath = Path.Combine(appletDir, "manifest.xml");
                    using (var fs = File.OpenRead(appletPath))
                    {
                        AppletManifest manifest = AppletManifest.Load(fs);
                        (appService as MiniAppletManagerService).m_appletBaseDir.Add(manifest, appletDir);
                        // Is this applet in the allowed applets

                        // public key token match?
                        appService.LoadApplet(manifest);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Load a solution file and all referneced applets
        /// </summary>
        private static void LoadSolution(String solutionFile, IAppletManagerService appService)
        {
            using (var fs = File.OpenRead(solutionFile))
            {
                var solution = AppletManifest.Load(fs);

                // Load include elements
                var solnDir = Path.GetDirectoryName(solutionFile);

                // Preload any manifests
                var refManifests = new Dictionary <String, AppletManifest>();
                // Load reference manifests
                foreach (var mfstFile in Directory.GetFiles(solnDir, "manifest.xml", SearchOption.AllDirectories))
                {
                    using (var manifestStream = File.OpenRead(mfstFile))
                    {
                        refManifests.Add(Path.GetDirectoryName(mfstFile), AppletManifest.Load(manifestStream));
                    }
                }

                // Load dependencies
                foreach (var dep in solution.Info.Dependencies)
                {
                    // Attempt to load the appropriate manifest file
                    var cand = refManifests.FirstOrDefault(o => o.Value.Info.Id == dep.Id);
                    if (cand.Value != null)
                    {
                        (appService as MiniAppletManagerService).m_appletBaseDir.Add(cand.Value, cand.Key);
                        // Is this applet in the allowed applets

                        // public key token match?
                        appService.LoadApplet(cand.Value);
                    }
                }
            }
        }