<commit_before>﻿namespace Silphid.Showzup
{
    public abstract class ViewModel<T> : IViewModel<T>
    {
        public T Model { get; }
        object IViewModel.Model => Model;

        protected ViewModel(T model)
        {
            Model = model;
        }
    }
}<commit_msg>ViewModel are now disposable.<commit_after>﻿using System;
using System.Collections;
using System.Collections.Generic;
using UniRx;

namespace Silphid.Showzup
{
    public abstract class ViewModel<T> : IViewModel<T>, IDisposable, ICollection<IDisposable>
    {
        public T Model { get; }
        object IViewModel.Model => Model;
        protected readonly CompositeDisposable Disposables = new CompositeDisposable();

        protected ViewModel(T model)
        {
            Model = model;
        }

        public virtual void Dispose()
        {
            Disposables.Dispose();
        }
        
        #region ICollection<IDisposable>

        IEnumerator<IDisposable> IEnumerable<IDisposable>.GetEnumerator() => Disposables.GetEnumerator();
        IEnumerator IEnumerable.GetEnumerator() => Disposables.GetEnumerator();
        void ICollection<IDisposable>.Add(IDisposable item) => Disposables.Add(item);
        void ICollection<IDisposable>.Clear() => Disposables.Clear();
        bool ICollection<IDisposable>.Contains(IDisposable item) => Disposables.Contains(item);
        void ICollection<IDisposable>.CopyTo(IDisposable[] array, int arrayIndex) => Disposables.CopyTo(array, arrayIndex);
        bool ICollection<IDisposable>.Remove(IDisposable item) => Disposables.Remove(item);
        int ICollection<IDisposable>.Count => Disposables.Count;
        bool ICollection<IDisposable>.IsReadOnly => Disposables.IsReadOnly;

        #endregion
    }
}
{'fraction_non_alphanumeric': 0.10073989755264656, 'fraction_numerical': 0.0, 'mean_word_length': 3.0506912442396312, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 29, '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': '7310425', 'n_tokens_mistral': 515, 'n_tokens_neox': 492, 'n_words': 99}