public bool DoesThisRuleApplyTo(StyleSheetTypeOptions styleSheetType) { if (!Enum.IsDefined(typeof(StyleSheetTypeOptions), styleSheetType)) { throw new ArgumentOutOfRangeException("styleSheetType"); } // This can't be applied to compiled stylesheets as the ConformityOptions.AllowPercentageWidthsOnSpecifiedElementTypesntageWidthDivs option specifies that img elements // are allowed width:100% if the style is nested within a div that has percentage width (when the rules are compiled or combined this nesting will no longer be possible) if (styleSheetType == StyleSheetTypeOptions.Compiled) { return(false); } // Can't apply to combined sheets for the same reason as above if (styleSheetType == StyleSheetTypeOptions.Combined) { return(false); } // There may be some dodgy hacks required in the Reset sheet that uses widths that wouldn't be allowed in other places, so skip processing on thoses if (styleSheetType == StyleSheetTypeOptions.Reset) { return(false); } // For the other types (ie. Themes and Other), we DO want this rule to run return(true); }
/// <summary> /// Try to get a message value for the base Exception constructor. If any of the arguments are invalid then return null and allow the constructor /// above to throw an ArgumentException when it identifies them. This should combine the brokenRuleException's message with the filename of the /// source file (if the content is Combined or Compiled then indicate this, likewise if it's identified as a Resets or Theme sheet). If the /// file is not the result of Combined or Compiled content then also include the line number which was identified as invalid (it won't /// mean anything for Combined or Compiled content, so don't bother for those). /// </summary> private static string TryToGetMessage( BrokenRuleEncounteredException brokenRuleException, StyleSheetTypeOptions styleSheetType, string relativePath) { if ((brokenRuleException == null) || !Enum.IsDefined(typeof(StyleSheetTypeOptions), styleSheetType) || string.IsNullOrWhiteSpace(relativePath)) { return(null); } var filename = relativePath; if (styleSheetType != StyleSheetTypeOptions.Other) { filename += "[" + styleSheetType + "]"; } var message = brokenRuleException.Message + " in " + filename; if ((styleSheetType != StyleSheetTypeOptions.Combined) && (styleSheetType != StyleSheetTypeOptions.Compiled)) { // SourceLineIndex is zero-based so add one to show line number message += " (line " + (brokenRuleException.Fragment.SourceLineIndex + 1) + ")"; } return(message); }
public bool DoesThisRuleApplyTo(StyleSheetTypeOptions styleSheetType) { if (!Enum.IsDefined(typeof(StyleSheetTypeOptions), styleSheetType)) { throw new ArgumentOutOfRangeException("styleSheetType"); } // Applying this to individual stylesheets would not give adequate cover (since selectors shouldn't be repeated anywhere throughout the styles, not // just within a given sheet). It can't be applied to compiled content since it would prevent valid DRY through using of LESS mixins - eg. // // .ListWithBlueItems // { // > li { color: blue; } // } // ul.List1 // { // .ListWithBlueItems; // > li { padding: 4px; } // } // // will be compiled into // // ul.List1 > li { color: blue; } // ul.List1 > li { padding: 4px; } // // resulting in repeated selectors even though effort has been made to avoid duplication in the source. // So this rule can only be applied Combined stylesheet content. return(styleSheetType == StyleSheetTypeOptions.Combined); }
public bool DoesThisRuleApplyTo(StyleSheetTypeOptions styleSheetType) { if (!Enum.IsDefined(typeof(StyleSheetTypeOptions), styleSheetType)) { throw new ArgumentOutOfRangeException("styleSheetType"); } return(styleSheetType != StyleSheetTypeOptions.Compiled && styleSheetType != StyleSheetTypeOptions.Combined); }
public bool DoesThisRuleApplyTo(StyleSheetTypeOptions styleSheetType) { if (!Enum.IsDefined(typeof(StyleSheetTypeOptions), styleSheetType)) { throw new ArgumentOutOfRangeException("styleSheetType"); } return((styleSheetType == StyleSheetTypeOptions.Reset) || (styleSheetType == StyleSheetTypeOptions.Themes)); }
public bool DoesThisRuleApplyTo(StyleSheetTypeOptions styleSheetType) { if (!Enum.IsDefined(typeof(StyleSheetTypeOptions), styleSheetType)) { throw new ArgumentOutOfRangeException("styleSheetType"); } // This can only apply to "Other" stylesheets since anything else may be Resets or Themes or contain Resets or Themes content (ie. Combined stylesheet content) return(styleSheetType == StyleSheetTypeOptions.Other); }
public bool DoesThisRuleApplyTo(StyleSheetTypeOptions styleSheetType) { if (!Enum.IsDefined(typeof(StyleSheetTypeOptions), styleSheetType)) { throw new ArgumentOutOfRangeException("styleSheetType"); } // This doesn't apply to Resets or Themes since they don't need html scoping and can't apply to Compiled sheets since the html-scoping tags may have been removed // and can't apply to Combined content since thes may include content from Resets of Themes return(styleSheetType == StyleSheetTypeOptions.Other); }
public BrokenRuleEncounteredInFileException( BrokenRuleEncounteredException brokenRuleException, StyleSheetTypeOptions styleSheetType, string relativePath) : base(TryToGetMessage(brokenRuleException, styleSheetType, relativePath) ?? "") { if (brokenRuleException == null) { throw new ArgumentNullException("brokenRuleException"); } if (!Enum.IsDefined(typeof(StyleSheetTypeOptions), styleSheetType)) { throw new ArgumentOutOfRangeException("styleSheetType"); } if (string.IsNullOrWhiteSpace(relativePath)) { throw new ArgumentException("Null/blank relativePath specified"); } BrokenRuleException = brokenRuleException; StyleSheetType = styleSheetType; RelativePath = relativePath; }