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
<ItemGroup> | |
<EmbeddedResource Include="Configuration\config.json" /> | |
</ItemGroup> |
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
namespace Foo.Configuration | |
{ | |
public interface IConfiguration | |
{ | |
string ApiBaseAddress { get; set; } | |
} | |
public class Configuration : IConfiguration | |
{ | |
[JsonConstructor] |
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
using System.IO; | |
using System.Reflection; | |
using Autofac; | |
using Newtonsoft.Json; | |
using Foo.Configuration; | |
using Module = Autofac.Module; | |
namespace Foo.Modules | |
{ | |
public class ConfigurationModule : Module |
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
Animated.loop( | |
Animated.sequence([ | |
Animated.delay(3000), | |
Animated.timing(this.state.width, { | |
toValue: 400, | |
duration: 2000 | |
}) | |
]), | |
{ | |
iterations: 10 |
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
animateWidth() { | |
Animated.sequence([ | |
Animated.delay(3000), | |
Animated.timing(this.state.width, { | |
toValue: 400, | |
duration: 2000 | |
}) | |
]).start(() => { | |
// Logic whenever an iteration finishes... | |
this.animateWidth() |
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
[HttpPost] | |
public async Task<IActionResult> Post(Guid id, string name) | |
{ | |
Guard.GuidNotEmpty(id, nameof(id)); | |
Guard.StringNotNullOrEmpty(name, nameof(name)); | |
// handle the request | |
} |
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
public static class Guard | |
{ | |
public static void GuidNotEmpty(Guid argument, string argumentName) | |
{ | |
if (argument == Guid.Empty) | |
throw new ArgumentException("Guid should not be empty.", argumentName); | |
} | |
public static void StringNotNullOrEmpty(string argument, string argumentName) | |
{ |
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
public sealed class GuardException : Exception | |
{ | |
public string ArgumentName { get; } | |
public GuardException(string argumentName, string message) | |
: base(message) | |
{ | |
ArgumentName = argumentName; | |
} | |
} |
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
public static class Guard | |
{ | |
public static void GuidNotEmpty(Guid argument, string argumentName) | |
{ | |
if (argument == Guid.Empty) | |
throw new GuardException(argumentName, "Guid should not be empty."); | |
} | |
public static void StringNotNullOrEmpty(string argument, string argumentName) | |
{ |
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
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. | |
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | |
{ | |
app.UseExceptionHandler(errorApp => | |
{ | |
errorApp.Run(async context => | |
{ | |
var exceptionHandlingFeature = context.Features.Get<IExceptionHandlerPathFeature>(); | |
if (exceptionHandlingFeature?.Error is GuardException ex) |