Skip to content

Instantly share code, notes, and snippets.

💤
Sleeping...

walterlv walterlv

View GitHub Profile
@walterlv
walterlv / ExceptionDescriptor.cs
Last active Mar 24, 2019
Get the key descriptor of an Exception instance so that we can determine whether two exceptions are the same.
View ExceptionDescriptor.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace Walterlv
{
/// <summary>
/// 包含一个 <see cref="Exception"/> 对象的关键特征,可使用此对象的实例判断两个不同的异常实例是否极有可能表示同一个异常。
/// </summary>
@walterlv
walterlv / SelfInstaller.cs
Created Feb 27, 2019
这是一个简单的自更新程序的类。使用此类型,程序初次运行的时候会安装自己,如果已安装旧版本会更新自己,如果已安装最新则直接运行。
View SelfInstaller.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security.Principal;
namespace Walterlv.Installing
{
@walterlv
walterlv / ContinuousPartOperation.cs
Last active Mar 19, 2019
An awaitable for waiting a part of a loop.
View ContinuousPartOperation.cs
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Walterlv
{
/// <summary>
/// 为一个持续操作中的一部分提供可异步等待的操作。
/// </summary>
@walterlv
walterlv / FileWatcher.cs
Last active Mar 19, 2019
FileWatcher that helps you to watch a single file change even if the file or it's owner folders does not exists.
View FileWatcher.cs
using System;
using System.IO;
namespace Walterlv.IO
{
public sealed class FileWatcher
{
/// <summary>监视的文件。</summary>
private readonly FileInfo _file;
@walterlv
walterlv / AsyncBox.cs
Created Sep 8, 2018
A UI container for async loading.
View AsyncBox.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Threading;
using Walterlv.Annotations;
View CachePool.cs
using System;
using System.Collections.Generic;
using Walterlv.Annotations;
namespace Walterlv
{
/// <summary>
/// 如果获取 <typeparamref name="TSource"/> 对应信息的过程比较耗时(例如反射),
/// 则可使用 <see cref="CachePool{TSource,TCache}"/> 对此过程进行缓存。
/// </summary>
@walterlv
walterlv / AwaiterInterfaces.cs
Created Jul 11, 2018
Custom awaiter with background UI thread
View AwaiterInterfaces.cs
using System.Runtime.CompilerServices;
namespace Walterlv.Threading
{
/// <summary>
/// 表示一个可等待对象,如果一个方法返回此类型的实例,则此方法可以使用 `await` 异步等待。
/// </summary>
/// <typeparam name="TAwaiter">用于给 await 确定返回时机的 IAwaiter 的实例。</typeparam>
public interface IAwaitable<out TAwaiter> where TAwaiter : IAwaiter
{
@walterlv
walterlv / CommandArgumentAttribute.cs
Created Oct 21, 2017
Provide a reflection based wrapper for `Microsoft.Extensions.CommandlineUtils` Library.
View CommandArgumentAttribute.cs
using System;
namespace Mdmeta.Core
{
/// <summary>
/// Specify a property to receive argument of command from the user.
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public sealed class CommandArgumentAttribute : Attribute
{
View WindowBlur.cs
using System;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
using Walterlv.Demo.Interop.Native;
namespace Walterlv.Demo.Interop
{
public class WindowBlur
{
You can’t perform that action at this time.