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


C# Support.XmlApplicationContext类代码示例

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


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

示例1: XmlApplicationContext

        public void ContainerResolvesSauceBéarnaise()
        {
            var context = new XmlApplicationContext("sauce.xml");
            SauceBéarnaise sauce = (SauceBéarnaise)context.GetObject("Sauce");

            Assert.NotNull(sauce);
        }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:7,代码来源:MenuFacts.cs

示例2: GetApplicationContextForConfigurationFile

        private static IApplicationContext GetApplicationContextForConfigurationFile(string configurationFile)
        {
            using (TimedLock.Lock(LoadedContexts))
            {
                IApplicationContext context;
                if (LoadedContexts.TryGetValue(configurationFile, out context))
                    return context;

                List<string> springFilesToLoad = new List<string>();
                foreach (string springFile in File.ReadAllLines("SpringFiles.txt"))
                    springFilesToLoad.Add("file://" + springFile);

                // Get all of the plugins
                foreach (string pluginFilename in Directory.GetFiles(".", "Plugin.*.xml"))
                    springFilesToLoad.Add("file://" + pluginFilename);

                // Load objects declared in Spring
                context = new XmlApplicationContext(springFilesToLoad.ToArray());

                // Load configuration file for options that can be set up in simplified XML
                ConfigurationFileReader.ReadConfigFile(context, configurationFile);

                LoadedContexts[configurationFile] = context;

                return context;
            }
        }
开发者ID:GWBasic,项目名称:ObjectCloud,代码行数:27,代码来源:ContextLoader.cs

示例3: Main

 public void Main()
 {
     var ctx = new XmlApplicationContext("objects.xml");
     var o1 = ctx.GetObject("SingletonObject");
     var o2 = ctx.GetObject("ProtoTypeObject");
     ctx.Dispose();
 }
开发者ID:serra,项目名称:stackoverflow,代码行数:7,代码来源:Program.cs

示例4: Setup

 public void Setup() {
     appContext = new XmlApplicationContext(false,
                                            ReadOnlyXmlTestResource.GetFilePath(
                                                "VelocityEngineFactoryObjectTests.xml",
                                                typeof(VelocityEngineFactoryObjectTests)));
     model.Add("var1", TEST_VALUE);
 }
开发者ID:fgq841103,项目名称:spring-net,代码行数:7,代码来源:VelocityEngineTestBase.cs

示例5: ShouldGetBacklogDistribution

        public void ShouldGetBacklogDistribution()
        {
            IApplicationContext context = new XmlApplicationContext(_config);

            IProbabilityDistribution backlogdist = (IProbabilityDistribution)context.GetObject("backlogdist");
            Assert.AreEqual(2, backlogdist.NextValue());
        }
开发者ID:jorn-ola-birkeland,项目名称:Flow-Simulator,代码行数:7,代码来源:SpringTest.cs

示例6: TestAutoProxyCreation

        public void TestAutoProxyCreation()
        {
            XmlApplicationContext context = new XmlApplicationContext(ReadOnlyXmlTestResource.GetFilePath("advisorAutoProxyCreatorCircularReferencesTests.xml", typeof(AdvisorAutoProxyCreatorCircularReferencesTests)));
            CountingAfterReturningAdvisor countingAdvisor = (CountingAfterReturningAdvisor)context.GetObject("testAdvisor");

            // direct deps of AutoProxyCreator are not eligable for proxying
            Assert.IsFalse(AopUtils.IsAopProxy(context.GetObject("aapc")));
            Assert.IsFalse(AopUtils.IsAopProxy(countingAdvisor));

            TestObjectFactoryObject testObjectFactory = (TestObjectFactoryObject) context.GetObject("&testObjectFactory");
            Assert.IsFalse(AopUtils.IsAopProxy(testObjectFactory));

            Assert.IsFalse(AopUtils.IsAopProxy(context.GetObject("someOtherObject")));

            // this one is completely independent
            Assert.IsTrue(AopUtils.IsAopProxy(context.GetObject("independentObject")));


            // Asserts SPRNET-1225 - advisor dependencies most not be auto-proxied
            object testObject = context.GetObject("testObjectFactory");
            Assert.IsFalse(AopUtils.IsAopProxy(testObject));

            // Asserts SPRNET-1224 - factory product most be cached
            context.GetObject("testObjectFactory");
            testObjectFactory.GetObjectCounter = 0;
            context.GetObject("testObjectFactory");
            Assert.AreEqual(0, testObjectFactory.GetObjectCounter);

            ICloneable someOtherObject = (ICloneable) context.GetObject("someOtherObject");
            someOtherObject.Clone();
            ICloneable independentObject = (ICloneable) context.GetObject("independentObject");
            independentObject.Clone();
            Assert.AreEqual(1, countingAdvisor.GetCalls());
        }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:34,代码来源:AdvisorAutoProxyCreatorCircularReferencesTests.cs

