public static void ConvertPwgImageToPwgImageWPF(PwgImage aPwgImage, ref PwgImageWPF aPwgImageWPF) { if (aPwgImage != null) { if (aPwgImageWPF == null) { aPwgImageWPF = new PwgImageWPF(); } aPwgImageWPF.Id = aPwgImage.Id; aPwgImageWPF.Counter = aPwgImage.Counter; aPwgImageWPF.File = aPwgImage.File; aPwgImageWPF.Height = aPwgImage.Height; aPwgImageWPF.UrlElement = aPwgImage.UrlElement; aPwgImageWPF.UrlHighDef = aPwgImage.UrlHighDef; aPwgImageWPF.UrlThunb = aPwgImage.UrlThunb; aPwgImageWPF.Width = aPwgImage.Width; if (aPwgImageWPF.Albums == null) { aPwgImageWPF.Albums = new System.Collections.ObjectModel.ObservableCollection<PwgAlbumWPF>(); } else { aPwgImageWPF.Albums.Clear(); } foreach (PwgAlbumWPF c in aPwgImageWPF.Albums) { aPwgImageWPF.Albums.Add(c); } //if (aPwgImageWPF.Tags == null) //{ // aPwgImageWPF.Tags = new System.Collections.ObjectModel.ObservableCollection<PwgTag>(); //} //else //{ // aPwgImageWPF.Tags.Clear(); //} //foreach (PwgTag t in aPwgImageWPF.Tags) //{ // aPwgImageWPF.Tags.Add(t); //} } }
public static void AddPwgImageToList(PwgImage aPwgImage, ref PwgImageListWPF aPwgImageListWPF) { if (aPwgImage != null) { if (aPwgImageListWPF == null) { aPwgImageListWPF = new PwgImageListWPF(); } PwgImageWPF pwgImg = new PwgImageWPF(); PwgImageWPFHelper.ConvertPwgImageToPwgImageWPF(aPwgImage, ref pwgImg); aPwgImageListWPF.Add(pwgImg); } }
/// <summary> /// private: convert response to dto object /// </summary> /// <param name="response"></param> /// <param name="session"></param> internal static PwgImage ConvertProxyResponseToDTO(PwgImageProxyResponse response) { PwgImage returnValue = new PwgImage(); try { returnValue.Counter = response.Counter; returnValue.Id = response.Id; returnValue.File = response.File; returnValue.Height = response.Height; returnValue.Width = response.Width; if (response.AvailableDate != null) { DateTime tryDate; if (DateTime.TryParse(response.AvailableDate, out tryDate)) { returnValue.AvailableDate = tryDate; } } if (response.CreatingDate != null) { DateTime tryDate; if (DateTime.TryParse(response.CreatingDate, out tryDate)) { returnValue.CreatingDate = tryDate; } } if (String.IsNullOrEmpty(response.UrlElement)) { returnValue.UrlElement = null; } else { returnValue.UrlElement = (new UriBuilder(response.UrlElement)).Uri; } if (String.IsNullOrEmpty(response.UrlThunb)) { returnValue.UrlThunb = null; } else { returnValue.UrlThunb = (new UriBuilder(response.UrlThunb)).Uri; } if (String.IsNullOrEmpty(response.UrlHighDef)) { returnValue.UrlHighDef = null; } else { returnValue.UrlHighDef = (new UriBuilder(response.UrlHighDef)).Uri; } returnValue.Tags = new List<PwgTag>(); if (response.Tags != null) { foreach (PwgTagProxyResponse tagResp in response.Tags) { PwgTag aTag = PwgTagsService.ConvertProxyResponseToDTO(tagResp); returnValue.Tags.Add(aTag); } } returnValue.Albums = new List<PwgAlbum>(); if (response.Albums != null) { foreach (PwgAlbumProxyResponse catResp in response.Albums) { PwgAlbum aCat = PwgAlbumsService.ConvertProxyResponseToDTO(catResp); returnValue.Albums.Add(aCat); } } } catch (Exception ex) { throw new PwgServiceException("ConvertProxyResponseToDTO : a error is raised when converting PwgTagProxyResponse.", ex); } return returnValue; }