Example #1
0
        public static ImageUri CreateImageUri(dynamic imageInfo)
        {
            if (imageInfo == null)
            {
                return(null);
            }
            ImageUri retval = null;

            try
            {
                if (imageInfo?["ImageId"] != null)
                {
                    retval = CreateImageUri(Convert.ToString(imageInfo["ImageId"])); //it might be an enhanced image object
                }
                else
                {
                    retval = CreateImageUri(Convert.ToString(imageInfo)); //it might be just the image Id
                }
            }
            catch (Exception ex)
            {
                Log.Logger.ErrorFormat($"Error while trying to create ImageUri from dynamic string [{Convert.ToString(imageInfo) }].  Error: {ex}");
            }
            return(retval);
        }
Example #2
0
        public static ImageUri CreateImageUri(int imageId)
        {
            ImageUri retval = null;

            try
            {
                retval = imageId == 0 ? null : new ImageUri(imageId);
            }
            catch (Exception ex)
            {
                Log.Logger.ErrorFormat($"Error while trying to create ImageUri with id {imageId}: ", ex);
            }
            return(retval);
        }
Example #3
0
        public static ImageUri CreateImage(dynamic imageId)
        {
            ImageUri retval = null;

            try
            {
                retval = CreateImage(Convert.ToString(imageId));
            }
            catch (Exception ex)
            {
                Log.Logger.ErrorFormat("Error while trying to create ImageUri: ", ex);
            }
            return(retval);
        }
Example #4
0
        public static ImageUri CreateImageUri(string imageId)
        {
            ImageUri retval = null;
            int      imgId;

            if (int.TryParse(imageId, out imgId) && imgId > 0)
            {
                retval = CreateImageUri(imgId);
            }
            else if (!string.IsNullOrWhiteSpace(imageId))
            {
                try
                {
                    retval = new ImageUri(imageId);
                }
                catch (Exception)
                {
                    Log.Logger.ErrorFormat($"Failed to create ImageUri with parameter {imageId}");
                }
            }
            return(retval);
        }