protected override object Get(object foreground = null) { if (string.IsNullOrWhiteSpace(_source)) { return(null); } object icon; if (_parsed) { icon = XamlTools.FromXamlString(_source); } else { icon = XamlTools.FromSvgString(_source); _source = XamlWriter.Save(icon); _parsed = true; } if (icon is DependencyObject o && _foreColor.HasValue && foreground is Brush brush) { XamlTools.SetForeground(o, _foreColor.ToColor(), brush); } return(icon); }
protected override object Get(object foreground = null) { if (string.IsNullOrWhiteSpace(_name)) { return(null); } object icon; if (_parsed) { icon = XamlTools.FromXamlString(_source); } else { using var xamlStream = _resourceManager.GetStream(_name); if (xamlStream == null) { return(null); } icon = XamlTools.FromXamlStream(xamlStream); _source = XamlWriter.Save(icon); _parsed = true; } if (icon is DependencyObject o && _foreColor.HasValue && foreground is Brush brush) { XamlTools.SetForeground(o, _foreColor.Value, brush); } return(icon); }
protected override object Get(object foreground = null) { if (string.IsNullOrWhiteSpace(_name)) { return(null); } object icon; if (_parsed) { icon = XamlTools.FromXamlString(_sourceXaml); } else { AppContext.SetSwitch("Switch.System.Xml.AllowDefaultResolver", true); using var svg = _resourceManager.GetStream(_name); icon = XamlTools.FromSvgStream(svg); _sourceXaml = XamlWriter.Save(icon); _parsed = true; } if (icon is DependencyObject o && _foreColor.HasValue && foreground is Brush brush) { XamlTools.SetForeground(o, _foreColor.Value, brush); } return(icon); }
protected override object Get(object foreground = null) { if (string.IsNullOrWhiteSpace(_name)) { return(null); } var icon = XamlTools.FromXamlString(_source); if (icon is DependencyObject o && _foreColor.HasValue && foreground is Brush brush) { XamlTools.SetForeground(o, _foreColor.ToColor(), brush); } return(icon); }