BililiveRecorder/BililiveRecorder.Core/Settings.cs

49 lines
1.4 KiB
C#
Raw Normal View History

2018-03-21 20:56:56 +08:00
using NLog;
2018-03-20 00:12:32 +08:00
using System.Collections.Generic;
using System.ComponentModel;
namespace BililiveRecorder.Core
{
public class Settings : INotifyPropertyChanged
{
2018-03-21 20:56:56 +08:00
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
2018-03-20 00:12:32 +08:00
2018-03-21 20:56:56 +08:00
private int _clip_past = 90;
public int Clip_Past
{
get => _clip_past;
set => SetField(ref _clip_past, value, nameof(Clip_Past));
}
2018-03-20 00:12:32 +08:00
2018-03-21 20:56:56 +08:00
private int _clip_future = 30;
public int Clip_Future
{
get => _clip_future;
set => SetField(ref _clip_future, value, nameof(Clip_Future));
}
private string _savepath = string.Empty;
public string SavePath
{
get => _savepath;
set => SetField(ref _savepath, value, nameof(SavePath));
}
2018-03-20 00:12:32 +08:00
public Settings()
{
}
public event PropertyChangedEventHandler PropertyChanged;
2018-03-21 20:56:56 +08:00
protected bool SetField<T>(ref T field, T value, string propertyName)
{
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
logger.Debug("设置 [{0}] 的值已从 [{1}] 修改到 [{2}]", propertyName, field, value);
field = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
return true;
}
2018-03-20 00:12:32 +08:00
}
}