SPRNET-1124

fixing broken build from inadvertent introduction of .NET 2.0 inline property initializers unsupported by the 1.1 or 2.0 csc.exe compiler used to build those targets
This commit is contained in:
sbohlen
2010-07-28 21:44:18 +00:00
parent 617adb53d6
commit 7b550ff4e4
8 changed files with 200 additions and 41 deletions

View File

@@ -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; }
/// <summary>
/// Initializes a new instance of the AbstractXmlApplicationContextArgs class.
/// </summary>
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;
}
}
}

View File

@@ -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.
/// </param>
public XmlApplicationContext(params string[] configurationLocations)
: this(new XmlApplicationContextArgs() { ConfigurationLocations = configurationLocations })
: this(new XmlApplicationContextArgs(string.Empty, null, configurationLocations, null, true, true))
{ }
/// <summary>
@@ -140,7 +140,7 @@ namespace Spring.Context.Support
/// </param>
public XmlApplicationContext(bool caseSensitive,
params string[] configurationLocations)
: this(new XmlApplicationContextArgs() { CaseSensitive = caseSensitive, ConfigurationLocations = configurationLocations })
: this(new XmlApplicationContextArgs(string.Empty, null, configurationLocations, null, caseSensitive, true))
{ }
/// <summary>
@@ -155,7 +155,7 @@ namespace Spring.Context.Support
/// </param>
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))
{ }
/// <summary>
@@ -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))
{ }
/// <summary>
@@ -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))
{ }
/// <summary>
@@ -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))
{ }
/// <summary>
@@ -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))
{ }

View File

@@ -25,15 +25,52 @@ using Spring.Core.IO;
namespace Spring.Context.Support
{
/// <summary>
/// Encapsulates arguments to the <see cref="Spring.Context.Support.XmlApplicationContext"/> class.
/// </summary>
public class XmlApplicationContextArgs : AbstractXmlApplicationContextArgs
{
private const bool DEFAULT_REFRESH = true;
private const bool DEFAULT_CASESENSITIVE = true;
/// <summary>
/// Initializes a new instance of the <see cref="XmlApplicationContextArgs"/> class.
/// </summary>
public XmlApplicationContextArgs()
: this(string.Empty, null, null, null, DEFAULT_CASESENSITIVE, DEFAULT_REFRESH)
{ }
/// <summary>
/// Initializes a new instance of the <see cref="XmlApplicationContextArgs"/> class.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="parentContext">The parent context.</param>
/// <param name="configurationLocations">The configuration locations.</param>
/// <param name="configurationResources">The configuration resources.</param>
public XmlApplicationContextArgs(string name, IApplicationContext parentContext, string[] configurationLocations, IResource[] configurationResources)
: this(name, parentContext, configurationLocations, configurationResources, DEFAULT_CASESENSITIVE, DEFAULT_REFRESH)
{ }
/// <summary>
/// Initializes a new instance of the XmlApplicationContextArgs class.
/// </summary>
public XmlApplicationContextArgs()
/// <param name="name">The name.</param>
/// <param name="parentContext">The parent context.</param>
/// <param name="configurationLocations">The configuration locations.</param>
/// <param name="configurationResources">The configuration resources.</param>
/// <param name="caseSensitive">if set to <c>true</c> [case sensitive].</param>
/// <param name="refresh">if set to <c>true</c> [refresh].</param>
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;
}
}
}

View File

@@ -68,7 +68,7 @@ namespace Spring.Context.Support
/// </summary>
/// <param name="configurationLocations">Names of configuration resources.</param>
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
/// <param name="caseSensitive">Flag specifying whether to make this context case sensitive or not.</param>
/// <param name="configurationLocations">Names of configuration resources.</param>
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
/// <param name="configurationLocations">Names of configuration resources.</param>
/// <param name="configurationResources">Configuration resources.</param>
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
/// <param name="configurationLocations">Names of configuration resources.</param>
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))
{ }
/// <summary>
/// Initializes a new instance of the <see cref="WebApplicationContext"/> class.
/// </summary>
/// <param name="args">The args.</param>
public WebApplicationContext(WebApplicationContextArgs args)
: base(args.Name, args.CaseSensitive, args.ParentContext)
{
_configurationLocations = args.ConfigurationLocations;
_configurationResources = args.ConfigurationResources;
DefaultResourceProtocol = WebUtils.DEFAULT_RESOURCE_PROTOCOL;
Refresh();

View File

@@ -22,19 +22,57 @@
using System;
using System.Collections.Generic;
using System.Text;
using Spring.Core.IO;
namespace Spring.Context.Support
{
/// <summary>
/// Encapsulates arguments to the <see cref="Spring.Context.Support.WebApplicationContext"/> class.
/// </summary>
public class WebApplicationContextArgs : AbstractXmlApplicationContextArgs
{
private const bool DEFAULT_CASESENSITIVE = false;
private const bool DEFAULT_REFRESH = false;
/// <summary>
/// Initializes a new instance of the WebApplicationContextArgs class.
/// </summary>
public WebApplicationContextArgs()
{
CaseSensitive = false;
CaseSensitive = DEFAULT_CASESENSITIVE;
}
/// <summary>
/// Initializes a new instance of the WebApplicationContextArgs class.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="parentContext">The parent context.</param>
/// <param name="configurationLocations">The configuration locations.</param>
/// <param name="configurationResources">The configuration resources.</param>
public WebApplicationContextArgs(string name, IApplicationContext parentContext, string[] configurationLocations, IResource[] configurationResources)
: this(name, parentContext, configurationLocations, configurationResources, DEFAULT_CASESENSITIVE)
{ }
/// <summary>
/// Initializes a new instance of the WebApplicationContextArgs class.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="parentContext">The parent context.</param>
/// <param name="configurationLocations">The configuration locations.</param>
/// <param name="configurationResources">The configuration resources.</param>
/// <param name="caseSensitive">if set to <c>true</c> [case sensitive].</param>
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;
}
}
}

View File

@@ -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);
}
}

View File

@@ -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<ArgumentException>(() => dvs.ResolveVariable("key-not-found"));
DictionaryVariableSource dvs = new DictionaryVariableSource();
dvs.Add(THE_KEY, "value-found");
Assert.Throws<ArgumentException>(() => dvs.ResolveVariable("not" + THE_KEY));
}
}
}

View File

@@ -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);
}
}