<commit_before>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ExifLibrary
{
    /// <summary>
    /// Represents a collection of <see cref="ExifLibrary.ExifProperty"/> objects.
    /// </summary>
    public class ExifPropertyCollection : IDictionary<ExifTag, ExifProperty>
    {
        #region Member Variables
        private Dictionary<ExifTag, ExifProperty> items;
        #endregion

        #region Constructor
        public ExifPropertyCollection()
        {
            items = new Dictionary<ExifTag, ExifProperty>();
        }
        #endregion

        #region Properties
        /// <summary>
        /// Gets the number of elements contained in the collection.
        /// </summary>
        public int Count { get { return items.Count; } }
        /// <summary>
        /// Gets a collection containing the keys in this collection.
        /// </summary>
        public ICollection<ExifTag> Keys { get { return items.Keys; } }
        /// <summary>
        /// Gets a collection containing the values in this collection.
        /// </summary>
        public ICollection<ExifProperty> Values { get { return items.Values; } }
        /// <summary>
        /// Gets or sets the <see cref="ExifLibrary.ExifProperty"/> with the specified key.
        /// </summary>
        public ExifProperty this[ExifTag key]
        {
            get { return items[key]; }
            set
            {
                if (items.ContainsKey(key))
                    items.Remove(key);
                items.Add(key, value);
            }
        }
        #endregion

        #region Instance Methods
        /// <summary>
        /// Adds the specified item to the collection.
        /// </summary>
        /// <param name="item">The <see cref="ExifLibrary.ExifProperty"/> to add to the collection.</param>
        public void Add(ExifProperty item)
        {<commit_msg>Added setter methods to metadata collection.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ExifLibrary
{
    /// <summary>
    /// Represents a collection of <see cref="ExifLibrary.ExifProperty"/> objects.
    /// </summary>
    public class ExifPropertyCollection : IDictionary<ExifTag, ExifProperty>
    {
        #region Member Variables
        private Dictionary<ExifTag, ExifProperty> items;
        #endregion

        #region Constructor
        public ExifPropertyCollection()
        {
            items = new Dictionary<ExifTag, ExifProperty>();
        }
        #endregion

        #region Properties
        /// <summary>
        /// Gets the number of elements contained in the collection.
        /// </summary>
        public int Count { get { return items.Count; } }
        /// <summary>
        /// Gets a collection containing the keys in this collection.
        /// </summary>
        public ICollection<ExifTag> Keys { get { return items.Keys; } }
        /// <summary>
        /// Gets a collection containing the values in this collection.
        /// </summary>
        public ICollection<ExifProperty> Values { get { return items.Values; } }
        /// <summary>
        /// Gets or sets the <see cref="ExifLibrary.ExifProperty"/> with the specified key.
        /// </summary>
        public ExifProperty this[ExifTag key]
        {
            get { return items[key]; }
            set
            {
                if (items.ContainsKey(key))
                    items.Remove(key);
                items.Add(key, value);
            }
        }
        #endregion

        #region ExifProperty Collection Setters
        /// <summary>
        /// Sets the <see cref="ExifLibrary.ExifProperty"/> with the specified key.
        /// </summary>
        /// <param name="key">The tag to set.</param>
        /// <param name="value">The value of tag.</param>
        public void Set(ExifTag key, byte value)
        {
            if (items.ContainsKey(key))
                items.Remove(key);
            items.Add(key, new ExifByte(key, value));
        }
        /// <summary>
        /// Sets the <see cref="ExifLibrary.ExifProperty"/> with the specified key.
        /// </summary>
        /// <param name="key">The tag to set.</param>
        /// <param name="value">The value of tag.</param>
        public void Set(ExifTag key, string value)
        {
            if (items.ContainsKey(key))
                items.Remove(key);
            items.Add(key, new ExifAscii(key, value));
        }
        /// <summary>
        /// Sets the <see cref="ExifLibrary.ExifProperty"/> with the specified key.
        /// </summary>
        /// <param name="key">The tag to set.</param>
        /// <param name="value">The value of tag.</param>
        public void Set(ExifTag key, ushort value)
        {
            if (items.ContainsKey(key))
                items.Remove(key);
            items.Add(key, new ExifUShort(key, value));
        }
        /// <summary>
        /// Sets the <see cref="ExifLibrary.ExifProperty"/> with the specified key.
        /// </summary>
        /// <param name="key">The tag to set.</param>
        /// <param name="value">The value of tag.</param>
        public void Set(ExifTag key, int value)
        {
            if (items.ContainsKey(key))
                items.Remove(key);
            items.Add(key, new ExifSInt(key, value));
        }
        /// <summary>
        /// Sets the <see cref="ExifLibrary.ExifProperty"/> with the specified key.
        /// </summary>
        /// <param name="key">The tag to set.</param>
        /// <param name="value">The value of tag.</param>
        public void Set(ExifTag key, uint value)
        {
            if (items.ContainsKey(key))
                items.Remove(key);
            items.Add(key, new ExifUInt(key, value));
        }
        /// <summary>
        /// Sets the <see cref="ExifLibrary.ExifProperty"/> with the specified key.
        /// </summary>
        /// <param name="key">The tag to set.</param>
        /// <param name="value">The value of tag.</param>
        public void Set(ExifTag key, float value)
        {
            if (items.ContainsKey(key))
                items.Remove(key);
            items.Add(key, new ExifURational(key, new MathEx.UFraction32(value)));
        }
        /// <summary>
        /// Sets the <see cref="ExifLibrary.ExifProperty"/> with the specified key.
        /// </summary>
        /// <param name="key">The tag to set.</param>
        /// <param name="value">The value of tag.</param>
        public void Set(ExifTag key, double value)
        {
            if (items.ContainsKey(key))
                items.Remove(key);
            items.Add(key, new ExifURational(key, new MathEx.UFraction32(value)));
        }
        /// <summary>
        /// Sets the <see cref="ExifLibrary.ExifProperty"/> with the specified key.
        /// </summary>
        /// <param name="key">The tag to set.</param>
        /// <param name="value">The value of tag.</param>
        public void Set(ExifTag key, object value)
        {
            Type type = value.GetType();
            if (type.IsEnum)
            {
                Type etype = typeof(ExifEnumProperty<>).MakeGenericType(new Type[] { type });
                object prop = Activator.CreateInstance(etype, new object[] { key, value });
                if (items.ContainsKey(key))
                    items.Remove(key);
                items.Add(key, (ExifProperty)prop);
            }
            else
                throw new ArgumentException("No exif property exists for this tag.", "value");
        }
        /// <summary>
        /// Sets the <see cref="ExifLibrary.ExifProperty"/> with the specified key.
        /// </summary>
        /// <param name="key">The tag to set.</param>
        /// <param name="value">The value of tag.</param>
        /// <param name="encoding">String encoding.</param>
        public void Set(ExifTag key, string value, Encoding encoding)
        {
            if (items.ContainsKey(key))
                items.Remove(key);
            items.Add(key, new ExifEncodedString(key, value, encoding));
        }
        /// <summary>
        /// Sets the <see cref="ExifLibrary.ExifProperty"/> with the specified key.
        /// </summary>
        /// <param name="key">The tag to set.</param>
        /// <param name="value">The value of tag.</param>
        public void Set(ExifTag key, DateTime value)
        {
            if (items.ContainsKey(key))
                items.Remove(key);
            items.Add(key, new ExifDateTime(key, value));
        }
        /// <summary>
        /// Sets the <see cref="ExifLibrary.ExifProperty"/> with the specified key.
        /// </summary>
        /// <param name="key">The tag to set.</param>
        /// <param name="d">Angular degrees (or clock hours for a timestamp).</param>
        /// <param name="m">Angular minutes (or clock minutes for a timestamp).</param>
        /// <param name="s">Angular seconds (or clock seconds for a timestamp).</param>
        public void Set(ExifTag key, float d, float m, float s)
        {
            if (items.ContainsKey(key))
                items.Remove(key);
            items.Add(key, new ExifURationalArray(key, new MathEx.UFraction32[] { new MathEx.UFraction32(d), new MathEx.UFraction32(m), new MathEx.UFraction32(s) }));
        }
        #endregion

        #region Instance Methods
        /// <summary>
        /// Adds the specified item to the collection.
        /// </summary>
        /// <param name="item">The <see cref="ExifLibrary.ExifProperty"/> to add to the collection.</param>
        public void Add(ExifProperty item)
        {
{'fraction_non_alphanumeric': 0.13293959175215003, 'fraction_numerical': 0.0012433944668946222, 'mean_word_length': 1.737379466817924, 'pattern_counts': {'":': 0, '<': 131, '<?xml version=': 0, '>': 131, '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': '2067094', 'n_tokens_mistral': 2594, 'n_tokens_neox': 2558, 'n_words': 726}