コード例 #1
0
ファイル: MainClass-JS.cs プロジェクト: vini-cesar/NUglify
        void ProcessRenamingFile(string filePath)
        {
            using (var fileReader = new StreamReader(filePath))
            {
                try
                {
                    using (var reader = XmlReader.Create(fileReader))
                    {
                        // let the manifest factory do all the heavy lifting of parsing the XML
                        // into config objects
                        var config = ManifestFactory.Create(reader);
                        if (config != null)
                        {
                            // add any rename pairs
                            foreach (var pair in config.RenameIdentifiers)
                            {
                                uglifyCommandParser.JSSettings.AddRenamePair(pair.Key, pair.Value);
                            }

                            // add any no-rename identifiers
                            uglifyCommandParser.JSSettings.SetNoAutoRenames(config.NoRenameIdentifiers);
                        }
                    }
                }
                catch (XmlException e)
                {
                    // throw an error indicating the XML error
                    System.Diagnostics.Debug.WriteLine(e.ToString());
                    throw new NotSupportedException(NUglify.InputXmlError.FormatInvariant(e.Message));
                }
            }
        }
コード例 #2
0
        public static Manifest ReadManifestFile(string xmlPath)
        {
            Manifest manifest = null;

            // create the file reader
            using (var fileReader = new StreamReader(xmlPath))
            {
                // create the xml reader from the file string using these settings
                var settings = new XmlReaderSettings()
                {
                    IgnoreComments = true,
                    IgnoreProcessingInstructions = true,
                    IgnoreWhitespace             = true,
                };

                using (var reader = XmlReader.Create(fileReader, settings))
                {
                    manifest = ManifestFactory.Create(reader);
                }
            }

            return(manifest);
        }