本文整理汇总了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);
}
示例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());
}
示例3: Main
public void Main()
{
var ctx = new XmlApplicationContext("objects.xml");
var o1 = ctx.GetObject("SingletonObject");
var o2 = ctx.GetObject("ProtoTypeObject");
ctx.Dispose();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
}
示例10: ShouldGetBacklogDistribution
public void ShouldGetBacklogDistribution()
{
IApplicationContext context = new XmlApplicationContext(_config);
IProbabilityDistribution backlogdist = (IProbabilityDistribution)context.GetObject("backlogdist");
Assert.AreEqual(2, backlogdist.NextValue());
}
示例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;
}
示例12: XmlApplicationContext
public void ContainerResolvesSauceBéarnaise()
{
var context = new XmlApplicationContext("sauce.xml");
SauceBéarnaise sauce = (SauceBéarnaise)context.GetObject("Sauce");
Assert.NotNull(sauce);
}
示例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);
}
示例14: ContainerLoadsXmlFromConfig
public void ContainerLoadsXmlFromConfig()
{
var context = new XmlApplicationContext("config://spring/objects");
SauceBéarnaise sauce =
(SauceBéarnaise)context.GetObject("Sauce");
Assert.NotNull(sauce);
}
示例15: ContainerLoadsXmlFromFileMoniker
public void ContainerLoadsXmlFromFileMoniker()
{
var context = new XmlApplicationContext("file://sauce.xml");
SauceBéarnaise sauce =
(SauceBéarnaise)context.GetObject("Sauce");
Assert.NotNull(sauce);
}