private void Invalidate() { Version++; Reset(); var sheet = CssParser.Parse(content ?? "", null, GetCombinedVariables()); foreach (var error in sheet.Errors) { this.LocalErrors.Add(error); } foreach (var warning in sheet.Warnings) { this.LocalWarnings.Add(warning); } this.localNamespaces = sheet.LocalNamespaces; this.localRules = sheet.LocalRules; this.variables = sheet.Variables; EagerLoading(); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Content")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LocalRules")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Errors")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Warnings")); }
private void Invalidate() { Version++; Reset(); var sheet = CssParser.Parse(content ?? "", BaseStyleSheets.LastOrDefault()?.Namespaces.FirstOrDefault(x => x.Alias == "")?.Namespace ?? CssParser.defaultCssNamespace, GetCombinedVariables()); foreach (var error in sheet.Errors) { this.LocalErrors.Add(error); } foreach (var warning in sheet.Warnings) { this.LocalWarnings.Add(warning); } this.localNamespaces = sheet.LocalNamespaces; this.localRules = sheet.LocalRules; this.variables = sheet.Variables; EagerLoading(); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Content")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LocalRules")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LocalNamespaces")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Errors")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Warnings")); }
private static CreateStyleDictionaryFromDeclarationBlockResult <TDependencyProperty> CreateStyleDictionaryFromDeclarationBlock( CssNamespaceCollection namespaces, StyleDeclarationBlock declarationBlock, Type matchedType, TDependencyObject dependencyObject, CssTypeHelper <TDependencyObject, TDependencyProperty, TStyle> cssTypeHelper) { var result = new CreateStyleDictionaryFromDeclarationBlockResult <TDependencyProperty>(); foreach (var styleDeclaration in declarationBlock) { var propertyInfo = cssTypeHelper.GetDependencyPropertyInfo(namespaces, matchedType, styleDeclaration.Property); if (propertyInfo == null) { continue; } try { var propertyValue = cssTypeHelper.GetPropertyValue(propertyInfo.DeclaringType, dependencyObject, propertyInfo.Name, styleDeclaration.Value, propertyInfo.Property, namespaces); result.PropertyStyleValues[propertyInfo.Property] = propertyValue; } catch { result.Errors.Add($"Cannot get property-value for '{styleDeclaration.Property}' with value '{styleDeclaration.Value}'!"); } } return(result); }
protected void Reset() { combinedRules = null; combinedNamespaces = null; variables = null; this.Errors.Clear(); this.Warnings.Clear(); }
protected void Reset() { combinedRules = null; combinedNamespaces = null; namespaceUri2Alias.Clear(); prefix2NamespaceUri.Clear(); variables = null; this.localErrors.Clear(); this.localWarnings.Clear(); this.errors = null; this.warnings = null; }
protected CssNamespaceCollection GetCombinedNamespaces() { if (BaseStyleSheets.Count == 0 && InheritedStyleSheets.Count == 0) { return(LocalNamespaces); } var result = new CssNamespaceCollection( InheritedStyleSheets .Select(x => x.Namespaces) .Concat(BaseStyleSheets.Select(x => x.Namespaces)) .Aggregate((a, b) => new CssNamespaceCollection(a.Concat(b))) .Concat(LocalNamespaces) .GroupBy(x => x.Alias) .Select(x => x.Last())); return(result); }