当前位置: 首页>>代码示例>>C#>>正文


C# Xml.ReadOnlyXmlTestResource类代码示例

本文整理汇总了C#中Spring.Objects.Factory.Xml.ReadOnlyXmlTestResource的典型用法代码示例。如果您正苦于以下问题:C# ReadOnlyXmlTestResource类的具体用法?C# ReadOnlyXmlTestResource怎么用?C# ReadOnlyXmlTestResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ReadOnlyXmlTestResource类属于Spring.Objects.Factory.Xml命名空间,在下文中一共展示了ReadOnlyXmlTestResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RefSubelementsBuildCollection

        public void RefSubelementsBuildCollection()
        {
            IResource resource = new ReadOnlyXmlTestResource("collections.xml", GetType());
            XmlObjectFactory xof = new XmlObjectFactory(resource);
            //Assert.IsTrue ("5 objects in reftypes, not " + xof.GetObjectDefinitionCount(), xof.GetObjectDefinitionCount() == 5);
            TestObject jen = (TestObject) xof.GetObject("jenny");
            TestObject dave = (TestObject) xof.GetObject("david");
            TestObject rod = (TestObject) xof.GetObject("rod");

            // Must be a list to support ordering
            // Our object doesn't modify the collection:
            // of course it could be a different copy in a real object
            IList friends = (IList) rod.Friends;
            Assert.IsTrue(friends.Count == 2);
            Assert.IsTrue(friends[0] == jen, "First friend must be jen, not " + friends[0]);
            Assert.IsTrue(friends[1] == dave);
            // Should be ordered
        }
开发者ID:fuadm,项目名称:spring-net,代码行数:18,代码来源:XmlObjectCollectionTests.cs

示例2: CanApplyConstructorArgsToAbstractType

        public void CanApplyConstructorArgsToAbstractType()
        {
            IResource resource = new ReadOnlyXmlTestResource("ctor-args.xml", GetType());
            XmlObjectFactory xof = new XmlObjectFactory(resource);
            TestObject rod = (TestObject)xof.GetObject("rod");
            Assert.AreEqual(1, rod.Age);

            RootObjectDefinition def = (RootObjectDefinition) xof.GetObjectDefinition("rod");
            ConstructorResolver resolver = new ConstructorResolver(xof, xof, new SimpleInstantiationStrategy(), 
                                                    new ObjectDefinitionValueResolver(xof));
            
            ConstructorInstantiationInfo ci = resolver.GetConstructorInstantiationInfo("rod", def, null, null);

            AbstractObjectDefinition objDef = (AbstractObjectDefinition)xof.GetObjectDefinition("foo");
            objDef.IsAbstract = false;

            TestObject foo = (TestObject) xof.GetObject("foo");


            Assert.AreEqual(2, foo.Age);
        }
开发者ID:fgq841103,项目名称:spring-net,代码行数:21,代码来源:XmlObjectCollectionTests.cs

示例3: LocaleTest

        public void LocaleTest()
        {
            CultureInfo oldCulture = Thread.CurrentThread.CurrentCulture;
            try
            {
                Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");

                IResource resource = new ReadOnlyXmlTestResource("locale.xml", GetType());
                XmlObjectFactory xof = new XmlObjectFactory(resource);
                TestObject to = xof.GetObject("jenny") as TestObject;
                Assert.IsNotNull(to);
                DateTime d = new DateTime(2007, 10, 30);
                Assert.AreEqual(d, to.Date);
                Assert.AreEqual(30, to.Size.Height);
                Assert.AreEqual(30, to.Size.Width);
            }
            finally
            {
                Thread.CurrentThread.CurrentCulture = oldCulture;
            }
        }
开发者ID:fgq841103,项目名称:spring-net,代码行数:21,代码来源:LocaleTests.cs

