diff --git a/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContextArgs.cs b/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContextArgs.cs
index fd8c992f..87fee378 100644
--- a/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContextArgs.cs
+++ b/src/Spring/Spring.Core/Context/Support/AbstractXmlApplicationContextArgs.cs
@@ -27,26 +27,94 @@ namespace Spring.Context.Support
{
public abstract class AbstractXmlApplicationContextArgs
{
+ private bool _caseSensitive;
- public virtual bool CaseSensitive { get; set; }
+ private string[] _configurationLocations;
- public virtual string[] ConfigurationLocations { get; set; }
+ private IResource[] _configurationResources;
- public virtual IResource[] ConfigurationResources { get; set; }
+ private string _name;
- public virtual string Name { get; set; }
+ private IApplicationContext _parentContext;
- public virtual IApplicationContext ParentContext { get; set; }
+ private bool _refresh;
- public virtual bool Refresh { get; set; }
-
- ///
- /// Initializes a new instance of the AbstractXmlApplicationContextArgs class.
- ///
- public AbstractXmlApplicationContextArgs()
+ public virtual bool CaseSensitive
{
- ConfigurationLocations = new string[0];
- ConfigurationResources = new IResource[0];
+ get
+ {
+ return _caseSensitive;
+ }
+ set
+ {
+ _caseSensitive = value;
+ }
+ }
+
+ public virtual string[] ConfigurationLocations
+ {
+ get
+ {
+ if (_configurationLocations == null)
+ _configurationLocations = new string[0];
+
+ return _configurationLocations;
+ }
+ set
+ {
+ _configurationLocations = value;
+ }
+ }
+
+ public virtual IResource[] ConfigurationResources
+ {
+ get
+ {
+ if (_configurationResources == null)
+ _configurationResources = new IResource[0];
+
+ return _configurationResources;
+ }
+ set
+ {
+ _configurationResources = value;
+ }
+ }
+
+ public virtual string Name
+ {
+ get
+ {
+ return _name;
+ }
+ set
+ {
+ _name = value;
+ }
+ }
+
+ public virtual IApplicationContext ParentContext
+ {
+ get
+ {
+ return _parentContext;
+ }
+ set
+ {
+ _parentContext = value;
+ }
+ }
+
+ public virtual bool Refresh
+ {
+ get
+ {
+ return _refresh;
+ }
+ set
+ {
+ _refresh = value;
+ }
}
}
diff --git a/src/Spring/Spring.Core/Context/Support/XmlApplicationContext.cs b/src/Spring/Spring.Core/Context/Support/XmlApplicationContext.cs
index aa9e82b0..ff4da0ae 100644
--- a/src/Spring/Spring.Core/Context/Support/XmlApplicationContext.cs
+++ b/src/Spring/Spring.Core/Context/Support/XmlApplicationContext.cs
@@ -111,7 +111,7 @@ namespace Spring.Context.Support
Refresh();
}
}
-
+
}
@@ -126,7 +126,7 @@ namespace Spring.Context.Support
/// Any number of XML based object definition resource locations.
///
public XmlApplicationContext(params string[] configurationLocations)
- : this(new XmlApplicationContextArgs() { ConfigurationLocations = configurationLocations })
+ : this(new XmlApplicationContextArgs(string.Empty, null, configurationLocations, null, true, true))
{ }
///
@@ -140,7 +140,7 @@ namespace Spring.Context.Support
///
public XmlApplicationContext(bool caseSensitive,
params string[] configurationLocations)
- : this(new XmlApplicationContextArgs() { CaseSensitive = caseSensitive, ConfigurationLocations = configurationLocations })
+ : this(new XmlApplicationContextArgs(string.Empty, null, configurationLocations, null, caseSensitive, true))
{ }
///
@@ -155,7 +155,7 @@ namespace Spring.Context.Support
///
public XmlApplicationContext(string name, bool caseSensitive,
params string[] configurationLocations)
- : this(new XmlApplicationContextArgs() { Name = name, CaseSensitive = caseSensitive, ConfigurationLocations = configurationLocations })
+ : this(new XmlApplicationContextArgs(name, null, configurationLocations, null, caseSensitive, true))
{ }
///
@@ -173,7 +173,7 @@ namespace Spring.Context.Support
public XmlApplicationContext(
IApplicationContext parentContext,
params string[] configurationLocations)
- : this(new XmlApplicationContextArgs() { ParentContext = parentContext, ConfigurationLocations = configurationLocations })
+ : this(new XmlApplicationContextArgs(string.Empty, parentContext, configurationLocations, null, true, true))
{ }
///
@@ -193,7 +193,7 @@ namespace Spring.Context.Support
bool caseSensitive,
IApplicationContext parentContext,
params string[] configurationLocations)
- : this(new XmlApplicationContextArgs() { CaseSensitive = caseSensitive, ParentContext = parentContext, ConfigurationLocations = configurationLocations })
+ : this(new XmlApplicationContextArgs(string.Empty, parentContext, configurationLocations, null, caseSensitive, true))
{ }
///
@@ -215,7 +215,7 @@ namespace Spring.Context.Support
bool caseSensitive,
IApplicationContext parentContext,
params string[] configurationLocations)
- : this(new XmlApplicationContextArgs() { Name = name, CaseSensitive = caseSensitive, ParentContext = parentContext, ConfigurationLocations = configurationLocations })
+ : this(new XmlApplicationContextArgs(name, parentContext, configurationLocations, null, caseSensitive, true))
{ }
///
@@ -243,7 +243,7 @@ namespace Spring.Context.Support
bool caseSensitive,
IApplicationContext parentContext,
params string[] configurationLocations)
- : this(new XmlApplicationContextArgs() { Refresh = refresh, Name = name, CaseSensitive = caseSensitive, ParentContext = parentContext, ConfigurationLocations = configurationLocations })
+ : this(new XmlApplicationContextArgs(name, parentContext, configurationLocations, null, true, refresh))
{ }
@@ -254,7 +254,7 @@ namespace Spring.Context.Support
IApplicationContext parentContext,
string[] configurationLocations,
IResource[] configurationResources)
- : this(new XmlApplicationContextArgs() { Refresh = refresh, Name = name, CaseSensitive = caseSensitive, ParentContext = parentContext, ConfigurationLocations = configurationLocations, ConfigurationResources = configurationResources })
+ : this(new XmlApplicationContextArgs(name, parentContext, configurationLocations, null, caseSensitive, refresh))
{ }
diff --git a/src/Spring/Spring.Core/Context/Support/XmlApplicationContextArgs.cs b/src/Spring/Spring.Core/Context/Support/XmlApplicationContextArgs.cs
index 7a87b775..4f981bd5 100644
--- a/src/Spring/Spring.Core/Context/Support/XmlApplicationContextArgs.cs
+++ b/src/Spring/Spring.Core/Context/Support/XmlApplicationContextArgs.cs
@@ -25,15 +25,52 @@ using Spring.Core.IO;
namespace Spring.Context.Support
{
+ ///
+ /// Encapsulates arguments to the class.
+ ///
public class XmlApplicationContextArgs : AbstractXmlApplicationContextArgs
{
+
+ private const bool DEFAULT_REFRESH = true;
+ private const bool DEFAULT_CASESENSITIVE = true;
+
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public XmlApplicationContextArgs()
+ : this(string.Empty, null, null, null, DEFAULT_CASESENSITIVE, DEFAULT_REFRESH)
+ { }
+
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The name.
+ /// The parent context.
+ /// The configuration locations.
+ /// The configuration resources.
+ public XmlApplicationContextArgs(string name, IApplicationContext parentContext, string[] configurationLocations, IResource[] configurationResources)
+ : this(name, parentContext, configurationLocations, configurationResources, DEFAULT_CASESENSITIVE, DEFAULT_REFRESH)
+ { }
+
///
/// Initializes a new instance of the XmlApplicationContextArgs class.
///
- public XmlApplicationContextArgs()
+ /// The name.
+ /// The parent context.
+ /// The configuration locations.
+ /// The configuration resources.
+ /// if set to true [case sensitive].
+ /// if set to true [refresh].
+ public XmlApplicationContextArgs(string name, IApplicationContext parentContext, string[] configurationLocations, IResource[] configurationResources, bool caseSensitive, bool refresh)
{
- CaseSensitive = true;
- Refresh = true;
+ Name = name;
+ ParentContext = parentContext;
+ ConfigurationLocations = configurationLocations;
+ ConfigurationResources = configurationResources;
+ CaseSensitive = caseSensitive;
+ Refresh = refresh;
}
}
}
diff --git a/src/Spring/Spring.Web/Context/Support/WebApplicationContext.cs b/src/Spring/Spring.Web/Context/Support/WebApplicationContext.cs
index 6678dce0..503438e1 100644
--- a/src/Spring/Spring.Web/Context/Support/WebApplicationContext.cs
+++ b/src/Spring/Spring.Web/Context/Support/WebApplicationContext.cs
@@ -68,7 +68,7 @@ namespace Spring.Context.Support
///
/// Names of configuration resources.
public WebApplicationContext(params string[] configurationLocations)
- : this(new WebApplicationContextArgs() { ConfigurationLocations = configurationLocations })
+ : this(new WebApplicationContextArgs(string.Empty, null, configurationLocations, null, false))
{
}
@@ -80,7 +80,7 @@ namespace Spring.Context.Support
/// Flag specifying whether to make this context case sensitive or not.
/// Names of configuration resources.
public WebApplicationContext(string name, bool caseSensitive, params string[] configurationLocations)
- : this(new WebApplicationContextArgs() { Name = name, CaseSensitive = caseSensitive, ConfigurationLocations = configurationLocations })
+ : this(new WebApplicationContextArgs(name, null, configurationLocations, null, caseSensitive))
{
}
@@ -93,7 +93,7 @@ namespace Spring.Context.Support
/// Names of configuration resources.
/// Configuration resources.
public WebApplicationContext(string name, bool caseSensitive, string[] configurationLocations, IResource[] configurationResources)
- : this(new WebApplicationContextArgs() { Name = name, CaseSensitive = caseSensitive, ConfigurationLocations = configurationLocations, ConfigurationResources=configurationResources })
+ : this(new WebApplicationContextArgs(name, null, configurationLocations, configurationResources, caseSensitive))
{
}
@@ -107,14 +107,20 @@ namespace Spring.Context.Support
/// Names of configuration resources.
public WebApplicationContext(string name, bool caseSensitive, IApplicationContext parentContext,
params string[] configurationLocations)
- : this(new WebApplicationContextArgs() { Name = name, CaseSensitive = caseSensitive, ParentContext = parentContext, ConfigurationLocations = configurationLocations })
+ : this(new WebApplicationContextArgs(name, parentContext, configurationLocations, null, caseSensitive))
{ }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The args.
public WebApplicationContext(WebApplicationContextArgs args)
: base(args.Name, args.CaseSensitive, args.ParentContext)
{
_configurationLocations = args.ConfigurationLocations;
+ _configurationResources = args.ConfigurationResources;
+
DefaultResourceProtocol = WebUtils.DEFAULT_RESOURCE_PROTOCOL;
Refresh();
diff --git a/src/Spring/Spring.Web/Context/Support/WebApplicationContextArgs.cs b/src/Spring/Spring.Web/Context/Support/WebApplicationContextArgs.cs
index fffd473f..8622b1ee 100644
--- a/src/Spring/Spring.Web/Context/Support/WebApplicationContextArgs.cs
+++ b/src/Spring/Spring.Web/Context/Support/WebApplicationContextArgs.cs
@@ -22,19 +22,57 @@
using System;
using System.Collections.Generic;
using System.Text;
+using Spring.Core.IO;
namespace Spring.Context.Support
{
-
+ ///
+ /// Encapsulates arguments to the class.
+ ///
public class WebApplicationContextArgs : AbstractXmlApplicationContextArgs
{
+
+ private const bool DEFAULT_CASESENSITIVE = false;
+ private const bool DEFAULT_REFRESH = false;
+
///
/// Initializes a new instance of the WebApplicationContextArgs class.
///
public WebApplicationContextArgs()
{
- CaseSensitive = false;
+ CaseSensitive = DEFAULT_CASESENSITIVE;
}
-
+
+ ///
+ /// Initializes a new instance of the WebApplicationContextArgs class.
+ ///
+ /// The name.
+ /// The parent context.
+ /// The configuration locations.
+ /// The configuration resources.
+ public WebApplicationContextArgs(string name, IApplicationContext parentContext, string[] configurationLocations, IResource[] configurationResources)
+ : this(name, parentContext, configurationLocations, configurationResources, DEFAULT_CASESENSITIVE)
+ { }
+
+
+ ///
+ /// Initializes a new instance of the WebApplicationContextArgs class.
+ ///
+ /// The name.
+ /// The parent context.
+ /// The configuration locations.
+ /// The configuration resources.
+ /// if set to true [case sensitive].
+ public WebApplicationContextArgs(string name, IApplicationContext parentContext, string[] configurationLocations, IResource[] configurationResources, bool caseSensitive)
+ {
+ Name = name;
+ ParentContext = parentContext;
+ ConfigurationLocations = configurationLocations;
+ ConfigurationResources = configurationResources;
+ CaseSensitive = caseSensitive;
+ Refresh = DEFAULT_REFRESH;
+ }
+
+
}
}
diff --git a/test/Spring/Spring.Core.Tests/Context/Support/XmlApplicationContentArgsTests.cs b/test/Spring/Spring.Core.Tests/Context/Support/XmlApplicationContentArgsTests.cs
index 6814ea62..92a5d515 100644
--- a/test/Spring/Spring.Core.Tests/Context/Support/XmlApplicationContentArgsTests.cs
+++ b/test/Spring/Spring.Core.Tests/Context/Support/XmlApplicationContentArgsTests.cs
@@ -11,14 +11,14 @@ namespace Spring.Context.Support
[Test]
public void Default_CaseSensitivity_isTrue()
{
- XmlApplicationContextArgs args = new XmlApplicationContextArgs();
+ XmlApplicationContextArgs args = new XmlApplicationContextArgs(string.Empty,null,null,null);
Assert.True(args.CaseSensitive);
}
[Test]
public void Default_AutoRefresh_isTrue()
{
- XmlApplicationContextArgs args = new XmlApplicationContextArgs();
+ XmlApplicationContextArgs args = new XmlApplicationContextArgs(string.Empty, null, null, null);
Assert.True(args.Refresh);
}
}
diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/Config/DictionaryVariableSourceTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/Config/DictionaryVariableSourceTests.cs
index 9906c89c..49fabf26 100644
--- a/test/Spring/Spring.Core.Tests/Objects/Factory/Config/DictionaryVariableSourceTests.cs
+++ b/test/Spring/Spring.Core.Tests/Objects/Factory/Config/DictionaryVariableSourceTests.cs
@@ -70,7 +70,9 @@ namespace Spring.Objects.Factory.Config
[Test]
public void Initialize_WithDictionaryConstructor_AddsCaseInsensitiveKeys()
{
- IDictionary dict = new Hashtable() { { "key1", "value1" }, { "KEY2", "value2" } };
+ IDictionary dict = new Hashtable();
+ dict.Add("key1", "value1");
+ dict.Add("KEY2", "value2");
DictionaryVariableSource dvs = new DictionaryVariableSource(dict);
@@ -81,7 +83,9 @@ namespace Spring.Objects.Factory.Config
[Test]
public void Initialize_WithDictionaryConstructor_AddsKeys()
{
- IDictionary dict = new Hashtable() { { "key1", "value1" }, { "key2", "value2" } };
+ IDictionary dict = new Hashtable();
+ dict.Add("key1", "value1");
+ dict.Add("key2", "value2");
DictionaryVariableSource dvs = new DictionaryVariableSource(dict);
@@ -92,7 +96,9 @@ namespace Spring.Objects.Factory.Config
[Test]
public void Initialize_WithDictionaryConstructorAndCaseSensitiveFlag_AddsCaseSensitiveKeys()
{
- IDictionary dict = new Hashtable() { { "key1", "lowecasevalue" }, { "KEY1", "uppercasevalue" } };
+ IDictionary dict = new Hashtable();
+ dict.Add("key1", "lowecasevalue");
+ dict.Add("KEY1", "uppercasevalue");
DictionaryVariableSource dvs = new DictionaryVariableSource(dict, false);
@@ -111,6 +117,7 @@ namespace Spring.Objects.Factory.Config
Assert.AreEqual("value2", dvs.ResolveVariable("key2"));
}
+#if NET_2_0
[Test]
public void Initialize_WithInlineDictionarySyntax()
{
@@ -120,14 +127,17 @@ namespace Spring.Objects.Factory.Config
Assert.AreEqual("value2", dvs.ResolveVariable("key2"));
}
+#endif
[Test]
public void Requesting_KeyNotFound_ThrowsException()
{
- DictionaryVariableSource dvs = new DictionaryVariableSource();
- dvs.Add("key-found", "value-found");
+ const string THE_KEY = "key-found";
- Assert.Throws(() => dvs.ResolveVariable("key-not-found"));
+ DictionaryVariableSource dvs = new DictionaryVariableSource();
+ dvs.Add(THE_KEY, "value-found");
+
+ Assert.Throws(() => dvs.ResolveVariable("not" + THE_KEY));
}
}
}
diff --git a/test/Spring/Spring.Web.Tests/Context/Support/WebApplicationContextArgsTests.cs b/test/Spring/Spring.Web.Tests/Context/Support/WebApplicationContextArgsTests.cs
index 923b2382..80a69a44 100644
--- a/test/Spring/Spring.Web.Tests/Context/Support/WebApplicationContextArgsTests.cs
+++ b/test/Spring/Spring.Web.Tests/Context/Support/WebApplicationContextArgsTests.cs
@@ -11,7 +11,7 @@ namespace Spring.Context.Support
[Test]
public void Default_CaseSensitivity_isFalse()
{
- WebApplicationContextArgs args = new WebApplicationContextArgs();
+ WebApplicationContextArgs args = new WebApplicationContextArgs(string.Empty, null, null, null);
Assert.False(args.CaseSensitive);
}
}