Created
July 21, 2017 04:02
-
-
Save litichevskiydv/39ad3efb3f0726f84b9ec5aa0c8e1317 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
namespace ImageValidator | |
{ | |
using System; | |
using System.IO; | |
using System.Linq; | |
using System.Reflection; | |
using System.Threading; | |
using Dapper; | |
using JetBrains.Annotations; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.Options; | |
using Skeleton.Dapper.ConnectionsFactory; | |
[UsedImplicitly] | |
static class Program | |
{ | |
private static IConfigurationRoot _configuration; | |
private static void BuildConfiguration(string[] commandLineArguments) | |
{ | |
var environmentConfiguration = new ConfigurationBuilder() | |
.AddCommandLine(commandLineArguments) | |
.AddEnvironmentVariables("IMAGEVALIDATOR_") | |
.Build(); | |
var environmentName = environmentConfiguration["environment"]; | |
_configuration = new ConfigurationBuilder() | |
.SetBasePath(Path.GetDirectoryName(typeof(Program).GetTypeInfo().Assembly.Location)) | |
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) | |
.AddCommandLine(commandLineArguments) | |
.AddEnvironmentVariables() | |
.Build(); | |
} | |
static int Main(string[] args) | |
{ | |
BuildConfiguration(args); | |
var connectionsFactory = | |
new SqlConnectionsFactory(Options.Create( | |
new SqlConnectionsFactoryOptions {SqlServer = _configuration.GetConnectionString("SqlServer")})); | |
using (var connection = connectionsFactory.Create()) | |
{ | |
var actualCollation = connection.Query<string>("select collation_name from sys.databases where name = 'tempdb'").Single(); | |
if (string.Equals(_configuration.GetValue<string>("ExpectedCollation"), actualCollation, StringComparison.OrdinalIgnoreCase) == false) | |
return 1; | |
} | |
return 0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment