コード例 #1
0
        public void set_and_get_a_nullable_integer()
        {
            ConstructorInstance instance = ConstructorInstance.For <ClassWithNullableInt>();

            instance.SetValue("age", "45");

            instance.Get("age", typeof(int?), new StubBuildSession()).ShouldEqual(45);

            instance.SetValue("age", null);
            instance.Get("age", typeof(int?), new StubBuildSession()).ShouldBeNull();
        }
コード例 #2
0
        public void get_and_set_for_a_nullable_date_time()
        {
            ConstructorInstance instance = ConstructorInstance.For <ClassWithNullableDate>();

            instance.SetValue("date", "12/23/2009");

            instance.Get("date", typeof(DateTime?), new StubBuildSession()).ShouldEqual(new DateTime(2009, 12, 23));

            instance.SetValue("date", null);

            instance.Get("date", typeof(DateTime?), new StubBuildSession()).ShouldBeNull();
        }
コード例 #3
0
        public void get_and_set_for_a_guid()
        {
            ConstructorInstance instance = ConstructorInstance.For <ClassWithGuid>();
            Guid guid = Guid.NewGuid();

            instance.SetValue("guid", guid.ToString());

            instance.Get("guid", typeof(Guid), new StubBuildSession()).ShouldEqual(guid);
        }
コード例 #4
0
        public void set_and_get_a_string()
        {
            ConstructorInstance instance = ConstructorInstance.For <ColorWidget>();

            instance.SetValue("color", "Red");


            instance.Get("color", typeof(string), new StubBuildSession()).ShouldEqual("Red");
        }
コード例 #5
0
        public void get_and_set_a_non_primitive_type_that_is_not_enumerable()
        {
            ConstructorInstance instance = ConstructorInstance.For <ClassWithNonPrimitive>();

            var widget = new AWidget();

            instance.SetValue("widget", widget);

            instance.Get("widget", typeof(IWidget), new StubBuildSession()).ShouldEqual(widget);
        }
コード例 #6
0
        public void Process(Type type, Registry registry)
        {
            //if (!typeof(IPersistenceDetails).IsAssignableFrom(type))
            //    return;
            if (!type.Name.Equals("PersistenceDetails"))
                return;

            IConfiguredInstance ctor = new ConstructorInstance(type);
            ctor.SetValue("location", this.connectionString);
            registry.For(type.BaseType).HttpContextScoped().Add(ctor);
        }
コード例 #7
0
        public void Process(Type type, Registry registry)
        {
            //if (!typeof(IPersistenceDetails).IsAssignableFrom(type))
            //    return;
            if (!type.Name.Equals("PersistenceDetails"))
            {
                return;
            }

            IConfiguredInstance ctor = new ConstructorInstance(type);

            ctor.SetValue("location", this.connectionString);
            registry.For(type.BaseType).HttpContextScoped().Add(ctor);
        }
コード例 #8
0
        public void Process(Type type, Registry registry)
        {
            if (!type.Name.StartsWith("Sql"))
            {
                return;
            }
            if (type == typeof(SqlCurrency))
            {
                return;
            }

            IConfiguredInstance ctor = new ConstructorInstance(type);
            ctor.SetValue("connString", this.connectionString);
            registry.For(type.BaseType).HttpContextScoped().Add(ctor);
        }
コード例 #9
0
        public void Process(Type type, Registry registry)
        {
            if (!type.Name.StartsWith("Sql"))
            {
                return;
            }
            if (type == typeof(SqlCurrency))
            {
                return;
            }

            IConfiguredInstance ctor = new ConstructorInstance(type);

            ctor.SetValue("connString", this.connectionString);
            registry.For(type.BaseType).HttpContextScoped().Add(ctor);
        }