Skip to content

Instantly share code, notes, and snippets.

Working from home

Szymon Pobiega SzymonPobiega

Working from home
View GitHub Profile
View EntitiesSample.cs
//Customer is an aggregate root
public class Customer : AggregateRootMappedByConvention
//Customer contains orders, each of which is uniquely identified hence is an entity
private readonly List<Order> _orders = new List<Order>();
public void CreateOrder(int id)
//Does not create an entity, only publishes event.
//The entity has localy unique id. Its uniqueness is ensured here.
View gist:814922
public void NHibernate_allows_crud_operations()
private void Create()
View gist:953302
protected override ValidationResults OnValidate(PurchaseTransaction purchaseTransaction)
return purchaseTransaction
.Return(TheResult, OrFailureCodeInCaseOfFailure);
SzymonPobiega / gist:1027094
Created Jun 15, 2011
Small internal DSL in unit tests
View gist:1027094
public void It_uses_more_specific_rule_if_rule_and_information_is_present()
Given(new ProductType("air", null, ProductCategory.AirOnly),
new ProductType("air", "someSpecialWeirdProduct", ProductCategory.LandOnly))
.ItMaps(new ProductReference("air", "someSpecialWeirdProduct"))
View gist:1148931
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<title>simon_v subscriptions in Google Reader</title>
<outline title="Publiczne" text="Publiczne">
<outline text=".neting in the free world"
title=".neting in the free world" type="rss"
xmlUrl="" htmlUrl=""/>
SzymonPobiega / gist:1617321
Created Jan 15, 2012
Here's how you use ReferenceDataManager
View gist:1617321
ObjectId hierarchyId;
var builder = new ChangeSetBuilder(objectFacade, null);
var hierarchy = builder.CreateHierarchy();
hierarchyId = hierarchy.Id;
var parentUnit = builder.CreateUnit("Parent", new Address("Lubicz", "23", "Krakow", "PL"));
var childUnit = builder.CreateUnit("Child", null);
builder.SetHierarchyRoot(hierarchy, parentUnit);
builder.SetParent(hierarchy, childUnit, parentUnit);
View gist:2358879
public static T NullArgumentLogAndThrow<T>(this ILog log, T arg)
if (arg.IsNotNull()) return arg;
// get calling method
var ex = new ArgumentNullException(typeof(T).Name);
log.Fatal(new StackTrace().GetFrame(1).GetMethod().Name, ex);
log.Fatal(new StackTrace().ToString());
throw ex;
SzymonPobiega / gist:2657868
Created May 11, 2012
Branch switching script
View gist:2657868
# The script switches IIS web applications to point to some other directory. It is very usefull when frequently changing branches.
# The script assumes SVN-ish branch structure like this:
# Root
# |
# |--Branches
# | |
# | |--Branch 1
# | |
# | \--Branch 2
View gist:2889459
<?xml version="1.0" encoding="utf-8" ?>
<level value="INFO"/>
<appender-ref ref="File"/>
<appender-ref ref="Console"/>
<logger name="NHibernate">
<level value="WARN" />
SzymonPobiega / gist:4538653
Created Jan 15, 2013
Why I _love_ event sourcing
View gist:4538653
public void After_successfully_deploying_a_component_it_triggers_its_start()
DeploymentPlanned("A", "1"),
DeploymentPlanned("B", "2"),