Created
September 9, 2009 16:28
-
-
Save KevM/183861 to your computer and use it in GitHub Desktop.
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
var concreteIRuleOfMessageType = container.Model.InstancesOf(typeof(IRule<MESSAGE>)).FirstOrDefault().ConcreteType; | |
var concreteIRuleSetOfMessageType = container.Model.InstancesOf(typeof(IRuleSet<MESSAGE>)).FirstOrDefault().ConcreteType; | |
var ruleInstances = new SmartInstance<IRule<MESSAGE>[]>().TheArrayOf<IRule<MESSAGE>>("rules") | |
.Contains(rule => | |
{ | |
foreach (var ruleExpresion in ruleSetExpression.Rules) | |
{ | |
var localRuleExpression = ruleExpresion; | |
rule.Instance( | |
new ConfiguredInstance(concreteIRuleOfMessageType) | |
.CtorDependency<IAction<MESSAGE>>("action").IsConcreteType(localRuleExpression.ActionType) | |
.CtorDependency<ICondition<MESSAGE>>("condition").IsConcreteType(localRuleExpression.ConditionType) | |
.CtorDependency<bool>("isRuleSetComplete").Is(localRuleExpression.ShouldRuleSetBeCompleteAfterThisRuleInvokes) | |
); | |
} | |
}); | |
container.Configure(config => | |
{ | |
config.ForRequestedType<IRuleSet<MESSAGE>>().TheDefault.Is.OfConcreteType(concreteIRuleSetOfMessageType) | |
.WithName(ruleSetExpression.RuleSetName) | |
.WithCtorArg("ruleSetName").EqualTo(ruleSetExpression.RuleSetName) | |
.CtorDependency<IRule<MESSAGE>[]>("rules").Is(ruleInstances); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment