本文整理汇总了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);
}
示例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;
}
}
示例3: Main
public void Main()
{
var ctx = new XmlApplicationContext("objects.xml");
var o1 = ctx.GetObject("SingletonObject");
var o2 = ctx.GetObject("ProtoTypeObject");
ctx.Dispose();
}
示例4: Setup
public void Setup() {
appContext = new XmlApplicationContext(false,
ReadOnlyXmlTestResource.GetFilePath(
"VelocityEngineFactoryObjectTests.xml",
typeof(VelocityEngineFactoryObjectTests)));
model.Add("var1", TEST_VALUE);
}
示例5: ShouldGetBacklogDistribution
public void ShouldGetBacklogDistribution()
{
IApplicationContext context = new XmlApplicationContext(_config);
IProbabilityDistribution backlogdist = (IProbabilityDistribution)context.GetObject("backlogdist");
Assert.AreEqual(2, backlogdist.NextValue());
}
示例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());
}
示例7: ContainerResolvesIngredientThroughExtensionMethod
public void ContainerResolvesIngredientThroughExtensionMethod()
{
var context = new XmlApplicationContext("sauce.xml");
IIngredient ingredient = context.Resolve<IIngredient>();
Assert.IsAssignableFrom<SauceBéarnaise>(ingredient);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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();
}
示例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: ShouldGetWorkStation
public void ShouldGetWorkStation()
{
IApplicationContext context = new XmlApplicationContext(_config);
IWorkStation ws = (IWorkStation)context.GetObject("ws1");
Assert.IsNotNull(ws);
}