From 78f18cac17b964d454bb2793bb6eb0c68a030041 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin 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 116dd820c..c47126ec8 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 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); } } }