This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed class Debouncer : IAsyncDisposable | |
{ | |
private readonly TimeSpan delay; | |
private readonly Action action; | |
private readonly ITimer timer; | |
private bool isWaitingOrActing; | |
public Debouncer(TimeSpan delay, Action action, TimeProvider? timeProvider = null) | |
{ | |
this.delay = delay; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Buffers; | |
using System.Globalization; | |
public sealed class KdlWriter(TextWriter writer) | |
{ | |
private static readonly NumberFormatInfo DefaultNumberFormat = new() | |
{ | |
NumberGroupSeparator = "_", | |
NumberGroupSizes = [3], | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed class AsyncAutoResetEvent | |
{ | |
private readonly Lock @lock = new(); | |
private Task? currentWait; | |
private TaskCompletionSource? taskCompletionSource; | |
public void Set() | |
{ | |
lock (@lock) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Win32; | |
using Microsoft.Win32.SafeHandles; | |
using System; | |
using System.ComponentModel; | |
using System.Threading; | |
using Windows.Win32; | |
using Windows.Win32.Foundation; | |
using Windows.Win32.System.Registry; | |
/// <summary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
System.Tuple (System.Runtime 9.0.0.0): | |
- Tuple<T1> Create<T1>(T1) | |
System.Tuple (System.Runtime 9.0.0.0): | |
- Tuple<T1, T2> Create<T1, T2>(T1, T2) | |
System.Tuple (System.Runtime 9.0.0.0): | |
- Tuple<T1, T2, T3> Create<T1, T2, T3>(T1, T2, T3) | |
System.Tuple (System.Runtime 9.0.0.0): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create or alter proc dbo.RestoreDatabase(@databaseName sysname, @backupFilePath nvarchar(max), @replace bit, @progressPercentIncrement tinyint = 10) | |
as | |
set nocount on; | |
-- Get backup database name | |
declare @backups table (BackupName nvarchar(128), BackupDescription nvarchar(255), BackupType smallint, ExpirationDate datetime, Compressed binary(1), Position smallint, DeviceType tinyint, UserName nvarchar(128), ServerName nvarchar(128), DatabaseName nvarchar(128), DatabaseVersion int, DatabaseCreationDate datetime, BackupSize numeric(20,0), FirstLSN numeric(25,0), LastLSN numeric(25,0), CheckpointLSN numeric(25,0), DatabaseBackupLSN numeric(25,0), BackupStartDate datetime, BackupFinishDate datetime, SortOrder smallint, CodePage smallint, UnicodeLocaleId int, UnicodeComparisonStyle int, CompatibilityLevel tinyint, SoftwareVendorId int, SoftwareVersionMajor int, SoftwareVersionMinor int, SoftwareVersionBuild int, MachineName nvarchar(128), Flags int, BindingID uniqueidentifier, RecoveryForkID uniqueidentifier, Col |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Buffers; | |
using System.Buffers.Binary; | |
using System.Collections.Immutable; | |
using System.IO; | |
using System.Net; | |
using System.Net.NetworkInformation; | |
using System.Net.Sockets; | |
using System.Text; | |
using System.Threading.Channels; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Reflection; | |
internal static class ReflectionUtils | |
{ | |
public static bool IsVisibleOutsideAssembly(Type type) | |
{ | |
return (type.Attributes & TypeAttributes.VisibilityMask) switch | |
{ | |
TypeAttributes.Public => true, | |
TypeAttributes.NestedFamily or TypeAttributes.NestedFamORAssem => IsVisibleOutsideAssembly(type.DeclaringType!), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @databaseNameFilter sysname = '' | |
select | |
last_execution_time as LastExecutionTime, | |
last_elapsed_time * 0.000001 as ElapsedSeconds, | |
last_rows as LastRowCount, | |
total_rows as TotalRowCount, | |
execution_count as ExecutionCount, | |
objects.name as ObjectName, | |
SqlText.text as CommandText |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ComponentModel; | |
using System.Runtime.CompilerServices; | |
public abstract class ObservableObject : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler? PropertyChanged; | |
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) | |
{ | |
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
NewerOlder