예제 #1
0
        public static ImageReference?GetImageReference(object item, string iconName)
        {
            if (string.IsNullOrEmpty(iconName))
            {
                return(null);
            }
            int colonIndex = iconName.IndexOf(':');

            if (colonIndex >= 0)
            {
                var type = iconName.Substring(0, colonIndex).Trim();
                iconName = iconName.Substring(colonIndex + 1).Trim();
                if (type.Equals("img", StringComparison.OrdinalIgnoreCase))
                {
                    ImageReference imageReference;
                    if (ImageReference.TryParse(iconName, out imageReference))
                    {
                        return(imageReference);
                    }
                    return(null);
                }
                return(null);
            }
            return(new ImageReference(item.GetType().Assembly, iconName));
        }