<commit_before>﻿using System;
using System.Reactive;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Windows.Input;

using Common.Logging;

using Naru.WPF.Command;

namespace Naru.WPF.ViewModel
{
    public class ClosingStrategy : IClosingStrategy
    {
        private readonly ILog _log;
        private readonly Subject<Unit> _closing = new Subject<Unit>();
        private readonly Subject<Unit> _closed = new Subject<Unit>();

        private Func<bool> _canClose;

        public ICommand CloseCommand { get; private set; }

        public Func<bool> CanCloseSetup
        {
            set { _canClose = value; }
        }

        public ClosingStrategy(ILog log)
        {
            _log = log;

            CanCloseSetup = () => true;

            CloseCommand = new DelegateCommand(() => Close());
        }

        public bool CanClose()
        {
            return _canClose();
        }

        public void Close()
        {
            _log.Debug(string.Format("Closing ViewModel {0}", GetType().FullName));

            _closing.OnNext(Unit.Default);
            _closing.OnCompleted();

            _closed.OnNext(Unit.Default);
        }

        public IObservable<Unit> Closing { get { return _closing.AsObservable(); } }

        public IObservable<Unit> Closed { get { return _closed.AsObservable(); } }
    }
}<commit_msg>ClosingStrategy - OnCompleted _closed subject.<commit_after>﻿using System;
using System.Reactive;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Windows.Input;

using Common.Logging;

using Naru.WPF.Command;

namespace Naru.WPF.ViewModel
{
    public class ClosingStrategy : IClosingStrategy
    {
        private readonly ILog _log;
        private readonly Subject<Unit> _closing = new Subject<Unit>();
        private readonly Subject<Unit> _closed = new Subject<Unit>();

        private Func<bool> _canClose;

        public ICommand CloseCommand { get; private set; }

        public Func<bool> CanCloseSetup
        {
            set { _canClose = value; }
        }

        public ClosingStrategy(ILog log)
        {
            _log = log;

            CanCloseSetup = () => true;

            CloseCommand = new DelegateCommand(() => Close());
        }

        public bool CanClose()
        {
            return _canClose();
        }

        public void Close()
        {
            _log.Debug(string.Format("Closing ViewModel {0}", GetType().FullName));

            _closing.OnNext(Unit.Default);
            _closing.OnCompleted();

            _closed.OnNext(Unit.Default);
            _closed.OnCompleted();
        }

        public IObservable<Unit> Closing { get { return _closing.AsObservable(); } }

        public IObservable<Unit> Closed { get { return _closed.AsObservable(); } }
    }
}
{'fraction_non_alphanumeric': 0.10290986515259049, 'fraction_numerical': 0.0007097232079489, 'mean_word_length': 2.1925254813137034, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, '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': '7232521', 'n_tokens_mistral': 803, 'n_tokens_neox': 767, 'n_words': 182}