public IEnumerable <Label> GetLabels(Topic topic, ImageLabel imageLabel) { #region validation if (topic == null) { throw new ArgumentNullException(nameof(topic)); } if (imageLabel == null) { throw new ArgumentNullException(nameof(imageLabel)); } #endregion IEnumerable <Label> labels = FileSession.Execute((fileName, filePath) => { if (!FileContainer.ExistsFile(fileName, filePath)) { return(new List <Label>()); } using (StreamReader streamReader = EncodingUtil.GetStreamReader(FileContainer.GetFileStream(fileName, filePath), Encoding.UTF8)) { string labelContentJson = streamReader.ReadToEnd(); return(JsonConvert.DeserializeObject <IEnumerable <Label> >(labelContentJson)); } }, GetLabelFileName(imageLabel.Url), GetLabelsPath(topic)); imageLabel.SetLabels(labels); return(labels); }
public IEnumerable <Label> GetLabels(Topic topic, ImageLabel image) { #region validation if (topic == null) { throw new ArgumentNullException(nameof(topic)); } if (image == null) { throw new ArgumentNullException(nameof(image)); } #endregion IEnumerable <Label> labels = FileSession.Execute((fileName, filePath) => { if (!FileContainer.ExistsFile(fileName, filePath)) { return(new List <Label>()); } using (Stream labelFileStream = FileContainer.GetFileStream(fileName, filePath)) { return(LabelStoreUtil.GetLabelsFromStream(labelFileStream)); } }, image.GetLabelFileName(), GetLabelsPath(topic)); image.SetLabels(labels); return(labels); }