<commit_before>﻿using CodeShield;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BGC.Core
{
    public class ComposerProfile : BgcEntity<Guid>
    {
        private static bool IsImage(MediaTypeInfo media) => media?.MimeType.MediaType.StartsWith("image/") ?? false;

        private MediaTypeInfo _profilePicture;
        [NotMapped]
        public virtual MediaTypeInfo ProfilePicture
        {
            get
            {
                return _profilePicture;
            }

            set
            {
                Shield.Assert(value, IsImage(value), (x) => new InvalidOperationException($"The new value for {nameof(ProfilePicture)} doesn't refer to a valid image.")).ThrowOnError();

                _profilePicture = value;
            }
        }

        public IEnumerable<MediaTypeInfo> Images() => Media.Where(m => IsImage(m));

        private ICollection<MediaTypeInfo> _media;
        [NotMapped]
        public virtual ICollection<MediaTypeInfo> Media
        {
            get
            {
                return _media ?? (_media = new HashSet<MediaTypeInfo>());
            }

            set
            {
                _media = value;
            }
        }

        /// <summary>
        /// Adds images from the <paramref name="media"/> collection or updates existing ones.
        /// </summary>
        /// <param name="media"></param>
        public void UpdateMedia(IEnumerable<MediaTypeInfo> media)
        {
            List<MediaTypeInfo> mediaToUpdate = new List<MediaTypeInfo>();

            foreach (MediaTypeInfo m in media)
            {<commit_msg>Minor revision in ComposerProfile's XML documentation.<commit_after>﻿using CodeShield;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BGC.Core
{
    public class ComposerProfile : BgcEntity<Guid>
    {
        private static bool IsImage(MediaTypeInfo media) => media?.MimeType.MediaType.StartsWith("image/") ?? false;

        private MediaTypeInfo _profilePicture;
        [NotMapped]
        public virtual MediaTypeInfo ProfilePicture
        {
            get
            {
                return _profilePicture;
            }

            set
            {
                Shield.Assert(value, IsImage(value), (x) => new InvalidOperationException($"The new value for {nameof(ProfilePicture)} doesn't refer to a valid image.")).ThrowOnError();

                _profilePicture = value;
            }
        }

        public IEnumerable<MediaTypeInfo> Images() => Media.Where(m => IsImage(m));

        private ICollection<MediaTypeInfo> _media;
        [NotMapped]
        public virtual ICollection<MediaTypeInfo> Media
        {
            get
            {
                return _media ?? (_media = new HashSet<MediaTypeInfo>());
            }

            set
            {
                _media = value;
            }
        }

        /// <summary>
        /// Adds images from the <paramref name="media"/> collection or replaces existing ones with the newer versions.
        /// </summary>
        /// <param name="media"></param>
        public void UpdateMedia(IEnumerable<MediaTypeInfo> media)
        {
            List<MediaTypeInfo> mediaToUpdate = new List<MediaTypeInfo>();

            foreach (MediaTypeInfo m in media)
            {
{'fraction_non_alphanumeric': 0.09534619750283768, 'fraction_numerical': 0.0, 'mean_word_length': 1.9547359597652976, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '908924', 'n_tokens_mistral': 892, 'n_tokens_neox': 879, 'n_words': 221}