Skip to content

Commit

Permalink
Tuning Frame
Browse files Browse the repository at this point in the history
  • Loading branch information
AigioL committed Oct 15, 2021
1 parent ee225da commit 5e41320
Show file tree
Hide file tree
Showing 197 changed files with 3,900 additions and 4,197 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ assignees: ''

- 程序版本(Program Version):
- 系统版本号(OS Version): <!-- example Windows 10.19042.844(see winver) -->
- 是否为应用商店版本(Store Version): <!--是(Yes)/否(No)-->

### 🖼 截图(Screenshots)

Expand Down
6 changes: 5 additions & 1 deletion .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ assignees: ''

<!--
如截图等其他信息可以贴在这里
-->
-->

- 程序版本(Program Version):
- 系统版本号(OS Version): <!-- example Windows 10.19042.844(see winver) -->
- 是否为应用商店版本(Store Version): <!--是(Yes)/否(No)-->
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

「Steam++」是一个包含多种Steam工具功能的工具箱,此工具的大部分功能都是需要您下载安装Steam才能使用。

![Release Download](https://img.shields.io/github/downloads/rmbadmin/SteamTools/total?style=flat-square)
[![Release Version](https://img.shields.io/github/v/release/rmbadmin/SteamTools?style=flat-square)](https://github.com/rmbadmin/SteamTools/releases/latest)
[![GitHub license](https://img.shields.io/github/license/rmbadmin/SteamTools?style=flat-square)](LICENSE)
[![GitHub Star](https://img.shields.io/github/stars/rmbadmin/SteamTools?style=flat-square)](https://github.com/rmbadmin/SteamTools/stargazers)
[![GitHub Fork](https://img.shields.io/github/forks/rmbadmin/SteamTools?style=flat-square)](https://github.com/rmbadmin/SteamTools/network/members)
![GitHub Repo size](https://img.shields.io/github/repo-size/rmbadmin/SteamTools?style=flat-square&color=3cb371)
![Release Download](https://img.shields.io/github/downloads/SteamTools-Team/SteamTools/total?style=flat-square)
[![Release Version](https://img.shields.io/github/v/release/SteamTools-Team/SteamTools?style=flat-square)](https://github.com/SteamTools-Team/SteamTools/releases/latest)
[![GitHub license](https://img.shields.io/github/license/SteamTools-Team/SteamTools?style=flat-square)](LICENSE)
[![GitHub Star](https://img.shields.io/github/stars/SteamTools-Team/SteamTools?style=flat-square)](https://github.com/SteamTools-Team/SteamTools/stargazers)
[![GitHub Fork](https://img.shields.io/github/forks/SteamTools-Team/SteamTools?style=flat-square)](https://github.com/SteamTools-Team/SteamTools/network/members)
![GitHub Repo size](https://img.shields.io/github/repo-size/SteamTools-Team/SteamTools?style=flat-square&color=3cb371)
[![GitHub Repo Languages](https://img.shields.io/github/languages/top/SteamTools-Team/SteamTools?style=flat-square)](https://github.com/SteamTools-Team/SteamTools/search?l=c%23)
[![NET 6.0](https://img.shields.io/badge/dotnet-6.0-purple.svg?style=flat-square&color=512bd4)](https://devblogs.microsoft.com/dotnet/announcing-net-6-release-candidate-1)
[![C# 10.0](https://img.shields.io/badge/c%23-10.0-brightgreen.svg?style=flat-square&color=6da86a)](https://docs.microsoft.com/zh-cn/dotnet/csharp/whats-new/csharp-10)
Expand All @@ -20,7 +20,7 @@
[![BackManage WebSite](https://img.shields.io/badge/website@back_manage-Ant%20Design%20of%20Blazor-purple.svg?style=flat-square&color=512bd4)](https://github.com/ant-design-blazor/ant-design-blazor)

[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2FSteamTools-Team%2FSteamTools%2Fbadge%3Fref%3Ddevelop&style=flat-square)](https://actions-badge.atrox.dev/SteamTools-Team/SteamTools/goto?ref=develop)
[![GitHub Star](https://img.shields.io/github/stars/rmbadmin/SteamTools.svg?style=social)](https://github.com/SteamTools-Team/SteamTools)
[![GitHub Star](https://img.shields.io/github/stars/SteamTools-Team/SteamTools.svg?style=social)](https://github.com/SteamTools-Team/SteamTools)
[![Gitee Star](https://gitee.com/rmbgame/SteamTools/badge/star.svg)](https://gitee.com/rmbgame/SteamTools)
[![QQ群](https://img.shields.io/badge/QQ群-101075312-blue.svg?style=flat-square&color=12b7f5)](https://qm.qq.com/cgi-bin/qm/qr?k=JVlZF31RKSDqcsxfEaw6AQE75P2NF18F&jump_from=webapi)
</div>
Expand Down
16 changes: 16 additions & 0 deletions src/Common.ClientLib/Application/Services/Mvvm/MvvmService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using ReactiveUI;

namespace System.Application.Services
{
public abstract class MvvmService<TService> : ReactiveObject where TService : MvvmService<TService>
{
static TService? mCurrent;
public static TService Current => mCurrent ??
throw new NullReferenceException($"{typeof(TService).Name} not initialized.");

public MvvmService()
{
mCurrent = (TService)this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using System.Diagnostics.CodeAnalysis;
using System.IO;

namespace System.Application.Serialization
namespace System.Application.Settings
{
public class FileSettingsProvider : ISerializationProvider
public sealed class FileSettingsProvider : ISerializationProvider
{
private readonly string _path;
private readonly object _sync = new();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Diagnostics.CodeAnalysis;

namespace System.Application.Serialization
namespace System.Application.Settings
{
public interface ISerializationProvider
{
Expand All @@ -11,7 +11,7 @@ public interface ISerializationProvider
void Load();

/// <summary>
/// 在provider已重新加载到期时发生
/// 在 provider 已重新加载到期时发生
/// </summary>
event EventHandler Reloaded;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.ComponentModel;
using System.Diagnostics;

namespace System.Application.Serialization
namespace System.Application.Settings
{
[DebuggerDisplay("Value={Value}, Key={Key}, Default={Default}")]
public class SerializableProperty<T> : INotifyPropertyChanged where T : notnull
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System.Application.Serialization;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;

namespace System.Application.Models.Settings
namespace System.Application.Settings
{
public abstract class SettingsHostBase
{
Expand Down Expand Up @@ -89,32 +88,32 @@ protected SettingsHost2(bool isSupported) : base()
public static SerializableProperty<T> GetProperty<T>(T? defaultValue, bool autoSave, [CallerMemberName] string propertyName = "") where T : notnull => GetProperty(GetKey, Local, defaultValue, autoSave, propertyName);
}

/// <summary>
/// 将当前类的设置项存储在当前类名命名的文件中的实例实现版本
/// </summary>
/// <typeparam name="TSettings"></typeparam>
public abstract class SettingsHost3<TSettings> : SettingsHost2<TSettings> where TSettings : SettingsHost3<TSettings>, new()
{
protected SettingsHost3() : base(false)
{
Local = new FileSettingsProvider(LocalFilePath);
}
///// <summary>
///// 将当前类的设置项存储在当前类名命名的文件中的实例实现版本
///// </summary>
///// <typeparam name="TSettings"></typeparam>
//public abstract class SettingsHost3<TSettings> : SettingsHost2<TSettings> where TSettings : SettingsHost3<TSettings>, new()
//{
// protected SettingsHost3() : base(false)
// {
// Local = new FileSettingsProvider(LocalFilePath);
// }

protected internal override string GetCategoryName() => CategoryName;
// protected internal override string GetCategoryName() => CategoryName;

static string ConfigName => $"{CategoryName.TrimEnd("Settings", StringComparison.OrdinalIgnoreCase)}Config";
// static string ConfigName => $"{CategoryName.TrimEnd("Settings", StringComparison.OrdinalIgnoreCase)}Config";

readonly Lazy<string> _LocalFilePath = new(() => GetLocalFilePath(ConfigName + FileEx.MPO));
public new string LocalFilePath => _LocalFilePath.Value;
// readonly Lazy<string> _LocalFilePath = new(() => GetLocalFilePath(ConfigName + FileEx.MPO));
// public new string LocalFilePath => _LocalFilePath.Value;

public new ISerializationProvider Local { get; }
// public new ISerializationProvider Local { get; }

public static TSettings Instance => GetInstance<TSettings>();
// public static TSettings Instance => GetInstance<TSettings>();

string GetKey(string propertyName) => $"{((SettingsHostBase)this).CategoryName}.{propertyName}";
// string GetKey(string propertyName) => $"{((SettingsHostBase)this).CategoryName}.{propertyName}";

public new SerializableProperty<T> GetProperty<T>(T? defaultValue, bool autoSave, [CallerMemberName] string propertyName = "") where T : notnull => GetProperty(GetKey, Local, defaultValue, autoSave, propertyName);
}
// public new SerializableProperty<T> GetProperty<T>(T? defaultValue, bool autoSave, [CallerMemberName] string propertyName = "") where T : notnull => GetProperty(GetKey, Local, defaultValue, autoSave, propertyName);
//}

// ----- 示例 -----

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace System.Application.Serialization
namespace System.Application.Settings
{
public class ValueChangedEventArgs<T> : EventArgs where T : notnull
public sealed class ValueChangedEventArgs<T> : EventArgs where T : notnull
{
public T? OldValue { get; }
public T? NewValue { get; }
Expand Down
91 changes: 0 additions & 91 deletions src/Common.CoreLib/CodeValuePair.cs

This file was deleted.

1 change: 1 addition & 0 deletions src/Common.CoreLib/Common.CoreLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@
<LastGenOutput>SR.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// ReSharper disable once CheckNamespace
namespace System
{
public static class ViewModelExtensions
public static partial class DisposableExtensions
{
/// <summary>
/// 将 <see cref="IDisposable"/> 对象添加 <see cref="IDisposableHolder.CompositeDisposable"/> 中
Expand Down Expand Up @@ -47,4 +47,4 @@ public static bool RemoveTo<T>(this T? disposable, IDisposableHolder vm) where T
return r;
}
}
}
}
69 changes: 68 additions & 1 deletion src/Common.CoreLib/Extensions/TaskExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Runtime.CompilerServices;

// ReSharper disable once CheckNamespace
namespace System
{
public static class TaskExtensions
public static partial class TaskExtensions
{
static readonly TaskFactory _myTaskFactory = new(CancellationToken.None,
TaskCreationOptions.None, TaskContinuationOptions.None, TaskScheduler.Default);
Expand Down Expand Up @@ -58,5 +60,70 @@ public static void RunSync(this Func<ValueTask> func)
return func().AsTask();
}).Unwrap().GetAwaiter().GetResult();
}

public static Task Forget(
this Task task,
[CallerMemberName] string callerMemberName = "",
[CallerFilePath] string callerFilePath = "",
[CallerLineNumber] int callerLineNumber = 0)
{
task.ContinueWith(
x => TaskLog.Raise(new TaskLog(callerMemberName, callerFilePath, callerLineNumber, x.Exception)),
TaskContinuationOptions.OnlyOnFaulted).ConfigureAwait(false);
return task;
}

public static void ForgetAndDispose(
this Task task,
[CallerMemberName] string callerMemberName = "",
[CallerFilePath] string callerFilePath = "",
[CallerLineNumber] int callerLineNumber = 0)
{
task.ContinueWith(
x => TaskLog.Raise(new TaskLog(callerMemberName, callerFilePath, callerLineNumber, x.Exception)),
TaskContinuationOptions.OnlyOnFaulted).ContinueWith(s => s.Dispose()).ConfigureAwait(false);
}

public static Task WhenAll(this IEnumerable<Task> tasks) => Task.WhenAll(tasks);

public static Task<T[]> WhenAll<T>(this IEnumerable<Task<T>> tasks) => Task.WhenAll(tasks);

sealed class TaskLog
{
public string CallerMemberName { get; }

public string CallerFilePath { get; }

public int CallerLineNumber { get; }

public Exception Exception { get; }

public TaskLog(string callerMemberName, string callerFilePath, int callerLineNumber, Exception exception)
{
CallerMemberName = callerMemberName;
CallerFilePath = callerFilePath;
CallerLineNumber = callerLineNumber;
Exception = exception;
}


public static readonly EventHandler<TaskLog> Occured = (sender, e) =>
{
const string format = @"Unhandled Exception occured from Task.Forget()
-----------
Caller file : {1}
: line {2}
Caller member: {0}
Exception: {3}
";
System.Diagnostics.Debug.WriteLine(format, e.CallerMemberName, e.CallerFilePath, e.CallerLineNumber, e.Exception);
};

internal static void Raise(TaskLog log)
{
Occured?.Invoke(typeof(TaskLog), log);
}
}
}
}
4 changes: 3 additions & 1 deletion src/Common.CoreLib/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using static System.Properties.ThisAssembly;

Expand All @@ -10,4 +11,5 @@
[assembly: AssemblyDescription(AssemblyDescription)]
[assembly: AssemblyProduct(AssemblyProduct)]
[assembly: AssemblyCopyright(AssemblyCopyright)]
[assembly: AssemblyCompany(AssemblyCompany)]
[assembly: AssemblyCompany(AssemblyCompany)]
[assembly: NeutralResourcesLanguage("zh-Hans")]
Loading

0 comments on commit 5e41320

Please sign in to comment.