From 78f18cac17b964d454bb2793bb6eb0c68a030041 Mon Sep 17 00:00:00 2001
From: Kyle Spearrin <kyle.spearrin@gmail.com>
Date: Fri, 6 Oct 2017 15:07:30 -0400
Subject: [PATCH] fixes to razor mail service

---
 .../Implementations/RazorMailService.cs       | 20 ++++---------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/src/Core/Services/Implementations/RazorMailService.cs b/src/Core/Services/Implementations/RazorMailService.cs
index 116dd820c3..c47126ec8c 100644
--- a/src/Core/Services/Implementations/RazorMailService.cs
+++ b/src/Core/Services/Implementations/RazorMailService.cs
@@ -222,7 +222,7 @@ namespace Bit.Core.Services
         {
             public override Task<RazorLightProjectItem> GetItemAsync(string templateKey)
             {
-                if(string.IsNullOrEmpty(templateKey))
+                if(string.IsNullOrWhiteSpace(templateKey))
                 {
                     throw new ArgumentNullException(nameof(templateKey));
                 }
@@ -244,7 +244,7 @@ namespace Bit.Core.Services
 
             public CustomEmbeddedRazorProjectItem(string key)
             {
-                if(string.IsNullOrEmpty(key))
+                if(string.IsNullOrWhiteSpace(key))
                 {
                     throw new ArgumentNullException(nameof(key));
                 }
@@ -255,20 +255,8 @@ namespace Bit.Core.Services
             }
 
             public override string Key { get; set; }
-            public override bool Exists => true;
-
-            public override Stream Read()
-            {
-                using(var stream = _assembly.GetManifestResourceStream(_fullTemplateKey))
-                {
-                    if(stream == null)
-                    {
-                        throw new RazorLightException($"Couldn't load resource '{_fullTemplateKey}'.");
-                    }
-
-                    return stream;
-                }
-            }
+            public override bool Exists => _assembly.GetManifestResourceNames().Any(f => f == _fullTemplateKey);
+            public override Stream Read() => _assembly.GetManifestResourceStream(_fullTemplateKey);
         }
     }
 }