예제 #1
0
        static void XapFiles(ZipArchive zip, string dir) {
            ICollection<LanguageInfo> langs;
            IList<Uri> assemblies, externals;

            string manifestPath = Path.Combine(dir, "AppManifest.xaml");
            if (File.Exists(manifestPath)) {
                langs = FindSourceLanguages(dir);
                assemblies = GetManifestAssemblies(manifestPath);

                // Note: because the manifest file already exists, nothing 
                // needs to be done to support TPEs: Chiron doesn't need to host
                // them because they are assumed to be a well-known internet location.
                externals = null;
            } else {
                using (Stream appManifest = zip.Create("AppManifest.xaml")) {
                    GenerateManifest(dir, out langs, out assemblies, out externals).Save(appManifest);
                }
            }

            AddAssemblies(zip, dir, assemblies);

            GenerateLanguagesConfig(zip, langs);

            AddPathDirectories(zip);

            // add files on disk last so they always overwrite generated files
            zip.CopyFromDirectory(dir, "");
            
            zip.Close();
        }
예제 #2
0
        static void XapFiles(ZipArchive zip, string dir) {
            ICollection<LanguageInfo> langs;
            IList<Uri> assemblies, externals;

            string manifestPath = Path.Combine(dir, "AppManifest.xaml");
            if (File.Exists(manifestPath)) {
                langs = FindSourceLanguages(dir);
                GetManifestParts(manifestPath, out assemblies, out externals);
            } else {
                using (Stream appManifest = zip.Create("AppManifest.xaml")) {
                    GenerateManifest(dir, out langs, out assemblies, out externals).Save(appManifest);
                }
            }

            AddAssemblies(zip, dir, assemblies);

            GenerateLanguagesConfig(zip, langs);

            AddPathDirectories(zip);

            // add files on disk last so they always overwrite generated files
            zip.CopyFromDirectory(dir, "");
            
            zip.Close();
        }
예제 #3
0
        static void XapFiles(ZipArchive zip, string dir) {
            ICollection<LanguageInfo> langs = FindSourceLanguages(dir);
            
            string manifestPath = Path.Combine(dir, "AppManifest.xaml");
            IList<Uri> assemblies;

            if (File.Exists(manifestPath)) {
                assemblies = GetManifestAssemblies(manifestPath);
            } else {
                assemblies = GetLanguageAssemblies(langs);
                // generate the manfiest
                using (Stream appManifest = zip.Create("AppManifest.xaml")) {
                    Chiron.ManifestTemplate.Generate(assemblies).Save(appManifest);
                }
            }

            AddAssemblies(zip, dir, assemblies);

            GenerateLanguagesConfig(zip, langs);

            AddPathDirectories(zip);

            // add files on disk last so they always overwrite generated files
            zip.CopyFromDirectory(dir, "");
            
            zip.Close();
        }
예제 #4
0
        // Generates languages.config file
        // this is needed by the DLR to load arbitrary DLR-based languages implementations
        private static void GenerateLanguagesConfig(ZipArchive zip, ICollection<LanguageInfo> langs) {
            bool needLangConfig = false;
            foreach (LanguageInfo lang in langs) {
                if (lang.LanguageContext != "") {
                    needLangConfig = true;
                    break;
                }
            }

            // Only need language configuration file for non-builtin languages
            if (needLangConfig) {
                Stream outStream = zip.Create("languages.config");
                StreamWriter writer = new StreamWriter(outStream);
                writer.WriteLine("<Languages>");

                foreach (LanguageInfo lang in langs) {
                    writer.WriteLine("  <Language");
                    writer.WriteLine("            names=\"{0}\"", lang.GetNames());
                    writer.WriteLine("            languageContext=\"{0}\"", lang.LanguageContext);
                    writer.WriteLine("            extensions=\"{0}\"", lang.GetExtensionsString());
                    writer.WriteLine("            assemblies=\"{0}\"", lang.GetAssemblyNames());
                    writer.WriteLine("            external=\"{0}\"", lang.External);
                    writer.WriteLine("  />");
                    
                }

                writer.WriteLine("</Languages>");
                writer.Close();
            }
        }