Skip to content

Instantly share code, notes, and snippets.

internal class ProcessInvoker
{
/// <summary>
/// Invokes the host process for test service
/// </summary>
public static void InvokeDummyService()
{
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
ProcessStartInfo info = new ProcessStartInfo(Path.Combine(path, "DummyService.exe"));
@vendettamit
vendettamit / AsyncHelperForSyncRun.cs
Created January 28, 2016 16:50
A helper to run Async method as sync to avoid context switch dead lock.
///<Remark>
/// Usage: AsyncHelper.RunSync(await () => _httpClient.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead))
/// Ref - http://stackoverflow.com/questions/35066721/c-sharp-httpclient-block-for-async-call-deadlock
///</Remark>
public static class AsyncHelper
{
private static readonly TaskFactory _myTaskFactory = new
TaskFactory(CancellationToken.None,
TaskCreationOptions.None,
TaskContinuationOptions.None,
@vendettamit
vendettamit / DynamicOrderByHelper.cs
Created January 20, 2016 19:28
Helper class to pass dynamic orderby parameter in LINQ.
///<summary>
/// Usage -
/// if (QueryHelper.PropertyExists<Club>(orderBy))
/// {
/// query = query.OrderByProperty(orderBy);
/// - OR -
/// query = query.OrderByPropertyDescending(orderBy);
/// }
///</summary>
public static class QueryHelper
public class FeedDao
{
private readonly RetryPolicy retryPolicy;
public FeedDao()
{
// setup retry policy that will try 3 times, with fast retry for first time and then
// with incremental interval by 1.5 seconds.
this.retryPolicy =
new RetryPolicy<DownloadFeedTrasientErrorDetectionStrategy>(
/// <summary>
/// Provides the transient error detection logic that can recognize transient faults when dealing with reading online feed.
/// </summary>
internal class DownloadFeedTrasientErrorDetectionStrategy : ITransientErrorDetectionStrategy
{
/// <summary>
/// Determines whether the specified exception represents a transient failure that can be compensated by a retry.
/// </summary>
/// <param name="ex">The exception object to be verified.</param>
/// <returns>True if the specified exception is considered as transient, otherwise false.</returns>
SomeUtility.FindElement("ele_PreviewCloseButton");
@vendettamit
vendettamit / SampleT4Xml.xml
Created January 7, 2016 00:28
Code snippet for blogpost
<?xml version="1.0" encoding="utf-8" ?>
<root>
<uielements>
<!--Validations and common actions-->
<CommonActions>
<element Name="ele_PreviewCloseButton" PrimaryLocator="×" SecondaryLocator="" Type="Button"/>
</CommonActions>
<ErrorPage>
<element Name="ele_ErrorPageMessage" PrimaryLocator="An error occurred while processing your request." SecondaryLocator="" Type="Div"/>
@vendettamit
vendettamit / Element.tt
Last active January 7, 2016 01:23
T4 Template to generate classes from XML file.
<#@ template debug="true" hostSpecific="true" #>
<#@ output extension=".cs" #>
<#@ Assembly Name="System.Core.dll" #>
<#@ Assembly Name="System.Xml.dll" #>
<#@ Assembly Name="System.Xml.Linq.dll" #>
<#@ Assembly Name="System.Windows.Forms.dll" #>
<#@ import namespace="System" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Diagnostics" #>
<#@ import namespace="System.Linq" #>
@vendettamit
vendettamit / FK_Reference_Finder.sql
Created December 29, 2015 22:07
Sql server script to get the FK relations for a particular table
declare @table as sysname
Set @table = 'Tranx_BirthChildCongenitalAnomaly'
SELECT
K_Table = FK.TABLE_NAME,
FK_Column = CU.COLUMN_NAME,
PK_Table = PK.TABLE_NAME,
PK_Column = PT.COLUMN_NAME,
Constraint_Name = C.CONSTRAINT_NAME
FROM
@vendettamit
vendettamit / gist:c883b72a150d435d6bed
Created December 28, 2015 19:21 — forked from SzymonPobiega/gist:5220595
DDD/CQRS/ES/Architecture videos

If you have two days to learn the very basics of modelling, Domain-Driven Design, CQRS and Event Sourcing, here's what you should do:

In the evenings read the [Domain-Driven Design Quickly Minibook]{http://www.infoq.com/minibooks/domain-driven-design-quickly}. During the day watch following great videos (in this order):

  1. Eric Evans' [What I've learned about DDD since the book]{http://www.infoq.com/presentations/ddd-eric-evans}
  2. Eric Evans' [Strategic Design - Responsibility Traps]{http://www.infoq.com/presentations/design-strategic-eric-evans}
  3. Udi Dahan's [Avoid a Failed SOA: Business & Autonomous Components to the Rescue]{http://www.infoq.com/presentations/SOA-Business-Autonomous-Components}
  4. Udi Dahan's [Command-Query Responsibility Segregation]{http://www.infoq.com/presentations/Command-Query-Responsibility-Segregation}
  5. Greg Young's [Unshackle Your Domain]{http://www.infoq.com/presentations/greg-young-unshackle-qcon08}
  6. Eric Evans' [Acknowledging CAP at the Root -- in the Domain Model]{ht