Svg.SvgPaintServerFactory.Create C# (CSharp) Method

Create() public static method

public static Create ( string value, SvgDocument document ) : SvgPaintServer
value string
document SvgDocument
return SvgPaintServer
        public static SvgPaintServer Create(string value, SvgDocument document)
        {
            // If it's pointing to a paint server
            if (string.IsNullOrEmpty(value))
            {
                return SvgColourServer.NotSet;
            }
            else if (value.IndexOf("url(#") > -1)
            {
                Match match = _urlRefPattern.Match(value);
                Uri id = new Uri(match.Groups[1].Value, UriKind.Relative);
                return (SvgPaintServer)document.IdManager.GetElementById(id);
            }
            // If referenced to to a different (linear or radial) gradient
            else if (document.IdManager.GetElementById(value) != null && document.IdManager.GetElementById(value).GetType().BaseType == typeof(SvgGradientServer))
            {
                return (SvgPaintServer)document.IdManager.GetElementById(value);
            }
            else // Otherwise try and parse as colour
            {
                return new SvgColourServer((Color)_colourConverter.ConvertFrom(value.Trim()));
            }
        }

Usage Example

        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            if (value is string)
            {
                return(SvgPaintServerFactory.Create((string)value, (SvgDocument)context));
            }

            return(base.ConvertFrom(context, culture, value));
        }
All Usage Examples Of Svg.SvgPaintServerFactory::Create