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


C# XmlApplicationContext.GetObject方法代码示例

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


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

示例1: 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

示例2: 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

示例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: Main

 public void Main()
 {
     var ctx = new XmlApplicationContext("q11630224/objects.xml");
     var report1 = (IReport)ctx.GetObject("report1");
     var report2 = (IReport)ctx.GetObject("report1");
     Console.WriteLine(UsageTrackingInterceptor.UsageCount);
     report1.WriteReport();
     report2.WriteReport();
     Console.WriteLine(UsageTrackingInterceptor.UsageCount);
 }
开发者ID:serra,项目名称:stackoverflow,代码行数:10,代码来源:Program.cs

示例5: UsingNullFactoryObjectIsAnOptionIfWeMassageContextToAllowForNullReferences

        public void UsingNullFactoryObjectIsAnOptionIfWeMassageContextToAllowForNullReferences()
        {
            var ctx = new XmlApplicationContext("objects.xml", "objects-ref1-as-nullobject.xml");

            var o2 = (MyClass)ctx.GetObject("MySecondObject");
            Assert.IsNotNull(o2.Prop);

            var o = (MyClass)ctx.GetObject("MyObject");
            Assert.IsNotNull(o.Prop);
            Assert.IsInstanceOf<IMyOtherInterface>(o.Prop);
            Assert.IsInstanceOf<MyOtherClassNullObject>(o.Prop);
        }
开发者ID:serra,项目名称:stackoverflow,代码行数:12,代码来源:Program.cs

示例6: ComponentsUseSpecifiedName

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

            Assert.That(objectDefinitionNames.Count, Is.EqualTo(5 + 4));
            Assert.That(_applicationContext.GetObject("Component"), Is.Not.Null);
            Assert.That(_applicationContext.GetObject("Service"), Is.Not.Null);
            Assert.That(_applicationContext.GetObject("Repository"), Is.Not.Null);
            Assert.That(_applicationContext.GetObject("Controller"), Is.Not.Null);
            Assert.That(_applicationContext.GetObject("Configuration"), Is.Not.Null);
        }
开发者ID:Binodesk,项目名称:spring-net,代码行数:12,代码来源:ComponentScanObjectDefinitionParserTests.cs

示例7: ScanComponentsAndAddToContext

        public void ScanComponentsAndAddToContext()
        {
            var prefix = "ComponentScan.ScanComponentsAndAddToContext.";
            _applicationContext = new XmlApplicationContext(ReadOnlyXmlTestResource.GetFilePath("ConfigFiles.ComponentScan1.xml", GetType()));
            var objectDefinitionNames = _applicationContext.ObjectFactory.GetObjectDefinitionNames();

            Assert.That(objectDefinitionNames.Count, Is.EqualTo(5+4));
            Assert.That(_applicationContext.GetObject(prefix + "ComponentImpl"), Is.Not.Null);
            Assert.That(_applicationContext.GetObject(prefix + "ServiceImpl"), Is.Not.Null);
            Assert.That(_applicationContext.GetObject(prefix + "RepositoryImpl"), Is.Not.Null);
            Assert.That(_applicationContext.GetObject(prefix + "ControllerImpl"), Is.Not.Null);
            Assert.That(_applicationContext.GetObject(prefix + "ConfigurationImpl"), Is.Not.Null);
        }
开发者ID:Binodesk,项目名称:spring-net,代码行数:13,代码来源:ComponentScanObjectDefinitionParserTests.cs

示例8: Exe1

        public void Exe1()
        {
            var ctx2 = new StaticApplicationContext();
            //  var ctx = ContextRegistry.GetContext(); // 全局配置

            var ctx = new XmlApplicationContext(System.AppDomain.CurrentDomain.BaseDirectory + "bin/SpringNet/objects.xml"); // 局部配置
            //ctx.RegisterPrototype("Person", typeof(Student), null);
            //ctx.RegisterSingleton("Alice", typeof(Person), null);
            // 注册可以通过xml配置注册
            Person person = ctx.GetObject("Person") as Person;
            Person alice = ctx.GetObject("Alice") as Person;

            var a = 1;
        }
开发者ID:rager520,项目名称:StarTech,代码行数:14,代码来源:SpringNetAction.cs

示例9: MainWindow

        public MainWindow()
        {
            InitializeComponent();
            IApplicationContext context = new XmlApplicationContext("Config/spring.net.xml");
            IUserService userService = (IUserService)context.GetObject("UserService");
            IGroupService groupService = (IGroupService)context.GetObject("GroupService");
            userService.Login("admin", "123456");
            IList<GroupVO> list = groupService.GetListAll();
            foreach (GroupVO vo in list)
            {
                this.textBox.Text += vo.GroupName + "---";
                System.Console.WriteLine("" + vo.GroupName);
            }

        }
开发者ID:limingnihao,项目名称:Net,代码行数:15,代码来源:MainWindow.xaml.cs

示例10: 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

示例11: 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

示例12: 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

示例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: ContainerLoadsXmlFromFileMoniker

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

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


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