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


C# Xml.XmlObjectFactory类代码示例

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


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

示例1: SetUp

 public void SetUp()
 {
     IObjectFactory grandparent = new XmlObjectFactory(new ReadOnlyXmlTestResource("root.xml", GetType()));
     IObjectFactory parent = new XmlObjectFactory(new ReadOnlyXmlTestResource("middle.xml", GetType()), grandparent);
     IConfigurableListableObjectFactory child = new XmlObjectFactory(new ReadOnlyXmlTestResource("leaf.xml", GetType()), parent);
     _factory = child;
 }
开发者ID:spring-projects,项目名称:spring-net,代码行数:7,代码来源:ObjectFactoryUtilsTests.cs

示例2: MultiplePatterns

		public void MultiplePatterns()
		{
			IObjectFactory iof = new XmlObjectFactory(new ReadOnlyXmlTestResource("RegularExpressionSetterTests.xml", GetType()));
			IPerson advised = (IPerson) iof.GetObject("SettersAndReturnsThisAdvised");
			
		    // Interceptor behind regexp advisor
			NopInterceptor nop = (NopInterceptor) iof.GetObject("NopInterceptor");
			Assert.AreEqual(0, nop.Count);
		
			int newAge = 12;
			// Not advised
			advised.Exceptional(null);
			Assert.AreEqual(0, nop.Count);
			
			// This is proxied
			advised.ReturnsThis();
			Assert.AreEqual(1, nop.Count);
			
			// Only setter is advised
		    advised.SetAge(newAge);
			Assert.AreEqual(2, nop.Count);

		    Assert.AreEqual(newAge, advised.GetAge());
			Assert.AreEqual(2, nop.Count);
		}
开发者ID:fgq841103,项目名称:spring-net,代码行数:25,代码来源:RegularExpressionMethodPointcutAdvisorTests.cs

示例3: Setup

 public void Setup()
 {
     NamespaceParserRegistry.RegisterParser(typeof(RabbitNamespaceHandler));
     var resourceName = @"assembly://Spring.Messaging.Amqp.Rabbit.Tests/Spring.Messaging.Amqp.Rabbit.Tests.Config/" + typeof(ConnectionFactoryParserTests).Name + "-context.xml";
     var resource = new AssemblyResource(resourceName);
     this.objectFactory = new XmlObjectFactory(resource);
 }
开发者ID:yonglehou,项目名称:spring-net-amqp,代码行数:7,代码来源:ConnectionFactoryParserTests.cs

示例4: ConfigureIoC

        private void ConfigureIoC()
        {
            IResource input = new FileSystemResource(Server.MapPath("objects.xml"));
            IObjectFactory factory = new XmlObjectFactory(input);
            DependencyResolver.InitializeWith(new SpringDependencyResolver(factory));

            ControllerBuilder.Current.SetControllerFactory(typeof(IoCControllerFactory));
        }
开发者ID:EagleFlyHigh,项目名称:MvcContrib,代码行数:8,代码来源:Global.asax.cs

示例5: Setup

        public void Setup()
        {
            NamespaceParserRegistry.RegisterParser(typeof(RabbitNamespaceHandler));
            var resourceName = @"assembly://Spring.Messaging.Amqp.Rabbit.Tests/Spring.Messaging.Amqp.Rabbit.Tests.Config/" + typeof(ListenerContainerParserTests).Name + "-context.xml";
            var resource = new AssemblyResource(resourceName);
            this.objectFactory = new XmlObjectFactory(resource);

            // ((IConfigurableObjectFactory)objectFactory).setObjectExpressionResolver(new StandardObjectExpressionResolver());
        }
开发者ID:yonglehou,项目名称:spring-net-amqp,代码行数:9,代码来源:ListenerContainerParserTests.cs

示例6: ReadsReplicasWriteConcernCorrectly

        public void ReadsReplicasWriteConcernCorrectly()
        {
            string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
                           <objects xmlns='http://www.springframework.net' xmlns:mongo='http://www.springframework.net/mongo'>
                             <mongo:db-factory id='second' write-concern='W2' />
                           </objects>";
            var factory = new XmlObjectFactory(new StringResource(xml, Encoding.UTF8));

            var dbFactory = factory.GetObject<IMongoDatabaseFactory>("second");
            var db = dbFactory.GetDatabase();

            Assert.That(db.Settings.WriteConcern, Is.EqualTo(WriteConcern.W2));
        }
开发者ID:thomast74,项目名称:spring-net-data-mongodb,代码行数:13,代码来源:MongoDatabaseFactoryParserTests.cs

示例7: CreatesDbFactoryBean

        public void CreatesDbFactoryBean()
        {
            string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
                           <objects xmlns='http://www.springframework.net' xmlns:mongo='http://www.springframework.net/mongo'>
                             <mongo:mongo url='mongodb://localhost' />
                             <mongo:db-factory id='first' mongo-ref='Mongo' write-concern='WMajority' />
                           </objects>";
            var factory = new XmlObjectFactory(new StringResource(xml, Encoding.UTF8));

            var mongoDatabase = factory.GetObject("first");

            Assert.That(mongoDatabase, Is.Not.Null);
        }
开发者ID:thomast74,项目名称:spring-net-data-mongodb,代码行数:13,代码来源:MongoDatabaseFactoryParserTests.cs

示例8: SingletonProxyWithPrototypeTarget

		public void SingletonProxyWithPrototypeTarget() 
		{
			TestObjectImpl.constructionCount = 0;
			IObjectFactory iof = new XmlObjectFactory(new ReadOnlyXmlTestResource("prototypeTarget.xml", GetType()));
			for (int i = 0; i < 10; i++) 
			{
				TestObject to = (TestObject) iof.GetObject("testObjectSingleton");
				to.DoSomething();
			}
			TestInterceptor interceptor = (TestInterceptor) iof.GetObject("testInterceptor");
			Assert.AreEqual(1, TestObjectImpl.constructionCount);
			Assert.AreEqual(10, interceptor.invocationCount);
		}
开发者ID:fgq841103,项目名称:spring-net,代码行数:13,代码来源:PrototypeTargetTests.cs

示例9: SetUp

        public void SetUp()
        {
            const string xml =
    @"<?xml version='1.0' encoding='UTF-8' ?>
<objects xmlns='http://www.springframework.net'>
	<object id='noDecoratedService' type='Spring.Web.Services.WebServiceExporterTests+NoDecoratedService, Spring.Web.Tests'/>
    <object id='decoratedService' type='Spring.Web.Services.WebServiceExporterTests+DecoratedService, Spring.Web.Tests'/>
</objects>";
            Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(xml));
            IObjectFactory objectFactory = new XmlObjectFactory(new InputStreamResource(stream, string.Empty));

            wse = new WebServiceExporter();
            wse.ObjectFactory = objectFactory;
        }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:14,代码来源:WebServiceExporterTests.cs

示例10: RejectsConnectStringPlusDetailedConfiguration

        public void RejectsConnectStringPlusDetailedConfiguration()
        {
            string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
                           <objects xmlns='http://www.springframework.net' xmlns:mongo='http://www.springframework.net/mongo'>
                             <mongo:db-factory url='mongodb://localhost/database' username='username' password='password'/>
                           </objects>";

            Assert.That(
                delegate
                    {
                        var factory = new XmlObjectFactory(new StringResource(xml, Encoding.UTF8));
                    },
                Throws.TypeOf<ObjectDefinitionStoreException>());
        }
开发者ID:thomast74,项目名称:spring-net-data-mongodb,代码行数:14,代码来源:MongoDatabaseFactoryParserTests.cs

示例11: TestDifferentCollectionTypes

        public void TestDifferentCollectionTypes()
        {
            const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
            <objects xmlns='http://www.springframework.net' xmlns:v='http://www.springframework.net/validation'>
          <v:group id='validatePerson' when='T(Spring.Objects.TestObject) == #this.GetType()'>
            <v:required id ='req' when='true' test='Name'/>
            <v:regex id ='reg' test='Name'>
              <v:property name='Expression' value='[a-z]*\s[a-z]*'/>
              <v:property name='Options' value='IgnoreCase'/>
              <v:message id='reg1' providers='regularni' when='true'>
                 <v:param value='#this.ToString()'/> 
              </v:message>
            </v:regex>
          </v:group>  
           <v:collection id='collectionValidator' validate-all='true'>
                <v:ref name='validatePerson'/>
           </v:collection>
           </objects>";

            MemoryStream stream = new MemoryStream(new UTF8Encoding().GetBytes(xml));
            IResource resource = new InputStreamResource(stream, "collectionValidator");

            XmlObjectFactory objectFactory = new XmlObjectFactory(resource, null);
            CollectionValidator validator = (CollectionValidator) objectFactory.GetObject("collectionValidator");
            
            IList listPersons = new ArrayList();
            IDictionary dictPersons = new Hashtable();
            ISet setPersons = new ListSet();  

            listPersons.Add(new TestObject("DAMJAN Tomic", 24));
            listPersons.Add(new TestObject("Goran Milosavljevic", 24));
            listPersons.Add(new TestObject("Ivan CIKIC", 28));

            dictPersons.Add(1, listPersons[0]);
            dictPersons.Add(2, listPersons[1]);
            dictPersons.Add(3, listPersons[2]);

            setPersons.AddAll(listPersons);
            IValidationErrors ve = new ValidationErrors();

            Assert.IsTrue(validator.Validate(listPersons, ve));                        
            Assert.IsTrue(ve.IsEmpty);                                    
            Assert.IsTrue(validator.Validate(dictPersons, ve));
            Assert.IsTrue(ve.IsEmpty);
            Assert.IsTrue(validator.Validate(setPersons, ve));
            Assert.IsTrue(ve.IsEmpty);
        }
