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
bind(Warrior.class).to(Samurai.class); | |
bind(Weapon.class).to(Nunchucks.class); |
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 interface Warrior { | |
void fight(); | |
} | |
public class Ninja implements Warrior { | |
private Weapon weapon; | |
public Ninja(Weapon weapon) { | |
this.weapon = weapon; |
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
bind(Warrior.class).to(Ninja.class); |
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 interface Warrior { | |
void fight(); | |
} | |
public class Ninja implements Warrior { | |
@Override | |
public void fight() { | |
System.out.println("The ninja fights!"); | |
} |
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.Globalization; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using System.Reflection; | |
using Wes.Core.Domain.Internal.Contracts; | |
namespace Wes.Core.Infrastructure.Utilities.Sorting | |
{ |
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
exec sp_executesql N'SELECT | |
[Project2].[Id1] AS [Id], | |
[Project2].[Id] AS [Id1], | |
[Project2].[C1] AS [C1], | |
[Project2].[Id2] AS [Id2], | |
[Project2].[CultureName] AS [CultureName], | |
[Project2].[ProductId] AS [ProductId], | |
[Project2].[Name] AS [Name] | |
FROM ( SELECT | |
[Extent1].[Id] AS [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
public static class Extensions | |
{ | |
public static Expression<TDelegate> Expand<TDelegate> (this Expression<TDelegate> expr) | |
{ | |
return (Expression<TDelegate>)new ReplacingExpressionsExpander().Visit(expr); | |
} | |
public static Expression Expand (this Expression expr) | |
{ | |
return new ReplacingExpressionsExpander ().Visit (expr); |
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
class ReplacingExpressionsExpander: ExpressionExpander | |
{ | |
private static readonly IExpressionReplacer<MethodCallExpression>[] MethodCallReplacers | |
= new IExpressionReplacer<MethodCallExpression>[] {new ExpressionReplacerForExtensionsForITranslatableCurrent()}; | |
protected override Expression VisitMethodCall(MethodCallExpression methodCallExpression) | |
{ | |
foreach (var replacer in MethodCallReplacers.Where(replacer => replacer.ShouldReplace(methodCallExpression))) | |
{ | |
return Visit(replacer.GetReplacement(methodCallExpression)); |
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
/// <summary> | |
/// Dynamically replaces a MethodCallExpression for 'ExtensionsForITranslatable.Current()' to | |
/// a valid equivalent expression | |
/// </summary> | |
public class ExpressionReplacerForExtensionsForITranslatableCurrent: IExpressionReplacer<MethodCallExpression> | |
{ | |
private readonly MethodInfo _methodInfoForCurrent; | |
public ExpressionReplacerForExtensionsForITranslatableCurrent() | |
{ |
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 interface IExpressionReplacer<in TExpression> where TExpression: Expression | |
{ | |
bool ShouldReplace(TExpression expression); | |
Expression GetReplacement(TExpression expression); | |
} |