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
// A C# port of MRZ parser at https://github.com/DoubangoTelecom/ultimateMRZ-SDK/blob/71e507ffc33fb5a24a2fa127c72a41f3755f31e0/samples/c%2B%2B/mrz_parser.h#L1 | |
using System; | |
using System.Collections.Generic; | |
using System.Globalization; | |
using System.Linq; | |
using System.Text.RegularExpressions; | |
namespace ImranB.Parsers | |
{ | |
public class MrzData |
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 Mapper | |
{ | |
public static T2 Map<T1, T2>(T1 t1) | |
{ | |
var json = JsonConvert.SerializeObject(t1); | |
return JsonConvert.DeserializeObject<T2>(json); | |
} | |
} |
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
private static string SanitizeUrl(string url) | |
{ | |
var uri = new Uri(url); | |
var path = uri.GetLeftPart(UriPartial.Path); | |
path += path.EndsWith("/") ? "" : "/"; | |
var query = uri.ParseQueryString(); | |
var dict = new SortedDictionary<string, string>(query.AllKeys | |
.Where(k => !string.IsNullOrWhiteSpace(query[k])) | |
.ToDictionary(k => k, k => query[k])); | |
return (path + ToQueryString(dict)).ToLower(); |
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
//await connection.OpenWithRetryAsync(retryPolicy).ConfigureAwait(false); | |
//var reader = await command.ExecuteReaderWithRetryAsync(retryPolicy).ConfigureAwait(false); | |
public static Task OpenWithRetryAsync(this SqlConnection connection, | |
RetryPolicy retryPolicy) | |
{ | |
return retryPolicy.ExecuteAsync(connection.OpenAsync); | |
} | |
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
BEGIN TRANSACTION [Tran1] | |
BEGIN TRY | |
EXEC('RAISERROR ( ''Create Table Currencies'', 10,1) WITH NOWAIT'); | |
EXEC(' | |
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N''[dbo].[Currencies]'') AND type in (N''U'')) | |
BEGIN | |
CREATE TABLE [dbo].[Currencies] | |
( | |
[Id] [INT] IDENTITY(1,1) NOT NULL PRIMARY KEY, |
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
private async Task<IList<Product>> GetProductsAsync() | |
{ | |
var sqlCommandWrapper = new SqlCommandWrapper("YourConnString", 90);// connection string and timeout | |
var parameters = new SqlParameter[] {}; | |
return (await sqlCommandWrapper.ExecuteReaderAsync(CommandType.Text, // For stored-procedured no need to pass CommandType param | |
"Select Top 2 Id, Name From Products", | |
r => | |
new Product | |
{ | |
Id = (int)r["Id"], |
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
// =============================================================================== | |
// Microsoft Data Access Application Block for .NET | |
// http://msdn.microsoft.com/library/en-us/dnbda/html/daab-rm.asp | |
// | |
// cs | |
// | |
// This file contains the implementations of the SqlHelper and SqlHelperParameterCache | |
// classes. | |
// | |
// For more information see the Data Access Application Block Implementation Overview. |