예제 #1
0
        public AllowRole AddRole(string roleName)
        {
            if (AllowedRoles().Contains(roleName))
            {
                return(null);
            }

            var allow = new AllowRole(roleName);

            _policies.AddValue(allow);


            return(allow);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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>();
        }
예제 #5
0
 public BottleConfigurationDef AddRule(IBottleConfigurationRule rule)
 {
     _rules.AddValue(rule);
     return(this);
 }
 public ValidationFailureExpression Add(IValidationFailurePolicy policy)
 {
     _policies.AddValue(policy);
     return(this);
 }