/// <summary>
 /// Constructs a instance of the output CSS formatting options
 /// </summary>
 public FormattingOptions()
 {
     BreaksInsertingOptions = new BreaksInsertingOptions();
     IndentBy               = 0;
     IndentWith             = IndentType.Space;
     SpacesInsertingOptions = new SpacesInsertingOptions();
     WrapAt = 0;
 }
Esempio n. 2
0
        /// <summary>
        /// Converts a cleaning options to JSON
        /// </summary>
        /// <param name="options">Cleaning options</param>
        /// <returns>Cleaning options in JSON format</returns>
        private static JObject ConvertCleaningOptionsToJson(CleaningOptions options)
        {
            FormattingOptions         formattingOptions         = options.FormattingOptions;
            BreaksInsertingOptions    breaksInsertingOptions    = formattingOptions.BreaksInsertingOptions;
            SpacesInsertingOptions    spacesInsertingOptions    = formattingOptions.SpacesInsertingOptions;
            Level1OptimizationOptions level1OptimizationOptions = options.Level1OptimizationOptions;
            Level2OptimizationOptions level2OptimizationOptions = options.Level2OptimizationOptions;

            var optionsJson = new JObject(
                new JProperty("compatibility", options.Compatibility),
                new JProperty("format", new JObject(
                                  new JProperty("breaks", new JObject(
                                                    new JProperty("afterAtRule", breaksInsertingOptions.AfterAtRule),
                                                    new JProperty("afterBlockBegins", breaksInsertingOptions.AfterBlockBegins),
                                                    new JProperty("afterBlockEnds", breaksInsertingOptions.AfterBlockEnds),
                                                    new JProperty("afterComment", breaksInsertingOptions.AfterComment),
                                                    new JProperty("afterProperty", breaksInsertingOptions.AfterProperty),
                                                    new JProperty("afterRuleBegins", breaksInsertingOptions.AfterRuleBegins),
                                                    new JProperty("afterRuleEnds", breaksInsertingOptions.AfterRuleEnds),
                                                    new JProperty("beforeBlockEnds", breaksInsertingOptions.BeforeBlockEnds),
                                                    new JProperty("betweenSelectors", breaksInsertingOptions.BetweenSelectors)
                                                    )),
                                  new JProperty("indentBy", formattingOptions.IndentBy),
                                  new JProperty("indentWith", ConvertIndentTypeEnumValueToCode(formattingOptions.IndentWith)),
                                  new JProperty("spaces", new JObject(
                                                    new JProperty("aroundSelectorRelation", spacesInsertingOptions.AroundSelectorRelation),
                                                    new JProperty("beforeBlockBegins", spacesInsertingOptions.BeforeBlockBegins),
                                                    new JProperty("beforeValue", spacesInsertingOptions.BeforeValue)
                                                    )),
                                  new JProperty("wrapAt", formattingOptions.WrapAt)
                                  )),
                new JProperty("level", ConvertOptimizationLevelEnumValueToJson(options.Level,
                                                                               level1OptimizationOptions, level2OptimizationOptions))
                );

            return(optionsJson);
        }