Skip to content

Instantly share code, notes, and snippets.

public class Startup
{
public void ConfigureServices( IServiceCollection services )
{
services.AddMvc();
services.AddApiVersioning();
}}
}
module.exports = function() {
var azure = require('azure');
var topic = "foo-bar";
var connectionString = "Endpoint=sb://";
console.log("Configuring Service Bus.");
var serviceBusService = azure.createServiceBusService(connectionString);
var movies = [];
module.exports = function() {
var azure = require('azure');
var topic = "foo-bar";
var connectionString = "Endpoint=sb://...";
console.log("Configuring Service Bus.");
var serviceBusService = azure.createServiceBusService(connectionString);
var movies = [];
var difference = new Set(existingIntegers);
for(var index = 0; index < downloadedIntegers.length; index++) {
if (!existingIntegers.has(downloadedIntegers[index])) {
difference.push(downloadedIntegers[index]);
}
}
var difference = array1.filter(function(item, index) {
return !array2.includes(item);
});
@scionwest
scionwest / MultiModelValidator.cs
Last active February 4, 2018 00:51
Validation 2.0
public class AccountValidator : Validator<Account>
{
public AccountValidator()
{
base.AddSpecifications(
new EmailAddressFormatIsValidSpec(),
new PasswordIsRequiredSpec(),
new StringIsNotEmpty<User>(model => model.Username),
new StringIsNotEmpty<Account>(model => model.AccountNumber),
new UsernameIsRequiredSpec());
/// <summary>
/// Specification to ensure a string property on a model has a value
/// </summary>
public class MinimumLengthSpecification<TEntity> : ISpecification<TEntity>
{
// Store the property selector
private readonly Func<TEntity, string> propertySelector;
private readonly int minimumLength;
public class Startup
{
private IContainer ApplicationContainer;
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
@scionwest
scionwest / example.cs
Created June 15, 2017 15:32
Unit of WOrk
// Create repositories as part of a unit of work.
using (IUnitOfWork unitOfWork = this.UnitOfWorkFactory.CreateUnitOfWork())
{
IMovieHeaderRepository repo2 = unitOfWork.GetRepository<IMovieHeaderRepository>();
await repo2.Save(this.Movie);
IGenreRepository repo3 = unitOfWork.GetRepository<IGenreRepository>();
foreach(Movie movie in movies)
await repo3.Save(movie.Genre);
}
syntax = "proto3";
package AComms.Services;
// Client service definitions
service Messenger {
// Send a greeting message
rpc SayHello(HelloRequest) returns (HelloReply) {}
}