update
This commit is contained in:
@@ -63,7 +63,7 @@ namespace BITKit
|
||||
/// 主线程
|
||||
/// </summary>
|
||||
public static SynchronizationContext SynchronizationContext { get; private set; }
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public class OpenPath : IAction, IDisposable
|
||||
{
|
||||
@@ -73,9 +73,11 @@ namespace BITKit
|
||||
{
|
||||
path = null;
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
path = path.Replace(@"/", @"\");
|
||||
//path = string.IsNullOrEmpty(path) ? Environment.CurrentDirectory : path.Replace(@"/", @"\");
|
||||
path = string.IsNullOrEmpty(path) ? Environment.CurrentDirectory : System.IO.Path.Combine(Environment.CurrentDirectory, path);
|
||||
BIT4Log.Log<OpenPath>($"正在打开文件夹:{path}");
|
||||
try
|
||||
{
|
||||
@@ -88,6 +90,7 @@ namespace BITKit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class OpenAPP : IAction, IDisposable
|
||||
{
|
||||
@@ -214,6 +217,7 @@ namespace BITKit
|
||||
CancellationTokenSource = default;
|
||||
State = InitializationState.None;
|
||||
BIT4Log.Log<BITApp>($"已停止{nameof(BITApp)}");
|
||||
BIT4Log.Log<BITApp>("----------------------------------------");
|
||||
}
|
||||
public static void Run(string path, string WorkingDirectory = "")
|
||||
{
|
||||
|
@@ -60,6 +60,7 @@ namespace BITKit
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static IEnumerable<T[]> Combinations<T>(IEnumerable<T> source)
|
||||
{
|
||||
if (null == source) throw new ArgumentNullException(nameof(source));
|
||||
@@ -74,13 +75,14 @@ namespace BITKit
|
||||
switch (self)
|
||||
{
|
||||
case List<T> list:
|
||||
list.Insert(index,item);
|
||||
list.Insert(index, item);
|
||||
break;
|
||||
default:
|
||||
var _list = self.ToList();
|
||||
_list.Insert(index,item);
|
||||
_list.Insert(index, item);
|
||||
return _list;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -91,8 +93,10 @@ namespace BITKit
|
||||
{
|
||||
value = self.ElementAt(0);
|
||||
}
|
||||
|
||||
return value is not null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 组合集合中的所有元素
|
||||
/// </summary>
|
||||
@@ -113,6 +117,7 @@ namespace BITKit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取集合中所有的组合,每个组合中的元素个数为输入集合的元素个数,每个元素只出现一次
|
||||
/// </summary>
|
||||
@@ -132,5 +137,34 @@ namespace BITKit
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Linq Distinct扩展方法,可以传入自定义比较器
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="comparer"></param>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<T> Distinct<T>(
|
||||
this IEnumerable<T> source, Func<T, T, bool> comparer)
|
||||
where T : class
|
||||
=> source.Distinct(new DynamicEqualityComparer<T>(comparer));
|
||||
/// <summary>
|
||||
/// 动态自定义比较器
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
private sealed class DynamicEqualityComparer<T> : IEqualityComparer<T>
|
||||
where T : class
|
||||
{
|
||||
private readonly Func<T, T, bool> _func;
|
||||
|
||||
public DynamicEqualityComparer(Func<T, T, bool> func)
|
||||
{
|
||||
_func = func;
|
||||
}
|
||||
|
||||
public bool Equals(T x, T y) => _func(x, y);
|
||||
|
||||
public int GetHashCode(T obj) => 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user