开发者ID:Binodesk,项目名称:spring-net,代码行数:47,代码来源:CollectionValidatorTests.cs

示例12: ISBNValidatorTests

        public void ISBNValidatorTests()
        {
            const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
            <objects xmlns='http://www.springframework.net' xmlns:v='http://www.springframework.net/validation'>
                <v:validator id='urlValidator' test='#this' type='Spring.Validation.Validators.UrlValidator, Spring.Core'/>
            </objects>";
            
            MemoryStream stream = new MemoryStream(new UTF8Encoding().GetBytes(xml));
            IResource resource = new InputStreamResource(stream, "urlValidator");

            XmlObjectFactory objectFactory = new XmlObjectFactory(resource, null);
            object obj = objectFactory.GetObject("urlValidator");
            
            Assert.IsTrue(obj is IValidator);
            IValidator validator = obj as IValidator;
            Assert.IsTrue(validator.Validate("http://www.springframework.net", new ValidationErrors()));
        }
开发者ID:Binodesk,项目名称:spring-net,代码行数:17,代码来源:UrlValidatorIntegrationTests.cs

示例13: SetUp

        public void SetUp()
        {
            const string xml =
    @"<?xml version='1.0' encoding='UTF-8' ?>
        <objects xmlns='http://www.springframework.net'>
	        <object id='service' type='Spring.ServiceModel.ServiceExporterTests+Service, Spring.Services.Tests'/>
	        <object id='serviceWithMultipleInterfaces' type='Spring.ServiceModel.ServiceExporterTests+ServiceWithMultipleInterfaces, Spring.Services.Tests'/>
            <object id='decoratedService' type='Spring.ServiceModel.ServiceExporterTests+DecoratedService, Spring.Services.Tests'/>
            <object id='anotherService' type='Spring.ServiceModel.ServiceExporterTests+AnotherService, Spring.Services.Tests'/>
        </objects>";

            using (Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(xml)))
            {
                IObjectFactory objectFactory = new XmlObjectFactory(new InputStreamResource(stream, string.Empty));
                se = new ServiceExporter();
                se.ObjectFactory = objectFactory;
            }
        }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:18,代码来源:ServiceExporterTests.cs

示例14: Setup

 public override void Setup()
 {
     string objectXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?> " +
        "  <objects xmlns=\"http://www.springframework.net\" " +
        "    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
        "    xsi:schemaLocation=\"http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd\"> " +
        "    <object id=\"SimpleDependency\" singleton=\"false\" type=\"MvcContrib.UnitTests.IoC.SimpleDependency\"/> " +
        "    <object id=\"NestedDependency\" singleton=\"false\" type=\"MvcContrib.UnitTests.IoC.NestedDependency\" > " +
        "      <constructor-arg> " +
        "        <object type=\"MvcContrib.UnitTests.IoC.SimpleDependency\" /> " +
        "      </constructor-arg> " +
        "    </object> " +
        "  </objects>";
     Stream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(objectXml));
     IResource resource = new InputStreamResource(stream, "In memory xml");
     IObjectFactory factory = new XmlObjectFactory(resource);
     _dependencyResolver = new SpringDependencyResolver(factory);
 }
开发者ID:JonKruger,项目名称:MvcContrib,代码行数:18,代码来源:SpringDependencyResolverTester.cs

示例15: DoesntCallContextRegistryForLocalObjectFactoryReferences

        public void DoesntCallContextRegistryForLocalObjectFactoryReferences()
        {
            string xml = string.Format(
                @"<?xml version='1.0' encoding='UTF-8' ?>
<objects xmlns='http://www.springframework.net'>
	<object id='foo' type='{0}'>
        <property name='MyField' expression='@(theObject)' />
    </object>
</objects>"
                            , typeof(MyTestObject).AssemblyQualifiedName
                            );

            XmlObjectFactory of = new XmlObjectFactory(new StringResource(xml, Encoding.UTF8));
            object theObject = new object();
            of.RegisterSingleton("theObject", theObject);

            MyTestObject to = (MyTestObject) of.GetObject("foo");
            Assert.AreSame( theObject, to.MyField );
        }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:19,代码来源:ReferenceNodeTests.cs


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