Skip to content

Instantly share code, notes, and snippets.

View beyond-code-github's full-sized avatar

Pete Smith beyond-code-github

View GitHub Profile
@beyond-code-github
beyond-code-github / changetrackedarray.js
Last active August 29, 2015 13:55
Skeleton change tracked array extender for knockout.kj
ko.extenders.trackArrayChange = function (target, track) {
if (track) {
target.isDirty = ko.observable(false);
target.added = ko.observableArray([]);
target.removed = ko.observableArray([]);
var addItem = function (item) {
//...
};
@beyond-code-github
beyond-code-github / arraysubscriptions.js
Last active August 29, 2015 13:55
Suscribing to array changes using the new arraychange subscriptions in knockout 3.0
//....
//....
target.getChanges = function () {
var result = {
added: target.added(),
removed: target.removed()
};
return result;
@beyond-code-github
beyond-code-github / addremoveexample.js
Last active August 29, 2015 13:55
Tracking array adds and removes is not quite as simple as it first appears...
// Initialise array with some data and track changes
var trackedArray = ko.observableArray([1,2,3]).extend({trackArrayChanges: true});
trackedArray.getChanges();
// -> { } No changes yet
trackedArray.push(4);
trackedArray.pop();
trackedArray.getChanges();
@beyond-code-github
beyond-code-github / applychangetracking.cs
Created January 31, 2014 19:54
Original code for applying change tracking to observables from Part 1
....
....
var applyChangeTrackingToObservable = function (observable) {
// Only apply to basic writeable observables
if (observable && !observable.nodeType && !observable.refresh && ko.isObservable(observable)) {
if (!observable.isDirty) observable.extend({ trackChange: true });
}
};
@beyond-code-github
beyond-code-github / applychangetrackingmodified.js
Last active August 29, 2015 13:55
Modified version of apply change tracking to observable that properly track arrays
//....
//....
var applyChangeTrackingToObservable = function (observable) {
// Only apply to basic writeable observables
if (observable && !observable.nodeType && !observable.refresh && ko.isObservable(observable)) {
if (observable.isObservableArray) {
observable.extend({ trackArrayChange: true });
}
else {
@beyond-code-github
beyond-code-github / example.js
Last active August 29, 2015 13:55
Example usage of change tracking in a complex view model, including a primitive array
var viewModel = {
Name: ko.observable("Pete"),
Age: ko.observable(29),
Skills: ko.observableArray([
"TDD", "Knockout", "WebForms"
}),
Occupation: ko.observable("Developer")
};
applyChangeTracking(viewModel);
@beyond-code-github
beyond-code-github / changetracking.js
Last active August 29, 2015 13:55
Change tracking implementation including support for primitive arrays
var getObjProperties = function (obj) {
var objProperties = [];
var val = ko.utils.unwrapObservable(obj);
if (val !== null && typeof val === 'object') {
for (var i in val) {
if (val.hasOwnProperty(i)) objProperties.push({ "name": i, "value": val[i] });
}
}
@beyond-code-github
beyond-code-github / test.markdown
Created March 18, 2014 14:47
Hello world requests/second

#Plain text, 10,000 req, 8 concurrent

  • Nancy - Nowin - 2642,2938,3435,2942,3216,4006 = 3204
  • Superscribe - Nowin - 4111,3767,3716,3350,3306,3742 = 3665
  • Nancy - System.Web - 3766,4042,3680,3944,4129,4065 = 3937
  • Superscribe - System.Web - 5724,5790,5506,4355,4293,5783 = 5241
  • Nancy - Helios - 5681,5817,5896,4407,4253,5854 = 5318
  • Superscribe - Helios - 6161,6788,6583,5685,4278,6872 = 6061

Domain Driven Dilemmas

I'm fairly new to domain driven design and I've been scratching my head for a while over this issue.

Here are my domain rules

  • A Record entity has a document of key value pairs
  • We can update the document for a record by providing the updated key value pairs
  • When we update a document we must calculate some values according to some parsed expressions.
using Autofac;
using Xunit;
namespace LifetimeScope
{
public class Stackoverflow24762539
{
[Fact]
public void Repro()