Esempio n. 1
0
        internal static List<ParseException> Compact(string inputFile, string inputSource, TextWriter output, string copyright, string timeStamp, CssCompactor.Options options)
        {
            if (output == null)
            {
                throw new NullReferenceException("Output TextWriter was null.");
            }

            // write out header with copyright and timestamp
            CssCompactor.WriteHeader(output, copyright, timeStamp);

            // verify, compact and write out results
            CssParser parser = new CssParser(inputFile, inputSource);
            parser.Write(output, options);

            // return any errors
            return parser.Errors;
        }
Esempio n. 2
0
        internal static List <ParseException> Compact(string inputFile, string inputSource, TextWriter output, string copyright, string timeStamp, CssCompactor.Options options)
        {
            if (output == null)
            {
                throw new NullReferenceException("Output TextWriter was null.");
            }

            // write out header with copyright and timestamp
            CssCompactor.WriteHeader(output, copyright, timeStamp);

            // verify, compact and write out results
            CssParser parser = new CssParser(inputFile, inputSource);

            parser.Write(output, options);

            // return any errors
            return(parser.Errors);
        }
Esempio n. 3
0
        internal static List<ParseException> Compact(string inputFile, string outputFile, string copyright, string timeStamp, CssCompactor.Options options)
        {
            if (!System.IO.File.Exists(inputFile))
            {
                throw new FileNotFoundException(String.Format("File (\"{0}\") not found.", inputFile), inputFile);
            }

            if ((options & CssCompactor.Options.Overwrite) == 0x0 && System.IO.File.Exists(outputFile))
            {
                throw new AccessViolationException(String.Format("File (\"{0}\") already exists.", outputFile));
            }

            if (inputFile.Equals(outputFile, StringComparison.OrdinalIgnoreCase))
            {
                throw new ApplicationException("Input and output file are set to the same path.");
            }

            FileUtility.PrepSavePath(outputFile);
            using (TextWriter output = System.IO.File.CreateText(outputFile))
            {
                return CssCompactor.Compact(inputFile, null, output, copyright, timeStamp, options);
            }
        }
Esempio n. 4
0
        internal static List <ParseException> Compact(string inputFile, string outputFile, string copyright, string timeStamp, CssCompactor.Options options)
        {
            if (!System.IO.File.Exists(inputFile))
            {
                throw new FileNotFoundException(String.Format("File (\"{0}\") not found.", inputFile), inputFile);
            }

            if ((options & CssCompactor.Options.Overwrite) == 0x0 && System.IO.File.Exists(outputFile))
            {
                throw new AccessViolationException(String.Format("File (\"{0}\") already exists.", outputFile));
            }

            if (inputFile.Equals(outputFile, StringComparison.OrdinalIgnoreCase))
            {
                throw new ApplicationException("Input and output file are set to the same path.");
            }

            FileUtility.PrepSavePath(outputFile);
            using (TextWriter output = System.IO.File.CreateText(outputFile))
            {
                return(CssCompactor.Compact(inputFile, null, output, copyright, timeStamp, options));
            }
        }
Esempio n. 5
0
 public override void Write(TextWriter writer, CssCompactor.Options options)
 {
     writer.Write(this.Value);
 }
Esempio n. 6
0
 public override void Write(TextWriter writer, CssCompactor.Options options)
 {
     bool prettyPrint = IsPrettyPrint(options);
     if (prettyPrint)
     {
         writer.Write('\t');
     }
     writer.Write(this.Property);
     writer.Write(':');
     if (prettyPrint)
     {
         writer.Write(" ");
     }
     this.Value.Write(writer, options);
     writer.Write(";");
     if (prettyPrint)
     {
         writer.WriteLine();
     }
 }
Esempio n. 7
0
        public override void Write(TextWriter writer, CssCompactor.Options options)
        {
            bool space = false;

            foreach (CssString value in this.Values)
            {
                if (space)
                {
                    writer.Write(" ");
                }
                else
                {
                    space = true;
                }

                value.Write(writer, options);
            }
        }
Esempio n. 8
0
        public override void Write(TextWriter writer, CssCompactor.Options options)
        {
            bool prettyPrint = IsPrettyPrint(options);

            writer.Write('{');
            if (prettyPrint)
            {
                writer.WriteLine();
            }

            foreach (ICssValue value in this.Values)
            {
                value.Write(writer, options);
            }

            if (prettyPrint)
            {
                writer.WriteLine();
            }
            writer.Write('}');
        }
Esempio n. 9
0
        public override void Write(TextWriter writer, CssCompactor.Options options)
        {
            bool prettyPrint = IsPrettyPrint(options);

            bool comma = false;

            foreach (CssString selector in this.Selectors)
            {
                if (comma)
                {
                    writer.Write(",");
                    if (prettyPrint)
                    {
                        writer.WriteLine();
                    }
                }
                else
                {
                    comma = true;
                }

                selector.Write(writer, options);
            }

            if (prettyPrint)
            {
                writer.WriteLine();
            }
            writer.Write("{");
            if (prettyPrint)
            {
                writer.WriteLine();
            }

            foreach (CssDeclaration dec in this.Declarations)
            {
                dec.Write(writer, options);
            }

            writer.Write("}");
            if (prettyPrint)
            {
                writer.WriteLine();
            }
        }
Esempio n. 10
0
 protected static bool IsPrettyPrint(CssCompactor.Options options)
 {
     return (options & CssCompactor.Options.PrettyPrint) > 0;
 }
Esempio n. 11
0
 public abstract void Write(TextWriter writer, CssCompactor.Options options);
Esempio n. 12
0
        public override void Write(TextWriter writer, CssCompactor.Options options)
        {
            bool prettyPrint = IsPrettyPrint(options);

            writer.Write('@');
            writer.Write(this.ident);

            if (!String.IsNullOrEmpty(this.value))
            {
                writer.Write(' ');
                writer.Write(this.value);
            }

            if (this.block != null)
            {
                if (prettyPrint)
                {
                    writer.WriteLine();
                }
                this.block.Write(writer, options);
            }
            else
            {
                writer.Write(';');
            }

            if (prettyPrint)
            {
                writer.WriteLine();
            }
        }
Esempio n. 13
0
        public override void Write(TextWriter writer, CssCompactor.Options options)
        {
            bool prettyPrint = IsPrettyPrint(options);

            foreach (CssStatement statement in this.statements)
            {
                statement.Write(writer, options);
                if (prettyPrint)
                {
                    writer.WriteLine();
                }
            }
        }
Esempio n. 14
0
 public void Write(TextWriter writer, CssCompactor.Options options)
 {
     this.StyleSheet.Write(writer, options);
 }