<commit_before>using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive;
using System.Reactive.Subjects;
using System.Windows.Input;
using Addle.Core.Linq;
using JetBrains.Annotations;

namespace Addle.Wpf.ViewModel
{
	public class AutoCommand<TOwner, TParam> : IAutoCommandInternal, ICommand
	{
		readonly Action<TOwner, TParam> _executeCallback;
		readonly BehaviorSubject<bool> _canExecute = new BehaviorSubject<bool>(true);
		event EventHandler _canExecuteChanged;
		object _owner;

		public AutoCommand(Action<TOwner, TParam> executeCallback)
		{
			_executeCallback = executeCallback;
			_canExecute.Subscribe(OnCanExecuteChanged);
		}

		public AutoCommand(Action<TOwner> executeCallback)
			: this((owner, _) => executeCallback(owner))
		{
		}

		public BehaviorSubject<bool> CanExecute { get { return _canExecute; } }

		void IAutoCommandInternal.Setup(object owner, string propertyName)
		{
			_owner = owner;
		}

		void IAutoCommandInternal.Initialized()
		{
		}

		bool ICommand.CanExecute(object parameter)
		{
			return _canExecute == null || _canExecute.Value;
		}

		void ICommand.Execute(object parameter)
		{
			_executeCallback((TOwner)_owner, (TParam)parameter);
		}

		void OnCanExecuteChanged(bool value)
		{
			var handler = _canExecuteChanged;
			if (handler != null) _canExecuteChanged(this, new EventArgs());
		}

		event EventHandler ICommand.CanExecuteChanged { add { _canExecuteChanged += value; } remove { _canExecuteChanged -= value; } }
	}

	public class AutoCommand<TOwner> : AutoCommand<TOwner, Unit>
	{
		public AutoCommand(Action<TOwner> executeCallback)
			: base((owner, param) => executeCallback(owner))
		{
		}
	}
}
<commit_msg>fix bug in autocommand's event handler<commit_after>using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive;
using System.Reactive.Subjects;
using System.Windows.Input;
using Addle.Core.Linq;
using JetBrains.Annotations;

namespace Addle.Wpf.ViewModel
{
	public class AutoCommand<TOwner, TParam> : IAutoCommandInternal, ICommand
	{
		readonly Action<TOwner, TParam> _executeCallback;
		readonly BehaviorSubject<bool> _canExecute = new BehaviorSubject<bool>(true);
		event EventHandler _canExecuteChanged;
		object _owner;

		public AutoCommand(Action<TOwner, TParam> executeCallback)
		{
			_executeCallback = executeCallback;
			_canExecute.Subscribe(OnCanExecuteChanged);
		}

		public AutoCommand(Action<TOwner> executeCallback)
			: this((owner, _) => executeCallback(owner))
		{
		}

		public BehaviorSubject<bool> CanExecute { get { return _canExecute; } }

		void IAutoCommandInternal.Setup(object owner, string propertyName)
		{
			_owner = owner;
		}

		void IAutoCommandInternal.Initialized()
		{
		}

		bool ICommand.CanExecute(object parameter)
		{
			return _canExecute == null || _canExecute.Value;
		}

		void ICommand.Execute(object parameter)
		{
			_executeCallback((TOwner)_owner, (TParam)parameter);
		}

		void OnCanExecuteChanged(bool value)
		{
			var handler = _canExecuteChanged;
			if (handler != null) handler(this, new EventArgs());
		}

		event EventHandler ICommand.CanExecuteChanged { add { _canExecuteChanged += value; } remove { _canExecuteChanged -= value; } }
	}

	public class AutoCommand<TOwner> : AutoCommand<TOwner, Unit>
	{
		public AutoCommand(Action<TOwner> executeCallback)
			: base((owner, param) => executeCallback(owner))
		{
		}
	}
}

{'fraction_non_alphanumeric': 0.1015807962529274, 'fraction_numerical': 0.0, 'mean_word_length': 4.994736842105263, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 27, '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': '7121569', 'n_tokens_mistral': 1179, 'n_tokens_neox': 1053, 'n_words': 223}