示例7: ContainerResolvesIngredientThroughExtensionMethod

        public void ContainerResolvesIngredientThroughExtensionMethod()
        {
            var context = new XmlApplicationContext("sauce.xml");
            IIngredient ingredient = context.Resolve<IIngredient>();

            Assert.IsAssignableFrom<SauceBéarnaise>(ingredient);
        }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:7,代码来源:MenuFacts.cs

示例8: CustomProperties

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

            Assert.IsTrue(ctx.ContainsObjectDefinition("channel"));

            RootObjectDefinition rod = ((IObjectDefinitionRegistry)ctx).GetObjectDefinition("channel") as RootObjectDefinition;
            Assert.IsNotNull(rod);

            Assert.IsTrue(rod.HasObjectType);
            Assert.AreEqual(typeof(ChannelFactoryObject<IContract>), rod.ObjectType);
            Assert.AreEqual(1, rod.ConstructorArgumentValues.NamedArgumentValues.Count);
            Assert.AreEqual("ecn", rod.ConstructorArgumentValues.GetNamedArgumentValue("endpointConfigurationName").Value);
            Assert.IsTrue(rod.PropertyValues.Contains("Credentials.Windows.ClientCredential"));
            Assert.AreEqual("Spring\\Bruno:gnirpS", rod.PropertyValues.GetPropertyValue("Credentials.Windows.ClientCredential").Value);

            ChannelFactoryObject<IContract> cfo = ctx.GetObject("&channel") as ChannelFactoryObject<IContract>;
            Assert.IsNotNull(cfo);
            Assert.AreEqual(typeof(IContract), cfo.ObjectType);
            Assert.AreEqual("Spring", cfo.Credentials.Windows.ClientCredential.Domain);
            Assert.AreEqual("Bruno", cfo.Credentials.Windows.ClientCredential.UserName);
            Assert.AreEqual("gnirpS", cfo.Credentials.Windows.ClientCredential.Password);

            IContract contract = ctx.GetObject("channel") as IContract;
            Assert.IsNotNull(contract);
        }
开发者ID:spring-projects,项目名称:spring-net,代码行数:29,代码来源:ChannelFactoryObjectDefinitionParserTests.cs

示例9: UseSpecifiedObjectNameGenerator

        public void UseSpecifiedObjectNameGenerator()
        {
            _applicationContext = new XmlApplicationContext(ReadOnlyXmlTestResource.GetFilePath("ConfigFiles.ComponentScan3.xml", GetType()));
            var objectDefinitionNames = _applicationContext.ObjectFactory.GetObjectDefinitionNames();

            Assert.That(objectDefinitionNames.Contains("prototype"), Is.True);
        }
开发者ID:Binodesk,项目名称:spring-net,代码行数:7,代码来源:ComponentScanObjectDefinitionParserTests.cs

