Last active
July 12, 2019 06:47
-
-
Save CoditCompany/53abd555a53c39ec0bf025971dd31bdf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Specification before the actual check of the base-uri. | |
Spec<Uri> spec = | |
Spec.Of<Uri>() | |
.Add(uri => uri.Scheme == Uri.UriSchemeHttps, "should be 'https' scheme"); | |
// Demonstration purposes, generic type could be anything. | |
IObservable<T> obs = null; | |
// Access controlled function with validation, revocation, limited amount of evaluations and time-based availability. | |
Access<Uri, Uri> access = | |
Access.OnlyUriFromBase(new Uri("https://localhost:9090/")) | |
.Satisfy(spec) | |
.Once() | |
.DuringHours(9, 17) | |
.RevokedWhen(obs); | |
// Somewhere else... | |
AccessResult<Uri> result = access.Eval(new Uri("http://localhost:9090/path")); | |
if (result.TryGetValue(out Uri output)) | |
{ | |
// use the now correct 'output' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment