當前位置: 首頁>>代碼示例>>C#>>正文


C# XmlApplicationContext.GetObjectsOfType方法代碼示例

本文整理匯總了C#中Spring.Context.Support.XmlApplicationContext.GetObjectsOfType方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlApplicationContext.GetObjectsOfType方法的具體用法?C# XmlApplicationContext.GetObjectsOfType怎麽用?C# XmlApplicationContext.GetObjectsOfType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Spring.Context.Support.XmlApplicationContext的用法示例。


在下文中一共展示了XmlApplicationContext.GetObjectsOfType方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: XmlApplicationContext

        public void ContainerResolvesSauceBéarnaiseThroughType()
        {
            var context = new XmlApplicationContext("sauce.xml");
            SauceBéarnaise sauce = context.GetObjectsOfType(typeof(SauceBéarnaise)).Values.OfType<SauceBéarnaise>().Single();

            Assert.NotNull(sauce);
        }
開發者ID:mesta1,項目名稱:dli.net_sourcecode,代碼行數:7,代碼來源:MenuFacts.cs

示例2: WithoutId

        //[Test]
        public void WithoutId()
        {
            NamespaceParserRegistry.RegisterParser(typeof(WcfNamespaceParser));
            IApplicationContext ctx = new XmlApplicationContext(
                ReadOnlyXmlTestResource.GetFilePath("ChannelFactoryObjectDefinitionParserTests.WithoutId.xml", this.GetType()));

            IDictionary channels = ctx.GetObjectsOfType(typeof(IContract));
            Assert.AreEqual(1, channels.Count);
        }
開發者ID:fuadm,項目名稱:spring-net,代碼行數:10,代碼來源:ChannelFactoryObjectDefinitionParserTests.cs

示例3: ResolveUnnamedJunkFood

        public void ResolveUnnamedJunkFood()
        {
            var context = new XmlApplicationContext("ResolveUnnamedJunkFood.xml");
            var meal = context.GetObjectsOfType(typeof(JunkFood)).Values.OfType<JunkFood>().FirstOrDefault();

            Assert.NotNull(meal);
        }
開發者ID:mesta1,項目名稱:dli.net_sourcecode,代碼行數:7,代碼來源:MenuFacts.cs

示例4: CreateMultiCourseMealFromAllCourses

        public void CreateMultiCourseMealFromAllCourses()
        {
            var context = new XmlApplicationContext("CreateMultiCourseMealFromAllCourses.xml");
            var meal = context.GetObjectsOfType(typeof(IMeal)).Values.OfType<IMeal>().Single();

            var threeCourseMeal = Assert.IsAssignableFrom<Meal>(meal);
            Assert.IsAssignableFrom<Rillettes>(threeCourseMeal.Courses.First());
            Assert.IsAssignableFrom<CordonBleu>(threeCourseMeal.Courses.ElementAt(1));
            Assert.IsAssignableFrom<MousseAuChocolat>(threeCourseMeal.Courses.ElementAt(2));
        }
開發者ID:mesta1,項目名稱:dli.net_sourcecode,代碼行數:10,代碼來源:MenuFacts.cs

示例5: RegisterUnnamedIngredientsAndResolveByInterface

        public void RegisterUnnamedIngredientsAndResolveByInterface()
        {
            var context = new XmlApplicationContext("RegisterUnnamedIngredientsAndResolveByInterface.xml");
            var ingredients = context.GetObjectsOfType(typeof(IIngredient));

            Assert.True(ingredients.Values.OfType<Steak>().Any());
            Assert.True(ingredients.Values.OfType<SauceBéarnaise>().Any());
        }
開發者ID:mesta1,項目名稱:dli.net_sourcecode,代碼行數:8,代碼來源:MenuFacts.cs

示例6: RegisterUnnamedIngredientsAndResolveByConcreteType

        public void RegisterUnnamedIngredientsAndResolveByConcreteType()
        {
            var context = new XmlApplicationContext("RegisterUnnamedIngredientsAndResolveByConcreteType.xml");
            var meat = context.GetObjectsOfType(typeof(Steak))
                .Values
                .OfType<Steak>()
                .FirstOrDefault();
            var sauce = context.GetObjectsOfType(typeof(SauceBéarnaise)).Values.OfType<SauceBéarnaise>().FirstOrDefault();

            Assert.NotNull(meat);
            Assert.NotNull(sauce);
        }
開發者ID:mesta1,項目名稱:dli.net_sourcecode,代碼行數:12,代碼來源:MenuFacts.cs

示例7: ShouldLoad

        public void ShouldLoad()
        {
            IList<IObjectFactoryPostProcessor> all = new List<IObjectFactoryPostProcessor>();

            XmlApplicationContext child1 = new XmlApplicationContext("file://Spring/Layered/child1.xml");
            IDictionary processors = child1.GetObjectsOfType(typeof (IObjectFactoryPostProcessor));
            IEnumerator enumerator = processors.Values.GetEnumerator();

            while(enumerator.MoveNext())
            {
                all.Add((IObjectFactoryPostProcessor)enumerator.Current);
            }

            XmlApplicationContext child2 = new XmlApplicationContext(false, null, true, child1, "file://Spring/Layered/child2.xml");
            foreach (IObjectFactoryPostProcessor entry in all)
            {
                child2.AddObjectFactoryPostProcessor(entry);
            }
            child2.Refresh();
            XmlApplicationContext main = new XmlApplicationContext(false, null, true, child2, "file://Spring/Layered/main.xml");

            foreach (IObjectFactoryPostProcessor entry in all)
            {
                main.AddObjectFactoryPostProcessor(entry);
            }
            main.Refresh();
            Aggregate agg = (Aggregate) main.GetObject("agg");
            Assert.IsNotNull(agg);

            Service3 three = (Service3) main.GetObject("service3");

            Assert.IsNotNull(three);

            PostProcessor processor = (PostProcessor)main.GetObject("PostProcessor");

            Assert.IsNotNull(processor);
            IList<string> names = processor.Names;
            Assert.AreEqual(3, names.Count);
            Assert.IsTrue(names.Contains("foo"));
            Assert.IsTrue(names.Contains("barService"));
            Assert.IsTrue(names.Contains("connection"));
        }
開發者ID:sbendiola,項目名稱:sandbox,代碼行數:42,代碼來源:TestLayering.cs


注:本文中的Spring.Context.Support.XmlApplicationContext.GetObjectsOfType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。