示例10: ObtenerInsumosPlantilla

        /// <summary>
        /// Metodo que retorna la informacion de los insumos para generar las plantillas de estado de cuenta.
        /// </summary>
        /// <param name="IdConcesionario"></param>
        /// <param name="fecha"></param>
        /// <returns></returns>
        public System.Data.DataTable ObtenerInsumosPlantilla(decimal IdConcesionario, DateTime fecha)
        {
            DataTable insumo;
            try
            {
                IApplicationContext contexto = new XmlApplicationContext("DataConfiguration.xml");
                this.ConsultaDatos = (IConsultasPlantillaDB)contexto.GetObject("DaoConsulta");

                insumo = this.ConsultaDatos.ObtenerInsumosPlantilla(IdConcesionario, fecha);

            }
            catch (ExcepcionDatosEstadoCuenta excepcion)
            {
                throw excepcion;
            }
            catch (Exception excepcion)
            {
                string mensajeError = "Error presentado en la clase LogicaDatosEstadoCuenta en el método ObtenerInsumosPlantilla" +
                                      ". Detalle del error: " + excepcion.Message;

                throw new ExcepcionLogicaEstadoCuenta(mensajeError, excepcion);
            }

            return insumo;
        }
开发者ID:ramonsmits,项目名称:supportcode,代码行数:31,代码来源:LogicaDatosEstadoCuenta.cs

示例11: GetMenu

        public ActionResult GetMenu()
        {
            //TODO Eliminar cuando se descubra una mejor forma
            IApplicationContext appContext =
                new XmlApplicationContext(HttpContext.Server.MapPath(@"~/Config/service.xml"),
                    HttpContext.Server.MapPath(@"~/Config/repository.xml"));
            UsuarioService = (IUsuarioService)appContext.GetObject("UsuarioService");
            PerfilMenuService = (IPerfilMenuService)appContext.GetObject("PerfilMenuService");
            //

            List<Usuario> ListUsuario = UsuarioService.ReadUsuarioByUsername(User.Identity.Name).ToList();
            Usuario usuario = (Usuario)ListUsuario[0];
            IList<PerfilMenu> ListPM = PerfilMenuService.ReadPerfilMenuByPerfilId(usuario.PerfilId).ToList();
            IList<Menu> items = new List<Menu>();

            foreach (PerfilMenu pm in ListPM)
            {
                pm.Menu.Activo = pm.Activo;
                items.Add(pm.Menu);
            }

            MenuViewModel menuViewModel = new MenuViewModel(items, usuario);

            return PartialView("_Nav", menuViewModel);
        }
开发者ID:raflores,项目名称:ADSLAPEM,代码行数:25,代码来源:BaseController.cs

示例12: Main

        private static void Main(string[] args)
        {
            DeleteDatabase();

            _ctx = new XmlApplicationContext("objects.xml");
            try
            {
                PrintUsers();

                InsertUser("Marijn");

                PrintUsers();

                InsertUser("Iris");

                PrintUsers();

                Console.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            Console.WriteLine("Any key to exit ...");
            Console.ReadLine();
        }
开发者ID:serra,项目名称:spring-net-examples,代码行数:27,代码来源:Program.cs

示例13: ContainerLoadsXmlFromEmbeddedResource

        public void ContainerLoadsXmlFromEmbeddedResource()
        {
            var context = new XmlApplicationContext("assembly://Ploeh.Samples.Menu.SpringNet/Ploeh.Samples.Menu.SpringNet/sauce.xml");
            SauceBéarnaise sauce =
                (SauceBéarnaise)context.GetObject("Sauce");

            Assert.NotNull(sauce);
        }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:8,代码来源:MenuFacts.cs

示例14: ContainerLoadsXmlFromConfig

        public void ContainerLoadsXmlFromConfig()
        {
            var context = new XmlApplicationContext("config://spring/objects");
            SauceBéarnaise sauce =
                (SauceBéarnaise)context.GetObject("Sauce");

            Assert.NotNull(sauce);
        }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:8,代码来源:MenuFacts.cs

示例15: ShouldGetWorkStation

        public void ShouldGetWorkStation()
        {
            IApplicationContext context = new XmlApplicationContext(_config);

            IWorkStation ws = (IWorkStation)context.GetObject("ws1");

            Assert.IsNotNull(ws);
        }
开发者ID:jorn-ola-birkeland,项目名称:Flow-Simulator,代码行数:8,代码来源:SpringTest.cs


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