public AllowRole AddRole(string roleName) { if (AllowedRoles().Contains(roleName)) { return(null); } var allow = new AllowRole(roleName); _policies.AddValue(allow); return(allow); }
public void add_value() { var doer = new ASomethingDoer(); var dependency = new ListDependency(typeof(ISomethingDoer[])); dependency.AddValue(doer); dependency.Items.Count.ShouldEqual(1); dependency.Items[0].Value.ShouldBeTheSameAs(doer); }
public void Should_satisfy_dependency() { var def = new ObjectDef(typeof(NeedListOfDoers)); var doer1 = new ASomethingDoer(); var doers = new ListDependency(typeof(IEnumerable <ISomethingDoer>)); doers.AddValue(doer1); doers.AddType(typeof(BSomethingDoer)); def.Dependency(doers); def.Dependencies.ShouldHaveCount(1); }
public void build_an_object_with_a_list_dependency() { var def = new ObjectDef(typeof(ClassWithSomethings)); var listDependency = new ListDependency(typeof(IList <ISomething>)); listDependency.AddType(typeof(SomethingA)); listDependency.AddType(typeof(SomethingB)); listDependency.AddValue(new SomethingC()); def.Dependencies.Add(listDependency); var instance = new ObjectDefInstance(def); var container = new Container(); var @object = container.GetInstance <ClassWithSomethings>(instance); @object.Somethings[0].ShouldBeOfType <SomethingA>(); @object.Somethings[1].ShouldBeOfType <SomethingB>(); @object.Somethings[2].ShouldBeOfType <SomethingC>(); }
public BottleConfigurationDef AddRule(IBottleConfigurationRule rule) { _rules.AddValue(rule); return(this); }
public ValidationFailureExpression Add(IValidationFailurePolicy policy) { _policies.AddValue(policy); return(this); }