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); }
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); }
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); }
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); }