mirror of
https://github.com/disposable-email-domains/disposable-email-domains.git
synced 2024-11-25 01:58:11 +08:00
C# usage sample
This commit is contained in:
parent
766ef1913b
commit
b1c04c5bad
24
README.md
24
README.md
@ -86,6 +86,30 @@ rl.on('close', () => {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**C#**
|
||||||
|
```C#
|
||||||
|
private static readonly Lazy<HashSet<string>> _emailBlackList =
|
||||||
|
new Lazy<HashSet<string>>(
|
||||||
|
() =>
|
||||||
|
{
|
||||||
|
var result = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
using (var reader = new StreamReader("disposable_email_blacklist.conf"))
|
||||||
|
{
|
||||||
|
string line;
|
||||||
|
while ((line = reader.ReadLine()) != null)
|
||||||
|
if (!string.IsNullOrWhiteSpace(line) && !line.TrimStart().StartsWith("//"))
|
||||||
|
result.Add(line);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
var addr = new MailAddress(email);
|
||||||
|
if (_emailBlackList.Value.Contains(addr.Host)))
|
||||||
|
throw new ApplicationException("Email is blacklisted.");
|
||||||
|
```
|
||||||
|
|
||||||
Contributing
|
Contributing
|
||||||
============
|
============
|
||||||
Feel free to create PR with additions or request removal of some domain (with reasons).
|
Feel free to create PR with additions or request removal of some domain (with reasons).
|
||||||
|
Loading…
Reference in New Issue
Block a user