Skip to content

Instantly share code, notes, and snippets.

@jmarnold
Created March 29, 2011 17:26
Show Gist options
  • Save jmarnold/892813 to your computer and use it in GitHub Desktop.
Save jmarnold/892813 to your computer and use it in GitHub Desktop.
// TODO -- come back and clean this up. Just getting it up and running for a demo
BehaviorDetailsModel root = null;
var behaviors = new Cache<Type, BehaviorDetailsModel>(t =>
{
var model = new BehaviorDetailsModel {BehaviorType = t};
if(root == null)
{
root = model;
}
return model;
});
Type lastBehavior = null;
report
.Steps
.Each(s =>
{
var behaviorType = s.Behavior.BehaviorType;
if(behaviors.Has(behaviorType) && behaviorType != lastBehavior)
{
behaviors[behaviorType].AddAfter(s.Details);
}
else
{
behaviors[behaviorType].AddBefore(s.Details);
}
if(lastBehavior != null && behaviorType != lastBehavior)
{
behaviors[lastBehavior].Inner = behaviors[behaviorType];
}
lastBehavior = behaviorType;
});
return root;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment