暂时更改一部分Skill
This commit is contained in:
1 parent
84b28f9672
commit
6d4629e4ac
53 files changed
+5293
-10
No files matched your search
@@ -0,0 +1,381 @@
|
||||
# 常用 API 声明参考
|
||||
|
||||
来源:MAX.Common,2026-10-27 工作区源码快照。
|
||||
|
||||
按下方主题或文件名搜索。仅摘录选定文件的 public / protected 声明;省略方法体、初始化表达式与 XML 注释。这是定位参考,不是可直接编译的 C#,不保证包含嵌套类型的完整可见性上下文。行为说明见 SKILL.md;目标包版本不同时以实际包为准。
|
||||
|
||||
目录:命令与绑定模型、集合与数据、文件、数值与校验、事件与运行控制
|
||||
|
||||
## 命令与绑定模型
|
||||
|
||||
### Commands/MethodCommand.cs
|
||||
|
||||
命名空间:`MAX.Common.Commands`
|
||||
|
||||
```csharp
|
||||
public class MethodCommand( Action execute, Func<bool>? canExecute = null ) : ICommand
|
||||
public event EventHandler? CanExecuteChanged
|
||||
public bool CanExecute(object parameter)
|
||||
public void Execute(object parameter)
|
||||
public void RaiseCanExecuteChanged()
|
||||
public class MethodCommand<T> : ICommand
|
||||
public MethodCommand( Action<T> execute, Func<T, bool>? canExecute = null )
|
||||
public event EventHandler? CanExecuteChanged
|
||||
public bool CanExecute(object parameter)
|
||||
public void Execute(object parameter)
|
||||
public void RaiseCanExecuteChanged()
|
||||
```
|
||||
|
||||
### Commands/AsyncMethodCommand.cs
|
||||
|
||||
命名空间:`MAX.Common.Commands`
|
||||
|
||||
```csharp
|
||||
public class AsyncMethodCommand(Func<Task> execute, Func<bool>? canExecute = null) : ICommand
|
||||
public event EventHandler? CanExecuteChanged
|
||||
public bool CanExecute(object parameter)
|
||||
public async void Execute(object parameter)
|
||||
public void RaiseCanExecuteChanged()
|
||||
public class AsyncMethodCommand<T> : ICommand
|
||||
public event EventHandler? CanExecuteChanged
|
||||
public AsyncMethodCommand(Func<T, Task> execute, Func<T, bool>? canExecute = null)
|
||||
public bool CanExecute(object parameter)
|
||||
public async void Execute(object parameter)
|
||||
public void RaiseCanExecuteChanged()
|
||||
```
|
||||
|
||||
### Models/BindModelBase.cs
|
||||
|
||||
命名空间:`MAX.Common.Models`
|
||||
|
||||
```csharp
|
||||
public abstract class BindModelBase : INotifyPropertyChanged
|
||||
public event PropertyChangedEventHandler? PropertyChanged
|
||||
public BindModelBase()
|
||||
public virtual void OnInitialized()
|
||||
public virtual bool ShouldCheckValueMatching<T>(string? propertyName, T from, T to)
|
||||
protected virtual bool SetProperty<T>(ref T storage, T value, Action? onChanged = null, [CallerMemberName] string? propertyName = null)
|
||||
protected virtual bool SetPropertyNoCheck<T>(ref T storage, T value, Action? onChanged = null, [CallerMemberName] string? propertyName = null)
|
||||
protected virtual void OnPropertyChanging<T>(string? propertyName, T from, T to, CancelEventArgs cancelEventArgs)
|
||||
protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
|
||||
protected void RaisePropertyChanged([CallerMemberName] string? propertyName = null)
|
||||
```
|
||||
|
||||
### Models/BindableBaseEx.cs
|
||||
|
||||
命名空间:`MAX.Common.Models`
|
||||
|
||||
```csharp
|
||||
public abstract class BindableBaseEx : INotifyPropertyChanged
|
||||
public event PropertyChangedEventHandler? PropertyChanged
|
||||
public BindableBaseEx()
|
||||
public virtual void OnInitialized()
|
||||
public static string GetPropertyName<T>(Expression<Func<T>> expression)
|
||||
protected T? GetProperty<T>(Expression<Func<T>> expression)
|
||||
protected bool SetProperty<T>(Expression<Func<T>> expression, T value)
|
||||
protected bool SetProperty<T>(Expression<Func<T>> expression, T value, Action? changedCallback)
|
||||
protected bool SetProperty<T>(Expression<Func<T>> expression, T value, Action<T?>? changedCallback)
|
||||
protected bool SetProperty<T>(ref T storage, T value, Expression<Func<T>> expression)
|
||||
protected bool SetProperty<T>(ref T storage, T value, Expression<Func<T>> expression, Action? changedCallback)
|
||||
protected void RaisePropertyChanged<T>(Expression<Func<T>> expression)
|
||||
protected T? GetValue<T>([CallerMemberName] string? propertyName = null)
|
||||
protected bool SetValue<T>(T value, [CallerMemberName] string? propertyName = null)
|
||||
protected bool SetValue<T>(T value, Action? changedCallback, [CallerMemberName] string? propertyName = null)
|
||||
protected bool SetValue<T>(T value, Action<T?>? changedCallback, [CallerMemberName] string? propertyName = null)
|
||||
protected bool SetValue<T>(ref T storage, T value, [CallerMemberName] string? propertyName = null)
|
||||
protected bool SetValue<T>(ref T storage, T value, Action? changedCallback, [CallerMemberName] string? propertyName = null)
|
||||
protected bool SetProperty<T>(ref T storage, T value, string propertyName)
|
||||
protected virtual bool SetProperty<T>(ref T storage, T value, string propertyName, Action? changedCallback)
|
||||
protected virtual bool SetPropertyCore<T>(string propertyName, T value, out T? oldValue)
|
||||
protected virtual void RaisePropertyChanged(string propertyName)
|
||||
protected void RaisePropertyChanged()
|
||||
protected void RaisePropertiesChanged(params string[]? propertyNames)
|
||||
protected virtual void VerifyAccess()
|
||||
protected virtual bool CompareValues<T>(T storage, T value, string propertyName)
|
||||
```
|
||||
|
||||
### Models/BindObject.cs
|
||||
|
||||
命名空间:`MAX.Common.Models`
|
||||
|
||||
```csharp
|
||||
public sealed class BindObject<T> : BindModelBase
|
||||
public event TypedEventHandler<BindObject<T>, PropertyValueUpdatedEventArgs<T>>? ValueChanged
|
||||
public T? Value
|
||||
public BindObject(T? defaultValue = default)
|
||||
public void Set(T value)
|
||||
public static implicit operator BindObject<T>(T value)
|
||||
public static implicit operator T?(BindObject<T> value)
|
||||
```
|
||||
|
||||
## 集合与数据
|
||||
|
||||
### Data/Collections/BidirectionalDictionary.cs
|
||||
|
||||
命名空间:`MAX.Common.Data.Collections`
|
||||
|
||||
```csharp
|
||||
public class BidirectionalDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary, IReadOnlyCollection<KeyValuePair<TKey, TValue>>
|
||||
public TValue this[TKey key]
|
||||
public int Count
|
||||
public ICollection<TKey> Keys
|
||||
public ICollection<TValue> Values
|
||||
public bool IsReadOnly
|
||||
public bool IsFixedSize
|
||||
public bool IsSynchronized
|
||||
public object SyncRoot
|
||||
public BidirectionalDictionary()
|
||||
public BidirectionalDictionary(int capacity)
|
||||
public void Add(TKey key, TValue value)
|
||||
public bool Remove(TKey key)
|
||||
public bool RemoveByValue(TValue value)
|
||||
public void Clear()
|
||||
public bool TryGetValue(TKey key, out TValue value)
|
||||
public bool TryGetKey(TValue value, out TKey key)
|
||||
public TKey GetKey(TValue value)
|
||||
public TValue GetValue(TKey key)
|
||||
public bool ContainsKey(TKey key)
|
||||
public bool ContainsValue(TValue value)
|
||||
public void Add(KeyValuePair<TKey, TValue> item)
|
||||
public bool Contains(KeyValuePair<TKey, TValue> item)
|
||||
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
|
||||
public bool Remove(KeyValuePair<TKey, TValue> item)
|
||||
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
|
||||
```
|
||||
|
||||
### Data/Lists/CyclicReadOnlyList.cs
|
||||
|
||||
命名空间:`MAX.Common.Data.Lists`
|
||||
|
||||
```csharp
|
||||
public class CyclicReadOnlyList<T> : IReadOnlyList<T>
|
||||
public CyclicReadOnlyList(IReadOnlyList<T> source, int startIndex, int loopCount)
|
||||
public int Count
|
||||
public T this[int index]
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
```
|
||||
|
||||
### Data/Lists/SelectorReadonlyList.cs
|
||||
|
||||
命名空间:`MAX.Common.Data.Lists`
|
||||
|
||||
```csharp
|
||||
public class SelectorReadonlyList<TSource, TResult>(IReadOnlyList<TSource> source, Func<TSource, TResult> selector) : IReadOnlyList<TResult>
|
||||
public TResult this[int index]
|
||||
public int Count
|
||||
public IEnumerator<TResult> GetEnumerator()
|
||||
public static class SelectorReadonlyListExtensions
|
||||
public static IReadOnlyList<TResult> SelectAsReadonlyList<TSource, TResult>(this IReadOnlyList<TSource> source, Func<TSource, TResult> selector)
|
||||
```
|
||||
|
||||
### Data/Lists/ReversedReadonlyList.cs
|
||||
|
||||
命名空间:`MAX.Common.Data.Lists`
|
||||
|
||||
```csharp
|
||||
public class ReversedReadonlyList<T>(IReadOnlyList<T> source) : IReadOnlyList<T>
|
||||
public IReadOnlyList<T> Source
|
||||
public virtual T this[int index]
|
||||
public int Count
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
```
|
||||
|
||||
### Data/PrecisionBuilder.cs
|
||||
|
||||
命名空间:`MAX.Common.Data`
|
||||
|
||||
```csharp
|
||||
public class PrecisionBuilder
|
||||
public int PrecisionLength
|
||||
public bool UseScientificNotation
|
||||
public int ScientificNatationTriggerLength
|
||||
public bool RemoveTrailingZeros
|
||||
public PrecisionBuilder( int precisionLength, bool useScientificNotation, int scientificNatationTriggerLength, bool removeTrailingZeros )
|
||||
public PrecisionBuilder( int precisionLength, bool useScientificNotation, int scientificNatationTriggerLength, bool removeTrailingZeros, string scientificNotationString, string autoString )
|
||||
public string GetResultString(double d)
|
||||
```
|
||||
|
||||
### Models/EnumItem.cs
|
||||
|
||||
命名空间:`MAX.Common.Models`
|
||||
|
||||
```csharp
|
||||
public readonly record struct EnumItem( string Name, object Value, string? Description, string? ToolTip )
|
||||
public static IEnumerable<EnumItem> GetEnumItems<T>() where T : Enum
|
||||
public static IEnumerable<EnumItem> GetEnumItems(Type type)
|
||||
public static EnumItem GetEnumItem(Enum @enum)
|
||||
```
|
||||
|
||||
## 文件、数值与校验
|
||||
|
||||
### Helpers/FileHelper.Size.cs
|
||||
|
||||
命名空间:`MAX.Common.Helpers`
|
||||
|
||||
```csharp
|
||||
public static partial class FileHelper
|
||||
public static string FileSizeToKB(this long size, string format = "#,##0", string prefix = "", string suffix = " KB")
|
||||
public static string FileSizeToMB(this long size, string format = "#,##0", string prefix = "", string suffix = " MB")
|
||||
public static string FileSizeToGB(this long size, string format = "#,##0", string prefix = "", string suffix = " GB")
|
||||
public static string FileSizeToTB(this long size, string format = "#,##0", string prefix = "", string suffix = " TB")
|
||||
public static string FileSizeToPB(this long size, string format = "#,##0", string prefix = "", string suffix = " PB")
|
||||
public static string FileSizeToString(this long size, string format = "#,##0.##", string prefix = "")
|
||||
```
|
||||
|
||||
### Helpers/FileHelper.cs
|
||||
|
||||
命名空间:`MAX.Common.Helpers`
|
||||
|
||||
```csharp
|
||||
public static partial class FileHelper
|
||||
public static string GetUniqueFileName(string fullPath)
|
||||
public static string FixInvalidFullFilePath(string fullPath, string replacement = " ")
|
||||
public static bool IsFileNameInvalid(this string name)
|
||||
public static string FixInvalidFileName(string fileName, string replacement = " ")
|
||||
public static bool FileNameExists(this string fileName, IEnumerable<string> fileNames)
|
||||
public static Exception? ShowInExplorer(this string? filePath)
|
||||
public static Exception? OpenPathInSystemDefault(this string? filePath)
|
||||
public static async Task<string> CalculateFileMD5Async(string filePath, int bufferSize = 4096)
|
||||
public static string CalculateFileMD5(string filePath, int bufferSize = 4096)
|
||||
public static string? CalculateFileMD5(byte[]? bytes)
|
||||
public static async Task<string?> CalculateFileMD5Async(byte[]? bytes)
|
||||
public static List<string> ReadAllLines(string filePath, Encoding? encoding = null)
|
||||
public static FileInfo? SafeGetFileInfo(this string? filePath, Action<Exception>? handleException = null)
|
||||
public static bool AreFilePathsEqual(this string? path1, string? path2)
|
||||
public static bool? AreFilePathsEqualSafe(this string? path1, string? path2)
|
||||
public static string NormalizePath(this string? path)
|
||||
public static string NormalizePathSafe(this string? path)
|
||||
```
|
||||
|
||||
### Helpers/DirectoryHelper.cs
|
||||
|
||||
命名空间:`MAX.Common.Helpers`
|
||||
|
||||
```csharp
|
||||
public static class DirectoryHelper
|
||||
public static bool IsRootDirectory(string path)
|
||||
public static bool IsWindowsRootDirectory(string path)
|
||||
public static bool IsUnixRootDirectory(string path)
|
||||
public static DirectoryInfo CreateDirectory(string? dir, bool checkFileParent = false)
|
||||
public static Exception? TryCreateDirectory(string? dir, bool checkFileParent = false)
|
||||
public static bool HasWriteAccessToFolder(string folderPath)
|
||||
public static void CopyDirectory( string sourceDir, string destinationDir, bool recursive = true, Predicate<FileInfo>? handleFile = null )
|
||||
public static string GetUniqueFolderName(string folderPath, bool reuseEmptyDirectory = false)
|
||||
public static bool IsDirectoryEmpty(this string folderPath)
|
||||
public static bool IsDirectoryEmptyOrNotExist(this string folderPath)
|
||||
public static string AppendDirectorySeparatorChar(string path)
|
||||
public static string GetRelativePath(string relativeTo, string path)
|
||||
```
|
||||
|
||||
### Helpers/NumberHelper.Clamp.cs
|
||||
|
||||
命名空间:`MAX.Common.Helpers`
|
||||
|
||||
```csharp
|
||||
public static partial class NumberHelper
|
||||
public static T ClampGeneric<T>(this T value, T min, T max) where T : IComparable<T>
|
||||
public static float Clamp(this float input, float min, float max)
|
||||
public static double Clamp(this double input, double min, double max)
|
||||
public static decimal Clamp(this decimal input, decimal min, decimal max)
|
||||
public static int Clamp(this int input, int min, int max)
|
||||
public static long Clamp(this long input, long min, long max)
|
||||
public static short Clamp(this short input, short min, short max)
|
||||
public static sbyte Clamp(this sbyte input, sbyte min, sbyte max)
|
||||
public static uint Clamp(this uint input, uint min, uint max)
|
||||
public static ulong Clamp(this ulong input, ulong min, ulong max)
|
||||
public static ushort Clamp(this ushort input, ushort min, ushort max)
|
||||
public static byte Clamp(this byte input, byte min, byte max)
|
||||
```
|
||||
|
||||
### Utilities/PathValidator.cs
|
||||
|
||||
命名空间:`MAX.Common.Utilities`
|
||||
|
||||
```csharp
|
||||
public static partial class PathValidator
|
||||
public static bool IsFolderPathValidAndSafe([NotNullWhen(true)] string? path, bool allowRelativePath)
|
||||
```
|
||||
|
||||
### Utilities/FolderNameValidator.cs
|
||||
|
||||
命名空间:`MAX.Common.Utilities`
|
||||
|
||||
```csharp
|
||||
public static class FolderNameValidator
|
||||
public enum ValidationResult
|
||||
public static IReadOnlyCollection<string> ReservedNamesInWindows
|
||||
public static bool IsValidFolderName([NotNullWhen(true)] string? folderName)
|
||||
public static ValidationResult Validate(string? folderName)
|
||||
public static string GetErrorMessage(ValidationResult result)
|
||||
```
|
||||
|
||||
## 事件与运行控制
|
||||
|
||||
### Events/TypedEvent.cs
|
||||
|
||||
命名空间:`MAX.Common.Events`
|
||||
|
||||
```csharp
|
||||
public class TypedEvent<TSender, TArgs>
|
||||
public event TypedEventHandler<TSender, TArgs>? Event
|
||||
public void Raise(TSender sender, TArgs args)
|
||||
public class TypedEvent<TArgs>
|
||||
public event Action<TArgs>? Event
|
||||
public void Raise(TArgs args)
|
||||
public class TypedEvent
|
||||
public event Action? Event
|
||||
public void Raise()
|
||||
```
|
||||
|
||||
### Events/AsyncEvent.cs
|
||||
|
||||
命名空间:`MAX.Common.Events`
|
||||
|
||||
```csharp
|
||||
public class AsyncEvent<TEventArgs> where TEventArgs : EventArgs
|
||||
public static AsyncEvent<TEventArgs> operator +(AsyncEvent<TEventArgs>? e, Func<object, TEventArgs, Task>? callback)
|
||||
public static AsyncEvent<TEventArgs>? operator -(AsyncEvent<TEventArgs>? e, Func<object, TEventArgs, Task> callback)
|
||||
public async Task InvokeAsync(object sender, TEventArgs eventArgs)
|
||||
```
|
||||
|
||||
### Utilities/RunLimiter.cs
|
||||
|
||||
命名空间:`MAX.Common.Utilities`
|
||||
|
||||
```csharp
|
||||
public class RunLimiter(Action action, int maxLimit = 1)
|
||||
public bool Run()
|
||||
public bool CanRun()
|
||||
```
|
||||
|
||||
### Utilities/DisposeAction.cs
|
||||
|
||||
命名空间:`MAX.Common.Utilities`
|
||||
|
||||
```csharp
|
||||
public class DisposeAction(Action action) : IDisposable
|
||||
public Action Action
|
||||
public void Dispose()
|
||||
```
|
||||
|
||||
### Utilities/CompensatingTimer.cs
|
||||
|
||||
命名空间:`MAX.Common.Utilities`
|
||||
|
||||
```csharp
|
||||
public class CompensatingTimer : IDisposable
|
||||
public event Action<Exception>? OnTickException
|
||||
public CompensatingTimer(TimeSpan interval, Action tickCallback)
|
||||
public void Start()
|
||||
public void Stop()
|
||||
public void Dispose()
|
||||
```
|
||||
|
||||
### Helpers/SerializationHelper.cs
|
||||
|
||||
命名空间:`MAX.Common.Helpers`
|
||||
|
||||
```csharp
|
||||
public static class SerializationHelper
|
||||
public static T? TryGetValue<T>(this SerializationInfo info, string name, T? defaultWhenException = default)
|
||||
```
|
||||
Reference in new issue
Block a user