style: add .editorconfig for code formatting. see issu #25

This commit is contained in:
leo 2024-03-18 09:37:06 +08:00
parent a8eeea4f78
commit 18aaa0a143
225 changed files with 7781 additions and 3911 deletions

View file

@ -3,31 +3,38 @@ using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Threading.Tasks;
namespace SourceGit.ViewModels {
public class Apply : Popup {
namespace SourceGit.ViewModels
{
public class Apply : Popup
{
[Required(ErrorMessage = "Patch file is required!!!")]
[CustomValidation(typeof(Apply), nameof(ValidatePatchFile))]
public string PatchFile {
public string PatchFile
{
get => _patchFile;
set => SetProperty(ref _patchFile, value, true);
}
public bool IgnoreWhiteSpace {
public bool IgnoreWhiteSpace
{
get => _ignoreWhiteSpace;
set => SetProperty(ref _ignoreWhiteSpace, value);
}
public List<Models.ApplyWhiteSpaceMode> WhiteSpaceModes {
public List<Models.ApplyWhiteSpaceMode> WhiteSpaceModes
{
get;
private set;
}
public Models.ApplyWhiteSpaceMode SelectedWhiteSpaceMode {
public Models.ApplyWhiteSpaceMode SelectedWhiteSpaceMode
{
get;
set;
}
public Apply(Repository repo) {
public Apply(Repository repo)
{
_repo = repo;
WhiteSpaceModes = new List<Models.ApplyWhiteSpaceMode> {
@ -41,27 +48,31 @@ namespace SourceGit.ViewModels {
View = new Views.Apply() { DataContext = this };
}
public static ValidationResult ValidatePatchFile(string file, ValidationContext _) {
if (File.Exists(file)) {
public static ValidationResult ValidatePatchFile(string file, ValidationContext _)
{
if (File.Exists(file))
{
return ValidationResult.Success;
}
return new ValidationResult($"File '{file}' can NOT be found!!!");
}
public override Task<bool> Sure() {
public override Task<bool> Sure()
{
_repo.SetWatcherEnabled(false);
ProgressDescription = "Apply patch...";
return Task.Run(() => {
return Task.Run(() =>
{
var succ = new Commands.Apply(_repo.FullPath, _patchFile, _ignoreWhiteSpace, SelectedWhiteSpaceMode.Arg, null).Exec();
CallUIThread(() => _repo.SetWatcherEnabled(true));
return succ;
});
}
private Repository _repo = null;
private readonly Repository _repo = null;
private string _patchFile = string.Empty;
private bool _ignoreWhiteSpace = true;
}
}
}