示例4: MultiThreadedLazyInit

 public void MultiThreadedLazyInit()
 {
     IResource resource = new ReadOnlyXmlTestResource("lazy-init-multithreaded.xml", GetType());
     XmlObjectFactory xof = new XmlObjectFactory(resource);
     
     LazyWorker lw1 = new LazyWorker(xof);
     LazyWorker lw2 = new LazyWorker(xof);
     Thread thread1 = new Thread(new ThreadStart(lw1.DoWork));
     Thread thread2 = new Thread(new ThreadStart(lw2.DoWork));
         
     thread1.Start();
     Thread.Sleep(1000);
     thread2.Start();
     thread1.Join();
     thread2.Join();            
     Assert.AreEqual(typeof(LazyTestObject), lw1.ObjectFromContext.GetType());
     Assert.AreEqual(typeof(LazyTestObject), lw2.ObjectFromContext.GetType());
     Assert.AreEqual(1, LazyTestObject.Count);
 }
开发者ID:fgq841103,项目名称:spring-net,代码行数:19,代码来源:XmlObjectFactoryTests.cs

示例5: InitializingObjectAndInitMethod

 public void InitializingObjectAndInitMethod()
 {
     InitAndIB.constructed = false;
     IResource resource = new ReadOnlyXmlTestResource("initializers.xml", GetType());
     XmlObjectFactory xof = new XmlObjectFactory(resource);
     Assert.IsFalse(InitAndIB.constructed);
     xof.PreInstantiateSingletons();
     Assert.IsFalse(InitAndIB.constructed);
     InitAndIB iib = (InitAndIB) xof.GetObject("init-and-ib");
     Assert.IsTrue(InitAndIB.constructed);
     Assert.IsTrue(iib.afterPropertiesSetInvoked && iib.initMethodInvoked);
     Assert.IsTrue(!iib.destroyed && !iib.customDestroyed);
     xof.Dispose();
     Assert.IsTrue(iib.destroyed && iib.customDestroyed);
     xof.Dispose();
     Assert.IsTrue(iib.destroyed && iib.customDestroyed);
 }
开发者ID:fgq841103,项目名称:spring-net,代码行数:17,代码来源:XmlObjectFactoryTests.cs

示例6: InitMethodThrowsException

 public void InitMethodThrowsException()
 {
     IResource resource = new ReadOnlyXmlTestResource("initializers.xml", GetType());
     XmlObjectFactory xof = new XmlObjectFactory(resource);
     try
     {
         xof.GetObject("init-method2");
         Assert.Fail();
     }
     catch (ObjectCreationException ex)
     {
         Assert.IsTrue(ex.InnerException is FormatException);
     }
 }
开发者ID:fgq841103,项目名称:spring-net,代码行数:14,代码来源:XmlObjectFactoryTests.cs

示例7: PropertyWithIdRefObjectAttrSubelement

 public void PropertyWithIdRefObjectAttrSubelement()
 {
     IResource resource = new ReadOnlyXmlTestResource("collections.xml", GetType());
     XmlObjectFactory xof = new XmlObjectFactory(resource);
     TestObject verbose = (TestObject) xof.GetObject("verbose3");
     Assert.IsTrue(verbose.Name.Equals("verbose"));
 }
开发者ID:fgq841103,项目名称:spring-net,代码行数:7,代码来源:XmlObjectFactoryTests.cs

示例8: FactoryReferenceCircle

 public void FactoryReferenceCircle()
 {
     IResource resource = new ReadOnlyXmlTestResource("factoryCircle.xml", GetType());
     XmlObjectFactory xof = new XmlObjectFactory(resource);
     TestObject tb = (TestObject) xof.GetObject("singletonFactory");
     DummyFactory db = (DummyFactory) xof.GetObject("&singletonFactory");
     Assert.IsTrue(tb == db.OtherTestObject);
 }
开发者ID:fgq841103,项目名称:spring-net,代码行数:8,代码来源:XmlObjectFactoryTests.cs

示例9: PropertyInvokingFactoryObjectIsWiredCorrectly

 public void PropertyInvokingFactoryObjectIsWiredCorrectly()
 {
     IResource resource = new ReadOnlyXmlTestResource("invoke-factory.xml", GetType());
     XmlObjectFactory xof = new XmlObjectFactory(resource);
     TestObject actual = xof["culturalObject"] as TestObject;
     object expected = CultureInfo.InstalledUICulture;
     Assert.AreEqual(expected, actual.MyCulture);
 }
