예제 #1
0
        private static async Task <XDocument> MigrateBundle(XDocument doc, string fileName, string root, string folder)
        {
            string[] attrNames = new[] { "runOnBuild", "minify", "output" };
            XElement bundle    = doc.Descendants("bundle").FirstOrDefault();

            string[] attributes = bundle.Attributes()
                                  .Where(a => attrNames.Contains(a.Name.ToString()))
                                  .Select(a => a.Name.ToString())
                                  .ToArray();

            if (attributes.Count() == 0)
            {
                return(doc);
            }

            IEnumerable <string> constituentFiles = from f in doc.Descendants("file")
                                                    select ProjectHelpers.ToAbsoluteFilePath(f.Value, root, folder);

            BundleDocument newDoc = new BundleDocument(fileName, constituentFiles.ToArray());

            if (attributes.Contains("runOnBuild"))
            {
                newDoc.RunOnBuild = bundle.Attribute("runOnBuild").Value.Equals("true", StringComparison.OrdinalIgnoreCase);
            }

            if (attributes.Contains("minify"))
            {
                newDoc.Minified = bundle.Attribute("minify").Value.Equals("true", StringComparison.OrdinalIgnoreCase);
            }

            return(await newDoc.WriteBundleRecipe());
        }
예제 #2
0
        private async Task MakeBundleAsync(string extension)
        {
            string bundleFile;

            if (!GetFileName(out bundleFile, extension))
            {
                return;
            }

            try
            {
                BundleDocument doc = new BundleDocument(bundleFile, _files.ToArray());

                await doc.WriteBundleRecipe();
                await GenerateAsync(doc, extension);
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                MessageBox.Show("Error generating the bundle. See output window for details");
                _dte.StatusBar.Text = "Bundle was not created";
            }
        }
예제 #3
0
        private static async Task<XDocument> MigrateBundle(XDocument doc, string fileName, string root, string folder)
        {
            string[] attrNames = new[] { "runOnBuild", "minify", "output" };
            XElement bundle = doc.Descendants("bundle").FirstOrDefault();
            string[] attributes = bundle.Attributes()
                                        .Where(a => attrNames.Contains(a.Name.ToString()))
                                        .Select(a => a.Name.ToString())
                                        .ToArray();

            if (attributes.Count() == 0)
                return doc;

            IEnumerable<string> constituentFiles = ProjectHelpers.GetBundleConstituentFiles(doc.Descendants("file").Select(s => s.Value), root, folder, fileName);
            if (constituentFiles.Count() > 0)
            {
                BundleDocument newDoc = new BundleDocument(fileName, constituentFiles.ToArray());

                if (attributes.Contains("runOnBuild"))
                    newDoc.RunOnBuild = bundle.Attribute("runOnBuild").Value.Equals("true", StringComparison.OrdinalIgnoreCase);

                if (attributes.Contains("minify"))
                    newDoc.Minified = bundle.Attribute("minify").Value.Equals("true", StringComparison.OrdinalIgnoreCase);

                return await newDoc.WriteBundleRecipe();
            }
            else
            {
                return null;
            }
        }
예제 #4
0
        private async Task MakeBundleAsync(string extension)
        {
            string bundleFile;

            if (!GetFileName(out bundleFile, extension))
                return;

            try
            {
                BundleDocument doc = new BundleDocument(bundleFile, _files.ToArray());

                await doc.WriteBundleRecipe();
                await GenerateAsync(doc, extension);
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                MessageBox.Show("Error generating the bundle. See output window for details");
                _dte.StatusBar.Text = "Bundle was not created";
            }
        }
예제 #5
0
        private static XDocument MigrateBundle(XDocument doc, string fileName, string root, string folder)
        {
            string[] attrNames = new[] { "runOnBuild", "minify", "output" };
            XElement bundle = doc.Descendants("bundle").FirstOrDefault();
            string[] attributes = bundle.Attributes()
                                        .Where(a => attrNames.Contains(a.Name.ToString()))
                                        .Select(a => a.Name.ToString())
                                        .ToArray();

            if (attributes.Count() == 0)
                return doc;

            IEnumerable<string> constituentFiles = from f in doc.Descendants("file")
                                                   select ProjectHelpers.ToAbsoluteFilePath(f.Value, root, folder);
            BundleDocument newDoc = new BundleDocument(fileName, constituentFiles.ToArray());

            if (attributes.Contains("runOnBuild"))
                newDoc.RunOnBuild = bundle.Attribute("runOnBuild").Value.Equals("true", StringComparison.OrdinalIgnoreCase);

            if (attributes.Contains("minify"))
                newDoc.RunOnBuild = bundle.Attribute("minify").Value.Equals("true", StringComparison.OrdinalIgnoreCase);

            newDoc.WriteBundleRecipe().DoNotWait("Migrating bundle to new schema.");

            try
            {
                return XDocument.Load(fileName);
            }
            catch (XmlException)
            {
                return null;
            }
        }