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