Пример #1
0
        public MicroApp(string base_directory)
        {
            if (!base_directory.EndsWith(Path.DirectorySeparatorChar + ""))
            {
                base_directory += Path.DirectorySeparatorChar + "";
            }
            this.base_directory = base_directory;

            // Quickly figure out a manifest for the files in the directory
            string manifest_path = (from file in Directory.EnumerateFiles(base_directory) select file).Where((f) => f.Contains("manifest.json")).FirstOrDefault();

            // Load in the application manifest
            if (manifest_path != null)
            {
                // load the manifest file into a new micro app
                JObject manifest = JsonConvert.DeserializeObject(File.ReadAllText(manifest_path)) as JObject;

                // the base manifest settings
                MicroAppManifest new_manifest = new MicroAppManifest()
                {
                    ApplicationName = manifest["app_name"].ToString(),
                    AppIcon         = manifest["app_icon"].ToString()
                };

                // set the resource file paths
                new_manifest.css_files    = (from f in manifest["css_files"] select f).Select((j) => j.ToString());
                new_manifest.script_files = (from f in manifest["scripts"] select f).Select((j) => j.ToString());

                BundledMicroApplicationPart app = Bundle(manifest);

                dynamic package_output = new
                {
                    Manifest = new_manifest,
                    Parts    = new List <BundledMicroApplicationPart>()
                };

                // widgets
                foreach (JObject widget in manifest["widgets"])
                {
                    BundledMicroApplicationPart w = Bundle(widget);
                    package_output.Parts.Add(w);
                }

                package_output.Parts.Add(app);

                string json = JsonConvert.SerializeObject(package_output);
                JSONOutput = json;
            }
            else
            {
                Console.WriteLine("Manifest could not be loaded from directory " + base_directory + "!");
                Environment.Exit(0);
            }
        }
Пример #2
0
        public MicroApp(string base_directory)
        {
            if (!base_directory.EndsWith(Path.DirectorySeparatorChar+"")) base_directory += Path.DirectorySeparatorChar + "";
            this.base_directory = base_directory;

            // Quickly figure out a manifest for the files in the directory
            string manifest_path = (from file in Directory.EnumerateFiles(base_directory) select file).Where((f) => f.Contains("manifest.json")).FirstOrDefault();

            // Load in the application manifest
            if (manifest_path != null)
            {
                // load the manifest file into a new micro app
                JObject manifest = JsonConvert.DeserializeObject(File.ReadAllText(manifest_path)) as JObject;

                // the base manifest settings
                MicroAppManifest new_manifest = new MicroAppManifest() {
                    ApplicationName = manifest["app_name"].ToString(),
                    AppIcon = manifest["app_icon"].ToString()
                };

                // set the resource file paths
                new_manifest.css_files = (from f in manifest["css_files"] select f).Select((j) => j.ToString());
                new_manifest.script_files = (from f in manifest["scripts"] select f).Select((j) => j.ToString());

                BundledMicroApplicationPart app = Bundle(manifest);

                dynamic package_output = new
                {
                    Manifest = new_manifest,
                    Parts = new List<BundledMicroApplicationPart>()
                };

                // widgets
                foreach (JObject widget in manifest["widgets"])
                {
                    BundledMicroApplicationPart w = Bundle(widget);
                    package_output.Parts.Add(w);
                }

                package_output.Parts.Add(app);

                string json = JsonConvert.SerializeObject(package_output);
                JSONOutput = json;
            }
            else
            {
                Console.WriteLine("Manifest could not be loaded from directory "+base_directory + "!");
                Environment.Exit(0);
            }
        }