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 event Action<string> OperationFinishedNotification; | |
public string AwesomeBusinessOperation() | |
{ | |
var firstPart = TakesALongTimeToProcess("Tons"); | |
var secondPart = TakesALongTimeToProcess(firstPart + " of "); | |
var result = TakesALongTimeToProcess(secondPart + "money"); | |
var eventToFire = OperationFinishedNotification; | |
if(null!=eventToFire) |
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 class ComplexBusinessOperations | |
{ | |
private int moneyEarnedSoFar; | |
public int MoneyEarnedSoFar | |
{ | |
get { return moneyEarnedSoFar; } | |
} | |
public void EarnMoney(int investment) |
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 class Awaiter | |
{ | |
private readonly MyPrimitiveSynchronisationContext syncContext; | |
internal Awaiter(MyPrimitiveSynchronisationContext syncContext) | |
{ | |
this.syncContext = syncContext; | |
} | |
public void WaitFor(IAsyncResult toWaitOn) |
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
// Just works | |
List<String> listOfString = cast(list); | |
// Doesn't work | |
printAll(cast(list)); |
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 class CollectionUtils { | |
private CollectionUtils(){ | |
} | |
public static <T> List<T> list(){ | |
return new ArrayList<T>(); | |
} | |
public static <T> List<T> list(T...elements){ | |
return new ArrayList<T>(asList(elements)); |
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 class FocusSwitcher | |
{ | |
[DllImport("user32.dll")] | |
private static extern bool ShowWindowAsync(HandleRef hWnd, int nCmdShow); | |
[DllImport("user32.dll")] | |
private static extern bool SetForegroundWindow(IntPtr hWnd); | |
private const int SW_MAXIMIZE = 3; | |
public static void SwitchToCurrent() | |
{ |
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
<transparent-activation-step> | |
<regexp pattern="^com\.mycompany\.persistence\.data" /> <!-- Hier anpassen? --> | |
<!-- <regexp pattern="^enhancement\.model\." /> --> | |
</transparent-activation-step> |
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 NDependExperiments | |
{ | |
public class DataBaseOperation | |
{ | |
public void Store(object obj) {/** Do stuff **/} | |
} | |
class BusinessOperations | |
{ | |
private readonly DataBaseOperation dbConnection = new DataBaseOperation(); |
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 (var db = Db4oEmbedded.OpenFile("databaseWithArrayFields.db4o")) | |
{ | |
var metaData = db.Ext().KnownClasses(); | |
// process the data | |
foreach (var aClass in metaData) | |
{ | |
// analyse the class | |
var fields = aClass.GetDeclaredFields(); | |
foreach (var aField in fields) | |
{ |
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 final class CompositeComparator<T> implements Comparator<T>{ | |
private final List<Comparator<? super T>> comparators; | |
CompositeComparator(List<Comparator<? super T>> comparators) { | |
this.comparators = comparators; | |
} | |
public static <TCompare> Comparator<TCompare> compareWith(Comparator<? super TCompare>... comparators){ | |
return new CompositeComparator<TCompare>(Arrays.asList(comparators)); | |
} |