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
static public class DapperExtensions | |
{ | |
public static MemberInfo GetMemberInfo(this Expression expression) | |
{ | |
LambdaExpression lambdaExpression = (LambdaExpression)expression; | |
MemberExpression memberExpression; | |
if (lambdaExpression.Body is UnaryExpression) | |
{ |
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; | |
using System.Messaging; | |
namespace TestTransactionalQueue | |
{ | |
class Program | |
{ | |
private static MessageQueue GetQueue(bool trans=true ,string path = @".\Private$\TestTran") | |
{ |
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; | |
using System.Collections.Generic; | |
using System.Collections.ObjectModel; | |
using System.Threading; | |
namespace WpfApplication1 | |
{ | |
public class AsyncObservableCollection<T> : ObservableCollection<T> | |
{ | |
private readonly SynchronizationContext _synchronizationContext = SynchronizationContext.Current; |
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
internal class AutomapperConfigurationProfile : Profile | |
{ | |
protected override void Configure() | |
{ | |
CreateMap<Source,Destination>().ForMember(dest=>dest.Field1,opts=> opts.MapFrom(src=>(int)src.Fieldxx)); | |
CreateMap<Abc,Xyz>().ReverseMap(); | |
... | |
Mapping here | |
} |
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 DynamicColorGenExtensions | |
{ | |
//Find foreground color for a dynamic background color | |
public static Color FindForgroundColor(this Color color) | |
{ | |
if (color.R <= 5 && color.G <= 5 && color.B <= 5) | |
{ | |
return Color.WhiteSmoke; | |
} |
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
@echo off | |
if _%1_==__ goto USAGE | |
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem -subj "/CN=My Cert Name" | |
openssl pkcs12 -export -out mycert.pfx -inkey mycert.pem -in mycert.pem -passout pass:%1 | |
openssl x509 -inform pem -in mycert.pem -outform der -out mycert.cer | |
openssl pkcs12 -in mycert.pfx -nodes -passin pass:%1 | openssl x509 -noout -fingerprint | |
openssl x509 -in mycert.pem -noout -fingerprint |
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 void CopyMatchingProperties<TResult, TInput>(this TInput input, TResult result) | |
where TResult : class | |
where TInput : class | |
{ | |
var properties = typeof(TResult).GetProperties(BindingFlags.Instance | BindingFlags.Public).ToList(); | |
var propertiesInput = typeof(TInput).GetProperties(BindingFlags.Instance | BindingFlags.Public).ToList(); | |
properties.ForEach(p => | |
{ |
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
declare @dbName varchar(100) | |
set @dbName ='MyDatabase' | |
IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = @dbName) | |
BEGIN | |
declare @liveConnections as Table(Id int identity(1,1), name varchar(max), spid int ) |
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 AssemblyExtensions{ | |
public static List<TCustomAttribute> GetAllCustomAttributeInstances<TCustomAttribute>(this Assembly assembly) | |
where TCustomAttribute : Attribute | |
{ | |
var supportedMigrationVersions = assembly | |
.GetTypes() | |
.Where(t => Attribute.IsDefined(t, typeof(TCustomAttribute))) | |
.Select(t => (t.GetCustomAttribute(typeof(TCustomAttribute)) as TCustomAttribute)) | |
.ToList(); |
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
<Window x:Class="WpfApplication6.Window1" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
Title="Window1" Height="300" Width="300"> | |
<Grid> | |
<StackPanel> | |
<Path Fill="Black" Data="M 0 10 L 20 10 L 10 0 Z"/> | |
<Path Fill="Black" Data="M 0 0 L 10 10 L 20 0 Z"/> |
OlderNewer