public void ObjectType()
        {
            ObjectDefinitionBuilder odb = ObjectDefinitionBuilder.RootObjectDefinition(odf, typeof(TestObject));
            RootObjectDefinition    rod = odb.ObjectDefinition as RootObjectDefinition;

            Assert.IsNotNull(rod);
            Assert.IsTrue(rod.HasObjectType);
            Assert.AreEqual(typeof(TestObject), rod.ObjectType);
        }
        public void Simple()
        {
            GenericApplicationContext ctx = new GenericApplicationContext();
            IObjectDefinitionFactory  objectDefinitionFactory = new DefaultObjectDefinitionFactory();

            ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.RootObjectDefinition(objectDefinitionFactory,
                                                                                           typeof(TestObject));

            builder.AddPropertyValue("Age", 22)
            .AddPropertyValue("Name", "Joe")
            .AddPropertyReference("Spouse", "Spouse")
            .SetSingleton(false);

            ctx.RegisterObjectDefinition("TestObject", builder.ObjectDefinition);

            builder = ObjectDefinitionBuilder.RootObjectDefinition(objectDefinitionFactory, typeof(TestObject));

            IList friends = new ArrayList();

            friends.Add(new TestObject("Dan", 34));
            friends.Add(new TestObject("Mary", 33));
            builder.AddPropertyValue("Friends", friends)
            .AddConstructorArg("Susan")
            .AddConstructorArg(23)
            .SetSingleton(false);

            ctx.RegisterObjectDefinition("Spouse", builder.ObjectDefinition);



            TestObject to = ctx.GetObject("TestObject") as TestObject;

            Assert.IsNotNull(to);

            Assert.AreEqual("Joe", to.Name);
            Assert.AreEqual(22, to.Age);
            Assert.AreEqual(2, to.Spouse.Friends.Count);
            Assert.AreEqual(23, to.Spouse.Age);

            /*
             * AbstractApplicationContext ctx = ContextRegistry.GetContext() as AbstractApplicationContext;
             *
             *
             *
             * //XmlObjectFactory objectFactory = ctx.ObjectFactory as XmlObjectFactory;
             *
             * IObjectFactory objectFactory = ctx.ObjectFactory;
             *
             * //DefaultListableObjectFactory
             * if (objectFactory != null)
             * {
             *  Console.WriteLine("hi");
             * }
             * //objectFactory.RegisterObjectDefinition("TestObject", builder.ObjectDefinition);
             */
        }
        public void ObjectTypeWithFactoryMethod()
        {
            ObjectDefinitionBuilder odb =
                ObjectDefinitionBuilder.RootObjectDefinition(odf, typeof(TestObject), "Create");
            RootObjectDefinition rod = odb.ObjectDefinition as RootObjectDefinition;

            Assert.IsNotNull(rod);
            Assert.IsTrue(rod.HasObjectType);
            Assert.AreEqual(typeof(TestObject), rod.ObjectType);
            Assert.AreEqual("Create", rod.FactoryMethodName);
        }
        public void ObjectTypeWithSimpleProperty()
        {
            string[] dependsOn          = new string[] { "A", "B", "C" };
            ObjectDefinitionBuilder odb = ObjectDefinitionBuilder.RootObjectDefinition(odf, typeof(TestObject));

            odb.SetSingleton(false).AddPropertyReference("Age", "15");
            foreach (string dep in dependsOn)
            {
                odb.AddDependsOn(dep);
            }

            RootObjectDefinition rod = odb.ObjectDefinition as RootObjectDefinition;

            Assert.IsNotNull(rod);
            Assert.IsFalse(rod.IsSingleton);
            Assert.AreEqual(typeof(TestObject), rod.ObjectType);
            Assert.AreEqual(dependsOn, rod.DependsOn, "DependsOn not as expected");
            Assert.IsTrue(rod.PropertyValues.Contains("Age"));
        }