From 6bb0d736be4046f25690ee49db8cec81e1ec8750 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Fri, 22 Apr 2016 23:29:38 +0100 Subject: [PATCH] Add RequireNonNull http://www.yinwang.org/blog-cn/2015/11/21/programming-philosophy --- Wox.Infrastructure/StringMatcher.cs | 5 ++++- Wox.Infrastructure/SyntaxSuger.cs | 19 +++++++++++++++++++ Wox.Infrastructure/Wox.Infrastructure.csproj | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 Wox.Infrastructure/SyntaxSuger.cs diff --git a/Wox.Infrastructure/StringMatcher.cs b/Wox.Infrastructure/StringMatcher.cs index 6261d9a067..1c8f6ab0b7 100644 --- a/Wox.Infrastructure/StringMatcher.cs +++ b/Wox.Infrastructure/StringMatcher.cs @@ -1,4 +1,7 @@ -namespace Wox.Infrastructure +using System; +using JetBrains.Annotations; + +namespace Wox.Infrastructure { public class StringMatcher { diff --git a/Wox.Infrastructure/SyntaxSuger.cs b/Wox.Infrastructure/SyntaxSuger.cs new file mode 100644 index 0000000000..40be92fe29 --- /dev/null +++ b/Wox.Infrastructure/SyntaxSuger.cs @@ -0,0 +1,19 @@ +using System; + +namespace Wox.Infrastructure +{ + static class SyntaxSuger + { + public static T RequireNonNull(T obj) + { + if (obj == null) + { + throw new NullReferenceException(); + } + else + { + return obj; + } + } + } +} diff --git a/Wox.Infrastructure/Wox.Infrastructure.csproj b/Wox.Infrastructure/Wox.Infrastructure.csproj index 0b1d86dae7..76c669bc22 100644 --- a/Wox.Infrastructure/Wox.Infrastructure.csproj +++ b/Wox.Infrastructure/Wox.Infrastructure.csproj @@ -68,6 +68,7 @@ +