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);
        }
        public void DeleteLabels(Topic topic, ImageLabel image)
        {
            #region validation

            if (topic == null)
            {
                throw new ArgumentNullException(nameof(topic));
            }

            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            #endregion

            FileContainer.DeleteFile(image.GetLabelFileName(), GetLabelsPath(topic));
        }
        public IEnumerable <Label> AddLabels(Topic topic, ImageLabel image, IEnumerable <Label> labels)
        {
            #region validation

            if (topic == null)
            {
                throw new ArgumentNullException(nameof(topic));
            }

            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }

            if (labels == null)
            {
                throw new ArgumentNullException(nameof(labels));
            }

            #endregion

            // set id for labels
            foreach (Label label in labels)
            {
                label.Id = labels.GetNext(o => o.Id) + 1;
            }

            FileSession.Execute((fileName, filePath) =>
            {
                image.Labels            = labels.ToList();
                byte[] labelFileContent = image.GetLabelsAsByte();
                FileContainer.CreateFile(fileName, labelFileContent, filePath);

                return(true);
            }, image.GetLabelFileName(), GetLabelsPath(topic));

            return(labels);
        }