當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。