开发者ID:fgq841103,项目名称:spring-net,代码行数:8,代码来源:XmlObjectFactoryTests.cs

示例10: ViaXML

 public void ViaXML()
 {
     IResource resource = new ReadOnlyXmlTestResource("PropertyResourceConfigurerTests.xml", GetType());
     XmlObjectFactory xbf = new XmlObjectFactory(resource);
     PropertyOverrideConfigurer poc = (PropertyOverrideConfigurer) xbf.GetObject("OverrideConfigurer");
     Assert.IsNotNull(poc);
     poc.PostProcessObjectFactory(xbf);
     TestObject to = (TestObject) xbf.GetObject("Test2");
     Assert.AreEqual("Overriden Name", to.Name);
 }
开发者ID:adamlepkowski,项目名称:spring-net,代码行数:10,代码来源:PropertyOverrideConfigurerTests.cs

示例11: ViaXMLAndConfigSection

        public void ViaXMLAndConfigSection()
        {
            IResource resource = new ReadOnlyXmlTestResource("PropertyResourceConfigurerTests.xml", GetType());
            XmlObjectFactory xbf = new XmlObjectFactory(resource);
            PropertyPlaceholderConfigurer ppc = (PropertyPlaceholderConfigurer) xbf.GetObject("ConfigSectionPlaceholderConfigurer");
            Assert.IsNotNull(ppc);
            ppc.PostProcessObjectFactory(xbf);

            Assert.AreEqual("name from section", ((TestObject)xbf.GetObject("Test3")).Name);
            Assert.AreEqual("name from sectiongroup/section", ((TestObject)xbf.GetObject("Test4")).Name);
        }
开发者ID:tobi-tobsen,项目名称:spring-net,代码行数:11,代码来源:PropertyPlaceholderConfigurerTests.cs

示例12: ViaXML

 public void ViaXML()
 {
     IResource resource = new ReadOnlyXmlTestResource("PropertyResourceConfigurerTests.xml", GetType());
     XmlObjectFactory xbf = new XmlObjectFactory(resource);
     PropertyPlaceholderConfigurer ppc = (PropertyPlaceholderConfigurer) xbf.GetObject("PlaceholderConfigurer");
     Assert.IsNotNull(ppc);
     ppc.PostProcessObjectFactory(xbf);
     TestObject to = (TestObject) xbf.GetObject("Test1");
     Assert.AreEqual("A DefName", to.Name);
 }
开发者ID:tobi-tobsen,项目名称:spring-net,代码行数:10,代码来源:PropertyPlaceholderConfigurerTests.cs

示例13: NoSuchInitMethod

 public void NoSuchInitMethod()
 {
     IResource resource = new ReadOnlyXmlTestResource("initializers.xml", GetType());
     XmlObjectFactory xof = new XmlObjectFactory(resource);
     Assert.Throws<ObjectCreationException>(() => xof.GetObject("init-method3"));
 }
开发者ID:spring-projects,项目名称:spring-net,代码行数:6,代码来源:XmlObjectFactoryTests.cs

示例14: ImportsExternalResourcesBailsOnNonExistentResource

 public void ImportsExternalResourcesBailsOnNonExistentResource()
 {
     IResource resource = new ReadOnlyXmlTestResource("bad-external-resources.xml", GetType());
     Assert.Throws<ObjectDefinitionStoreException>(() => new XmlObjectFactory(resource));
 }
开发者ID:spring-projects,项目名称:spring-net,代码行数:5,代码来源:XmlObjectFactoryTests.cs

示例15: BadParentReference

 public void BadParentReference()
 {
     IResource resource = new ReadOnlyXmlTestResource("wellformed-but-bad.xml", GetType());
     XmlObjectFactory xof = new XmlObjectFactory(resource);
     Assert.Throws<ObjectCreationException>(() => xof.GetObject("no.parent.factory"));
 }
开发者ID:spring-projects,项目名称:spring-net,代码行数:6,代码来源:XmlObjectFactoryTests.cs


注:本文中的Spring.Objects.Factory.Xml.ReadOnlyXmlTestResource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。