CreateObjectDefinition() public method

Factory style method for getting concrete IConfigurableObjectDefinition instances.
If no parent is specified, a RootWebObjectDefinition is created, otherwise a ChildWebObjectDefinition.
public CreateObjectDefinition ( string typeName, string parent, AppDomain domain ) : AbstractObjectDefinition
typeName string The of the defined object.
parent string The name of the parent object definition (if any).
domain System.AppDomain The against which any class names /// will be resolved into instances.
return AbstractObjectDefinition
Example #1
0
 public static void ThrowsArgumentExceptionOnNonExistingPathImpl()
 {
     using (TestWebContext ctx = new TestWebContext("/Test", "testform.aspx"))
     {
         WebObjectDefinitionFactory factory = new WebObjectDefinitionFactory();
         IWebObjectDefinition       definition
             = (IWebObjectDefinition)factory.CreateObjectDefinition("/Test/DoesNotExist.aspx", "parentdefinition", AppDomain.CurrentDomain);
     }
 }
 public static void ThrowsArgumentExceptionOnNonExistingPathImpl()
 {
     using (TestWebContext ctx = new TestWebContext("/Test", "testform.aspx"))
     {
         WebObjectDefinitionFactory factory = new WebObjectDefinitionFactory();
         IWebObjectDefinition definition
             = (IWebObjectDefinition)factory.CreateObjectDefinition("/Test/DoesNotExist.aspx", "parentdefinition", AppDomain.CurrentDomain);
     }
 }
Example #3
0
 public static void ResolvesToPageRootDefinitionIfEndsWithASPXImpl()
 {
     using (TestWebContext ctx = new TestWebContext("/Test", "testform.aspx"))
     {
         WebObjectDefinitionFactory factory = new WebObjectDefinitionFactory();
         IWebObjectDefinition       definition
             = (IWebObjectDefinition)factory.CreateObjectDefinition("/Test/testform.aspx", null, AppDomain.CurrentDomain);
         Assert.IsNotNull(definition, "CreateObjectDefinition with no parent is returning null (it must never do so).");
         Assert.IsTrue(definition.IsPage, ".aspx extension must result in a page instance");
         Assert.AreEqual(typeof(RootWebObjectDefinition), definition.GetType());
     }
 }
 public static void ResolvesToPageRootDefinitionIfEndsWithASPXImpl()
 {
     using (TestWebContext ctx = new TestWebContext("/Test", "testform.aspx"))
     {
         WebObjectDefinitionFactory factory = new WebObjectDefinitionFactory();
         IWebObjectDefinition definition
             = (IWebObjectDefinition)factory.CreateObjectDefinition("/Test/testform.aspx", null, AppDomain.CurrentDomain);
         Assert.IsNotNull(definition, "CreateObjectDefinition with no parent is returning null (it must never do so).");
         Assert.IsTrue(definition.IsPage, ".aspx extension must result in a page instance");
         Assert.AreEqual(typeof(RootWebObjectDefinition), definition.GetType());
     }
 }
 public void DoesNotResolveTypeNameToFullTypeInstanceIfAppDomainIsNull()
 {
     WebObjectDefinitionFactory factory = new WebObjectDefinitionFactory();
     IConfigurableObjectDefinition definition
         = factory.CreateObjectDefinition(
             typeof(TestObject).FullName, null, null);
     Assert.IsNotNull(definition, "CreateObjectDefinition with no parent is returning null (it must never do so).");
     Assert.AreEqual(typeof(TestObject).FullName, definition.ObjectTypeName);
     Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Count,
                     "Must not have any property values as none were passed in.");
     Assert.AreEqual(0, definition.ConstructorArgumentValues.ArgumentCount,
                     "Must not have any ctor args as none were passed in.");
 }
 public void CreateChildDefinition()
 {
     WebObjectDefinitionFactory factory = new WebObjectDefinitionFactory();
     IConfigurableObjectDefinition definition
         = factory.CreateObjectDefinition(
             typeof(TestObject).FullName, "Aimee Mann", AppDomain.CurrentDomain);
     Assert.IsNotNull(definition, "CreateObjectDefinition with no parent is returning null (it must never do so).");
     Assert.AreEqual(typeof(TestObject), definition.ObjectType);
     Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Count,
                     "Must not have any property values as none were passed in.");
     Assert.AreEqual(0, definition.ConstructorArgumentValues.ArgumentCount,
                     "Must not have any ctor args as none were passed in.");
 }
Example #7
0
        public void DoesNotResolveTypeNameToFullTypeInstanceIfAppDomainIsNull()
        {
            WebObjectDefinitionFactory    factory = new WebObjectDefinitionFactory();
            IConfigurableObjectDefinition definition
                = factory.CreateObjectDefinition(
                      typeof(TestObject).FullName, null, null);

            Assert.IsNotNull(definition, "CreateObjectDefinition with no parent is returning null (it must never do so).");
            Assert.AreEqual(typeof(TestObject).FullName, definition.ObjectTypeName);
            Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Length,
                            "Must not have any property values as none were passed in.");
            Assert.AreEqual(0, definition.ConstructorArgumentValues.ArgumentCount,
                            "Must not have any ctor args as none were passed in.");
        }
Example #8
0
        public void CreateChildDefinition()
        {
            WebObjectDefinitionFactory    factory = new WebObjectDefinitionFactory();
            IConfigurableObjectDefinition definition
                = factory.CreateObjectDefinition(
                      typeof(TestObject).FullName, "Aimee Mann", AppDomain.CurrentDomain);

            Assert.IsNotNull(definition, "CreateObjectDefinition with no parent is returning null (it must never do so).");
            Assert.AreEqual(typeof(TestObject), definition.ObjectType);
            Assert.AreEqual(0, definition.PropertyValues.PropertyValues.Length,
                            "Must not have any property values as none were passed in.");
            Assert.AreEqual(0, definition.ConstructorArgumentValues.ArgumentCount,
                            "Must not have any ctor args as none were passed in.");
        }