springnet-commits Mailing List for Spring Framework .NET (Page 511)
Brought to you by:
aseovic,
markpollack
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(33) |
Aug
(163) |
Sep
(491) |
Oct
(289) |
Nov
(336) |
Dec
(84) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(227) |
Feb
(413) |
Mar
(128) |
Apr
(232) |
May
(92) |
Jun
(299) |
Jul
(386) |
Aug
(228) |
Sep
(237) |
Oct
(426) |
Nov
(325) |
Dec
(405) |
2006 |
Jan
(315) |
Feb
(311) |
Mar
(152) |
Apr
(177) |
May
(443) |
Jun
(92) |
Jul
(88) |
Aug
(80) |
Sep
(288) |
Oct
(515) |
Nov
(1049) |
Dec
(440) |
2007 |
Jan
(179) |
Feb
(406) |
Mar
(294) |
Apr
(80) |
May
(432) |
Jun
(242) |
Jul
(452) |
Aug
(710) |
Sep
(206) |
Oct
(240) |
Nov
(65) |
Dec
(227) |
2008 |
Jan
(80) |
Feb
(90) |
Mar
(98) |
Apr
(136) |
May
(101) |
Jun
(12) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Choy R. <ch...@us...> - 2004-08-01 09:02:24
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aop/Framework In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17589/src/Spring/Spring.Aop/Aop/Framework Modified Files: ProxyFactory.cs Log Message: Ported the first two test methods of ProxyFactoryTests from Spring.Java. Index: ProxyFactory.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Aop/Aop/Framework/ProxyFactory.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ProxyFactory.cs 15 May 2004 18:01:51 -0000 1.2 --- ProxyFactory.cs 1 Aug 2004 09:02:00 -0000 1.3 *************** *** 40,44 **** /// <param name="target">object to proxy</param> /// <exception cref="AopConfigException">if target is null</exception> ! public ProxyFactory(object target) : base(target.GetType().GetInterfaces()) { Target = target; --- 40,44 ---- /// <param name="target">object to proxy</param> /// <exception cref="AopConfigException">if target is null</exception> ! public ProxyFactory(object target) : base(GetInterfaces(target)) { Target = target; *************** *** 76,79 **** --- 76,94 ---- } + /// <summary> + /// Get interfaces of object. + /// </summary> + /// <param name="target">object to get interfaces of</param> + /// <returns>target</returns> + /// <exception cref="AopConfigException">If target is null</exception> + private static Type[] GetInterfaces(object target) + { + if ( target==null) + { + throw new AopConfigException("Can't proxy null object"); + } + return target.GetType().GetInterfaces(); + } + } } \ No newline at end of file |
From: Choy R. <ch...@us...> - 2004-08-01 09:02:24
|
Update of /cvsroot/springnet/Spring.Net/test/Spring/Spring.Aop.Tests/Aop/Framework In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17589/test/Spring/Spring.Aop.Tests/Aop/Framework Added Files: CountingBeforeAdvice.cs MethodCounter.cs ProxyFactoryTests.cs Log Message: Ported the first two test methods of ProxyFactoryTests from Spring.Java. --- NEW FILE: MethodCounter.cs --- #region License /* * Copyright 2002-2004 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #endregion #region Imports using System; using System.Collections; using System.Reflection; #endregion namespace Spring.Aop.Framework { /// <summary> /// Useful base class for counting advices etc. /// </summary> /// <author>Rod Johnson</author> /// <author>Choy Rim (.NET)</author> /// <version>$Id: MethodCounter.cs,v 1.1 2004/08/01 09:02:08 choyrim Exp $</version> public class MethodCounter { /// <summary>Method name --> count, does not understand overloading </summary> private Hashtable map = new Hashtable(); private int allCount; protected internal virtual void Count(MethodBase m) { Count(m.Name); } protected internal virtual void Count(string methodName) { int count = GetCalls(methodName); ++count; map[methodName] = count; ++allCount; } public virtual int GetCalls(string methodName) { int count = 0; if ( map.ContainsKey(methodName) ) { count = (int) map[methodName]; } return count; } public virtual int GetCalls() { return allCount; } } } --- NEW FILE: CountingBeforeAdvice.cs --- #region License /* * Copyright 2002-2004 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #endregion #region Imports using System; using System.Reflection; using Spring.Aop.Framework; #endregion namespace Spring.Aop.Framework { /// <summary> /// Summary description for CountingBeforeAdvice. /// </summary> public class CountingBeforeAdvice: MethodCounter, IMethodBeforeAdvice { #region IMethodBeforeAdvice Members public void Before(MethodBase method, object[] args, object target) { Count(method); } #endregion } } --- NEW FILE: ProxyFactoryTests.cs --- #region License /* * Copyright 2002-2004 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #endregion #region Imports using System; using System.Collections; using NUnit.Framework; using AopAlliance.Intercept; using Spring.Aop.Interceptor; using Spring.Aop.Support; #endregion namespace Spring.Aop.Framework { /// <summary> /// Unit tests for ProxyFactory. /// </summary> /// <author>Rod Johnson</author> /// <author>Choy Rim (.NET)</author> /// <version>$Id: ProxyFactoryTests.cs,v 1.1 2004/08/01 09:02:08 choyrim Exp $</version> [TestFixture] public class ProxyFactoryTests { [Test] [ExpectedException(typeof(AopConfigException))] public void testNullTarget() { // Use the constructor taking Object new ProxyFactory((System.Object) null); Assert.Fail("Should't allow proxy with null target"); } [Test] public void testIndexOfMethods() { TestObject target = new TestObject(); ProxyFactory pf = new ProxyFactory(target); NopInterceptor nop = new NopInterceptor(); IAdvisor advisor = new DefaultPointcutAdvisor(new CountingBeforeAdvice()); IAdvised advised = (IAdvised) pf.GetProxy(); // Can use advised and ProxyFactory interchangeably advised.AddInterceptor(nop); pf.AddAdvisor(advisor); Assert.AreEqual(- 1, pf.IndexOf((IInterceptor) null)); Assert.AreEqual(- 1, pf.IndexOf(new NopInterceptor())); Assert.AreEqual(0, pf.IndexOf(nop)); Assert.AreEqual(- 1, advised.IndexOf((IAdvisor) null)); Assert.AreEqual(1, pf.IndexOf(advisor)); Assert.AreEqual(- 1, advised.IndexOf(new DefaultPointcutAdvisor(null))); } #region Copied from Spring.Core.Tests // If we try to add reference to Spring.Core.Tests we get circular dependency internal interface INestedTestObject { string Company { get; set; } } internal interface ITestObject { int Age { get; set; } INestedTestObject Doctor { get; } INestedTestObject Lawyer { get; } string Name { get; set; } ITestObject Spouse { get; set; } void Exceptional (Exception t); object ReturnsThis (); //IndexedTestObject getNestedIndexedBean(); } internal class NestedTestObject : INestedTestObject { internal string company = ""; public NestedTestObject() { } public NestedTestObject(string comp) { Company = comp; } virtual public string Company { get { return this.company; } set { this.company = value; } } /* public override bool Equals(System.Object obj) { if (!(obj is NestedTestObject)) { return false; } NestedTestObject ntb = (NestedTestObject) obj; return new EqualsBuilder().append(company, ntb.company).isEquals(); } public override int GetHashCode() { return new HashCodeBuilder(23, 91).append(company).toHashCode(); } */ } internal class TestObject : ITestObject, System.IComparable { virtual public string Touchy { get { return touchy; } set { if (value.IndexOf((System.Char) '.') != - 1) throw new System.Exception("Can't contain a ."); if (value.IndexOf((System.Char) ',') != - 1) throw new System.FormatException("Number format exception: contains a ,"); this.touchy = value; } } virtual public bool PostProcessed { get { return postProcessed; } set { this.postProcessed = value; } } virtual public string Name { get { return name; } set { this.name = value; } } virtual public string Nickname { get { return nickname; } set { this.nickname = value; } } /// <summary>A simple integer age property</summary> virtual public int Age { get { return age; } set { this.age = value; } } /// <summary> /// A simple date property /// </summary> virtual public System.DateTime Date { get { return date; } set { this.date = value; } } virtual public System.Single MyFloat { get { return myFloat; } set { this.myFloat = value; } } virtual public ITestObject Spouse { get { return spouse; } set { this.spouse = value; } } virtual public INestedTestObject Doctor { get { return doctor; } set { this.doctor = value; } } virtual public INestedTestObject Lawyer { get { return lawyer; } set { this.lawyer = value; } } /// <summary> /// A collection of friends. /// </summary> virtual public ICollection Friends { get { return friends; } set { this.friends = value; } } virtual public IDictionary SomeMap { get { return someMap; } set { this.someMap = value; } } [NonSerialized] private bool postProcessed; /// <summary>Holds value of property age. </summary> [NonSerialized] private int age; /// <summary>Holds value of property name. </summary> [NonSerialized] private string name; [NonSerialized] private string nickname; [NonSerialized] private ITestObject spouse; [NonSerialized] private string touchy; [NonSerialized] private System.Collections.ICollection friends = new Spring.Util.LinkedList (); [NonSerialized] private System.Collections.IDictionary someMap = new System.Collections.Hashtable(); [NonSerialized] private System.DateTime date = System.DateTime.Now; [NonSerialized] private System.Single myFloat = (float) 0.0; [NonSerialized] private INestedTestObject doctor = new NestedTestObject(); [NonSerialized] private INestedTestObject lawyer = new NestedTestObject(); public TestObject() { } public TestObject(string name, int age) { this.name = name; this.age = age; } public override bool Equals(object other) { if (other == null || !(other is TestObject)) return false; TestObject tb2 = (TestObject) other; if (tb2.age != age) return false; if ((object) name == null) return (object) tb2.name == null; if (!tb2.name.Equals(name)) return false; return true; } /// <summary> /// The hashcode of the property /// </summary> /// <returns>the hashcode of the property</returns> public override int GetHashCode() { return name.GetHashCode(); } public virtual int CompareTo(object other) { if ((object) this.name != null && other is TestObject) { return String.CompareOrdinal(this.name, ((TestObject) other).name); } else { return 1; } } /// <summary> /// String representation of the class /// </summary> /// <returns>string represention</returns> public override string ToString() { string s = "name=" + name + "; age=" + age + "; touchy=" + touchy; s += ("; spouse={" + (spouse != null?spouse.Name:null) + "}"); return s; } /// <summary> /// Throw the given exception /// </summary> /// <param name="t">An exception to throw.</param> public virtual void Exceptional (Exception t) { if (t != null) { throw t; } } /// <summary> /// Return a reference to the object itself. 'Return this' /// </summary> /// <returns>a reference to the object itse.f</returns> public virtual object ReturnsThis () { return this; } /// <summary> /// Funny Named method. /// </summary> public virtual void Absquatulate () { //System.out.println("IOther.absquatulate"); } } #endregion } } |
From: Choy R. <ch...@us...> - 2004-08-01 09:02:23
|
Update of /cvsroot/springnet/Spring.Net/test/Spring/Spring.Aop.Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17589/test/Spring/Spring.Aop.Tests Modified Files: Spring.Aop.Tests.csproj Log Message: Ported the first two test methods of ProxyFactoryTests from Spring.Java. Index: Spring.Aop.Tests.csproj =================================================================== RCS file: /cvsroot/springnet/Spring.Net/test/Spring/Spring.Aop.Tests/Spring.Aop.Tests.csproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Spring.Aop.Tests.csproj 16 Jul 2004 14:06:17 -0000 1.2 --- Spring.Aop.Tests.csproj 1 Aug 2004 09:02:07 -0000 1.3 *************** *** 79,82 **** --- 79,102 ---- HintPath = "..\..\..\lib\Net\1.1\nunit.framework.dll" /> + <Reference + Name = "System.Data" + AssemblyName = "System.Data" + HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll" + /> + <Reference + Name = "System.XML" + AssemblyName = "System.Xml" + HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" + /> + <Reference + Name = "AopAlliance" + Project = "{3767878B-C181-4940-B1B4-D478143AD068}" + Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" + /> + <Reference + Name = "Spring.Core" + Project = "{710961A3-0DF4-49E4-A26E-F5B9C044AC84}" + Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" + /> </References> </Build> *************** *** 93,96 **** --- 113,136 ---- /> <File + RelPath = "Aop\Framework\CountingBeforeAdvice.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Aop\Framework\MethodCounter.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Aop\Framework\ProxyFactoryTests.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Aop\Interceptor\NopInterceptor.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Aop\Interceptor\SideEffectObject.cs" SubType = "Code" |
From: Choy R. <ch...@us...> - 2004-08-01 07:38:19
|
Update of /cvsroot/springnet/Spring.Net/test/Spring/Spring.Aop.Tests/Aop/Framework In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5365/Framework Log Message: Directory /cvsroot/springnet/Spring.Net/test/Spring/Spring.Aop.Tests/Aop/Framework added to the repository |
From: Choy R. <ch...@us...> - 2004-08-01 07:22:06
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3548/src/Spring/Spring.Core Modified Files: Spring.Core.csproj Log Message: The reference to Spring.Core.IResourceLoader was making the build fail. Index: Spring.Core.csproj =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Spring.Core.csproj,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Spring.Core.csproj 30 Jul 2004 06:07:54 -0000 1.17 --- Spring.Core.csproj 1 Aug 2004 07:21:47 -0000 1.18 *************** *** 1,621 **** ! <VisualStudioProject> ! <CSHARP ! ProjectType = "Local" ! ProductVersion = "7.10.3077" ! SchemaVersion = "2.0" ! ProjectGuid = "{710961A3-0DF4-49E4-A26E-F5B9C044AC84}" ! > ! <Build> ! <Settings ! ApplicationIcon = "" [...1208 lines suppressed...] ! <File ! RelPath = "Util\StringUtils.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Util\TypeAliasResolver.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Util\TypeResolver.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! </Include> ! </Files> ! </CSHARP> ! </VisualStudioProject> ! |
From: Choy R. <ch...@us...> - 2004-08-01 07:21:15
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/TypeConverters In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3469/src/Spring/Spring.Core/Objects/TypeConverters Modified Files: UriConverter.cs Log Message: Extraneous newlines were giving warnings for me Index: UriConverter.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/TypeConverters/UriConverter.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** UriConverter.cs 27 Jul 2004 01:58:02 -0000 1.1 --- UriConverter.cs 1 Aug 2004 07:20:56 -0000 1.2 *************** *** 18,37 **** #endregion - #region Imports using System; using System.ComponentModel; using System.Globalization; #endregion ! ! namespace Spring.Objects.TypeConverters ! { ! /// <summary> ! /// Converter for Uri ! /// </summary> ! /// <author>Juergen Hoeller</author> ! /// <author>Mark Pollack (.NET)</author> ! public class UriConverter : TypeConverter ! { ! #region Constructor (s) / Destructor /// <summary> /// Creates a new instance of the --- 18,26 ---- #endregion #region Imports using System; using System.ComponentModel; using System.Globalization; #endregion ! namespace Spring.Objects.TypeConverters { /// <summary> /// Converter for Uri /// </summary> /// <author>Juergen Hoeller</author> /// <author>Mark Pollack (.NET)</author> public class UriConverter : TypeConverter { #region Constructor (s) / Destructor /// <summary> /// Creates a new instance of the *************** *** 40,44 **** public UriConverter () {} #endregion ! #region Methods /// <summary> --- 29,33 ---- public UriConverter () {} #endregion ! #region Methods /// <summary> |
From: Mark P. <mar...@us...> - 2004-07-30 06:08:03
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Context/Context In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6819/src/Spring/Spring.Context/Context Added Files: ApplicationContextException.cs ApplicationEvent.cs IApplicationContext.cs IApplicationContextAware.cs IConfigurableApplicationContext.cs IHierarchicalMessageSource.cs IMessageSource.cs IMessageSourceResolvable.cs IResourceLoaderAware.cs NoSuchMessageException.cs Log Message: initial port of interfaces of context package. --- NEW FILE: IApplicationContext.cs --- #region Licence /* * Copyright 2002-2004 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #endregion #region Imports using System; using Spring.Objects.Factory; using Spring.Core.IO; #endregion namespace Spring.Context { /// <summary> Central interface to provide configuration for an application. /// This is read-only while the application is running, but may be /// reloaded if the implementation supports this. /// </summary> /// /// <remarks> /// <p>An ApplicationContext provides: /// <ul> /// <li>Bean factory methods, inherited from ListableBeanFactory. /// This avoids the need for applications to use singletons. /// </li> /// <li>The ability to resolve messages, supporting internationalization. /// Inherited from the MessageSource interface. /// </li> /// <li>The ability to load file resources in a generic fashion. /// Inherited from the ResourceLoader interface. /// </li> /// <li>The ability to publish events. Implementations must provide a means /// of registering event listeners. /// </li> /// <li>Inheritance from a parent context. Definitions in a descendant context /// will always take priority. This means, for example, that a single parent /// context can be used by an entire web application, while each servlet has /// its own child context that is independent of that of any other servlet. /// </li> /// </ul> /// </p> /// /// <p>In addition to standard bean factory lifecycle capabilities, /// ApplicationContext implementations need to detect ApplicationContextAware /// beans and invoke the setApplicationContext method accordingly. /// <see cref="Spring.Context.ApplicationContextAware"/> /// </p> /// </remarks> /// /// <author>Rod Johnson</author> /// <author>Juergen Hoeller</author> /// <author>Mark Pollack (.NET)</author> public interface IApplicationContext : IListableObjectFactory, IHierarchicalObjectFactory, IMessageSource, IResourceLoader { /// <summary> Return the timestamp when this context was first loaded.</summary> /// <returns> the timestamp (ms) when this context was first loaded /// </returns> long StartupDate { get; } /// <summary> Return the parent context, or null if there is no parent, /// and this is the root of the context hierarchy. /// </summary> /// <returns> the parent context, or null if there is no parent /// </returns> IApplicationContext GetParent(); /// <summary> Return a friendly name for this context.</summary> /// <returns> a display name for this context /// </returns> string GetDisplayName(); /// <summary> Notify all listeners registered with this application of an application /// event. Events may be framework events (such as RequestHandledEvent) /// or application-specific events. /// </summary> /// <param name="event">event to publish /// </param> void OnApplicationEvent(ApplicationEvent appEvent); } } --- NEW FILE: IConfigurableApplicationContext.cs --- #region Licence /* * Copyright 2002-2004 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #endregion using Spring.Objects.Factory.Config; using System; namespace Spring.Context { /// <summary>SPI interface to be implemented by most if not all application contexts. /// </summary> /// /// <remarks> /// <p>Provides means to configure an application context in addition to the /// application context client methods in the ApplicationContext interface.</p> /// /// <p>Configuration and lifecycle methods are encapsulated here to avoid /// making them obvious to ApplicationContext client code.</p> /// /// </remarks> /// <author>Juergen Hoeller</author> /// <author>Mark Pollack (.NET)</author> public interface IConfigurableApplicationContext : IApplicationContext { /// <summary> Return the internal object factory of this application context. /// </summary> /// <remarks> /// Can be used to access specific functionality of the factory. /// <p>Note that this is just guaranteed to return a non-null instance /// <i>after</i> the context has been refreshed at least once. /// </p> /// <p>Note: Do not use this to post-process the object factory; singletons /// will already have been instantiated before. Use a IObjectFactoryPostProcessor /// to intercept the object factory setup process before beans get touched. /// </p> /// </remarks> IConfigurableListableObjectFactory ObjectFactory { get; } /// <summary> Set the parent of this application context.</summary> /// <remarks> /// <p>Note that the parent shouldn't be changed: It should only be set outside /// a constructor if it isn't available when an object of this class is created, /// for example in case of WebApplicationContext setup.</p> /// </remarks> /// <param name="parent">The parent context /// </param> void SetParent(IApplicationContext parent); /// <summary> Add a new BeanFactoryPostProcessor that will get applied to the internal /// object factory of this application context on refresh, before any of the /// bean definitions get evaluated. To be invoked during context configuration. /// </summary> /// <param name="objectFactoryPostProcessor">the factory processor to register /// </param> void AddObjectFactoryPostProcessor(IObjectFactoryPostProcessor objectFactoryPostProcessor); /// <summary> Load or refresh the persistent representation of the configuration, /// which might an XML file, properties file, or relational database schema. /// </summary> /// <exception cref="Spring.Context.ApplicationContextException">if the config cannot be loaded /// </exception> /// <exception cref="Spring.Objects.ObjectsException">if the bean factory could not be initialized /// </exception> void Refresh(); /// <summary> Close this application context, releasing all resources and locks that the /// implementation might hold. /// </summary> /// <remarks> /// This includes disposing all cached singleton objects. /// <p>Note: Does <i>not</i> invoke close on a parent context.</p> /// </remarks> /// <exception cref="Spring.Context.ApplicationContextException"> /// if there were fatal errors /// </exception> void Close(); } } --- NEW FILE: IMessageSource.cs --- #region Licence /* * Copyright 2002-2004 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #endregion using System; namespace Spring.Context { /// <summary> Interface to be implemented by objects that can resolve messages. /// This enables parameterization and internationalization of messages. /// </summary> /// /// <remarks> /// <p>Spring provides one out-of-the-box implementations for production: /// <ul> /// <li><b>ResourceManagerMessageSource</b>, built on standard ResourceManager</li> /// </ul> /// </p> /// </remarks> /// /// <author>Rod Johnson</author> /// <author>Juergen Hoeller</author> /// <author>Mark Pollack (.NET)</author> public interface IMessageSource { /// <summary> Try to resolve the message. Return default message if no message was found.</summary> /// /// <param name="name">The name of the resource to get. This is typically /// a sort of "fully qualified name" meaning projectname.namespace.resourcefile-basename /// For example a project name "MyApp" with a resource files named res.resx in the /// MyWinforms namespace would be "MyApp.MyWinforms.res" /// </param> /// <param name="args">The array of arguments that will be filled in for params within /// the message (params look like "{0}", "{1,date}", "{2,time}" within a message), /// or null if none. /// </param> /// <param name="culture">The Cultureinfo object that represents the culture /// for which the resource is localized. /// </param> /// <param name="defaultMessage">String to return if the lookup fails /// </param> /// <returns>the resolved message if the lookup was successful; /// otherwise the default message passed as a parameter /// </returns> string GetMessage(string name, object[] args, string defaultMessage, System.Globalization.CultureInfo locale); /// <summary> Try to resolve the message. Treat as an error if the message can't be found.</summary> /// <param name="name">The name of the resource to get. This is typically /// a sort of "fully qualified name" meaning projectname.namespace.resourcefile-basename /// For example a project name "MyApp" with a resource files named res.resx in the /// MyWinforms namespace would be "MyApp.MyWinforms.res" /// </param> /// <param name="args">Array of arguments that will be filled in for params within /// the message (params look like "{0}", "{1,date}", "{2,time}" within a message), /// or null if none. /// </param> /// <param name="culture">The Cultureinfo object that represents the culture /// for which the resource is localized. /// </param> /// <returns>The resolved message /// </returns> /// <exception cref="Spring.Context.NoSuchMessageException"> /// if the message wasn't found /// </exception> string GetMessage(string code, object[] args, System.Globalization.CultureInfo locale); /// <summary> Try to resolve the message using all the attributes contained within the /// IMessageSourceResolvable argument that was passed in. /// </summary> /// <remarks> /// <p>NOTE: We must throw a NoSuchMessageException on this method /// since at the time of calling this method we aren't able to determine if the /// <code>defaultMessage</code> property of the resolvable is null or not. /// </p> /// </remarks> /// <param name="resolvable">value object storing attributes required to properly resolve a message /// </param> /// <param name="culture">The CultureInfo object that represents the culture /// for which the resource is localized. /// <returns>The resolved message /// </returns> /// <exception cref="Spring.Context.NoSuchMessageException"> /// if the message wasn't found /// </exception> string GetMessage(IMessageSourceResolvable resolvable, System.Globalization.CultureInfo locale); } } --- NEW FILE: IMessageSourceResolvable.cs --- #region Licence /* * Copyright 2002-2004 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #endregion using System; namespace Spring.Context { /// <summary> Interface for objects that are suitable for message resolution in a /// MessageSource. Spring's own validation error classes implement this /// interface. /// </summary> /// <author>Juergen Hoeller</author> /// <author>Mark Pollack (.NET)</author> public interface IMessageSourceResolvable { /// <summary> Return the codes to be used to resolve this message, in the order that /// they should get tried. The last code will therefore be the default one. /// </summary> /// <returns> A String array of codes which are associated with this message /// </returns> string[] Codes { get; } /// <summary> Return the array of arguments to be used to resolve this message.</summary> /// <returns> an array of objects to be used as parameters to replace /// placeholders within the message text /// </returns> object[] Arguments { get; } /// <summary> Return the default message to be used to resolve this message.</summary> /// <returns> the default message, or null if no default /// </returns> string DefaultMessage { get; } } } --- NEW FILE: IResourceLoaderAware.cs --- #region Licence /* * Copyright 2002-2004 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #endregion #region Imports using Spring.Core.IO; using System; #endregion namespace Spring.Context { /// <summary> Interface to be implemented by any object that wishes to be notified /// of the ResourceLoader (typically the ApplicationContext) that it runs in. /// </summary> /// /// <remarks> /// <p>Note that Resource dependencies can also be exposed as bean properties /// of type Resource, populated via Strings with automatic type conversion by /// the bean factory. This removes the need for implementing any callback /// interface just for the purpose of accessing a specific file resource. /// </p> /// /// /// <p>You typically need a ResourceLoader when your application object has /// to access a variety of file resources whose names are calculated. A good /// strategy is to make the object use a DefaultResourceLoader but still /// implement ResourceLoaderAware to allow for overriding when running in an /// IApplicationContext. See ReloadableResourceBundleMessageSource for an example. /// </p> /// /// </remarks> /// <author>Juergen Hoeller</author> /// <author>Mark Pollack (.NET)</author> /// <see cref="Spring.Context.IApplicationContextAware"/> /// <see cref="Spring.Objects.Factory.IInitializingBean"/> /* /// <see cref="org.springframework.core.io.DefaultResourceLoader"> /// </seealso> /// <seealso cref="org.springframework.context.support.ReloadableResourceBundleMessageSource"> /// </seealso> */ public interface IResourceLoaderAware { /// <summary> Set the ResourceLoader that this object runs in.</summary> /// <remarks> /// <p>Invoked after population of normal objects properties but before an init /// callback like InitializingObjects's afterPropertiesSet or a custom init-method. /// Invoked before ApplicationContextAware's setApplicationContext.</p> /// </remarks> /// <param name="resourceLoader">ResourceLoader object to be used by this object /// </param> IResourceLoader ResourceLoader { set; } } } --- NEW FILE: IHierarchicalMessageSource.cs --- #region Licence /* * Copyright 2002-2004 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #endregion using System; namespace Spring.Context { /// <summary>Sub-interface of MessageSource to be implemented by objects that /// can resolve messages hierarchically. /// </summary> /// <author>Rod Johnson</author> /// <author>Juergen Hoeller</author> /// <author>Mark Pollack (.NET)</author> public interface IHierarchicalMessageSource { /// <summary> /// The parent message source used to try and resolve /// messages that ths object can't resolve. If null no further /// resolution is possible. /// </summary> IMessageSource ParentMessageSource { get; set; } } } --- NEW FILE: NoSuchMessageException.cs --- #region Licence /* * Copyright 2002-2004 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #endregion using System.Globalization; using System; namespace Spring.Context { /// <summary> Exception thrown when a message can't be resolved.</summary> /// <author>Rod Johnson</author> /// <author>Mark Pollack (.NET)</author> [Serializable] public class NoSuchMessageException : SystemException { /// <summary> Create a new exception.</summary> /// <param name="code">code that could not be resolved for given Culture /// </param> /// <param name="culture">The CultureInfo that was used to search for the code within /// </param> public NoSuchMessageException(string code, CultureInfo locale):base("No message found under code '" + code + "' for locale '" + locale + "'.") { } /// <summary> Create a new exception.</summary> /// <param name="code">code that could not be resolved for given locale /// </param> //UPGRADE_TODO: Method 'java.util.Locale.getDefault' was converted to 'System.Threading.Thread.CurrentThread.CurrentCulture' which has a different behavior. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1073_3"' public NoSuchMessageException(System.String code):base("No message found under code '" + code + "' for locale '" + System.Threading.Thread.CurrentThread.CurrentCulture + "'.") { } } } --- NEW FILE: ApplicationEvent.cs --- #region Licence /* * Copyright 2002-2004 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #endregion using System; namespace Spring.Context { /// <summary> Class to be extended by all application events.</summary> /// /// <remarks> /// Abstract as it doesn't make sense for generic events /// to be published directly. /// </remarks> /// <author>Rod Johnson</author> /// <author>Mark Pollack (.NET)</author> [Serializable] public abstract class ApplicationEvent : System.EventArgs { /// <summary> Return the system time in milliseconds when the event happened.</summary> /// <returns> The system time in milliseconds when the event happened /// </returns> virtual public long Timestamp { get { return timestamp; } } /// <summary>System time when the event happened </summary> private long timestamp; /// <summary> Creates a new ApplicationEvent.</summary> /// <param name="source">component that published the event /// </param> public ApplicationEvent(System.Object source) : base() { timestamp = (System.DateTime.Now.Ticks - 621355968000000000) / 10000; } } } --- NEW FILE: ApplicationContextException.cs --- #region Licence /* * Copyright 2002-2004 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #endregion using Spring.Objects; using System; namespace Spring.Context { /// <summary> Exception thrown during application context initialization.</summary> /// <author>Rod Johnson</author> /// <author>Mark Pollack (.NET)</author> [Serializable] public class ApplicationContextException : FatalObjectException { /// <summary> Constructs an ApplicationContextException /// with the specified detail message and no root cause. /// </summary> /// <param name="msg">the detail message /// </param> public ApplicationContextException(string msg) : base(msg) { } /// <summary> Constructs an ApplicationContextException /// with the specified detail message and the given root cause. /// </summary> /// <param name="msg">the detail message /// </param> public ApplicationContextException(string msg, Exception ex) : base(msg, ex) { } } } --- NEW FILE: IApplicationContextAware.cs --- #region Licence /* * Copyright 2002-2004 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #endregion using System; namespace Spring.Context { /// <summary> Interface to be implemented by any object that wishes to be notified /// of the ApplicationContext that it runs in. /// </summary> /// /// <remarks> /// <p>Implementing this interface makes sense for example when an object /// requires access to a set of collaborating object. Note that configuration /// via object references is preferable to implementing this interface just /// for object lookup purposes.</p> /// /// <p>This interface can also be implemented if an object needs access to file /// resources, i.e. wants to call getResource, or access to the MessageSource. /// However, it is preferable to implement the more specific ResourceLoaderAware /// interface respectively receive a reference to the MessageSource bean in that /// scenario.</p> /// /// <p>Note that Resource dependencies can also be exposed as object properties /// of type Resource, populated via Strings with automatic type conversion by /// the bean factory. This removes the need for implementing any callback /// interface just for the purpose of accessing a specific file resource.</p> /// /// <p>ApplicationObjectSupport is a convenience base class for /// application objects, implementing this interface.</p> /// /// <p>For a list of all object lifecycle methods, see the ObjectFactory.</p> /// /// </remarks> /// <author>Rod Johnson</author> /// <author>Mark Pollack (.NET)</author> /// <see cref="Spring.Context.ResourceLoaderAware"/> /// <!-- <see cref="Spring.Context.Support.ApplicationObjectSupport"/> --> /// <see cref="Spring.Objects.Factory.IObjectFactoryAware"/> /// <see cref="Spring.Objects.Factory.IInitializingBean"/> /// <see cref="Spring.Objects.Factory.IObjectFactory"/> public interface IApplicationContextAware { /// <summary> Set the ApplicationContext that this object runs in.</summary> /// <remarks> /// Normally this call will be used to initialize the object. /// <p>Invoked after population of normal bean properties but before an init /// callback like InitializingBean's afterPropertiesSet or a custom init-method. /// Invoked after ResourceLoaderAware's setResourceLoader.</p> /// </remarks> /// <param name="applicationContext">IApplicationContext object to be used by this object /// </param> /// <exception cref="Spring.Context.ApplicationContextException"> /// in case of applicationContext initialization errors /// </exception> /// <exception cref="Spring.Objects.ObjectsException"> /// if thrown by application applicationContext methods. /// </exception> /// <exception cref="Spring.Objects.Factory.ObjectInitializationException"/> void SetApplicationContext(IApplicationContext applicationContext); } } |
From: Mark P. <mar...@us...> - 2004-07-30 06:08:03
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Context In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6819/src/Spring/Spring.Context Modified Files: AssemblyInfo.cs Spring.Context.csproj Log Message: initial port of interfaces of context package. Index: Spring.Context.csproj =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Context/Spring.Context.csproj,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Spring.Context.csproj 29 Apr 2004 00:46:34 -0000 1.1.1.1 --- Spring.Context.csproj 30 Jul 2004 06:07:54 -0000 1.2 *************** *** 1,88 **** ! <VisualStudioProject> ! <CSHARP ! ProjectType = "Local" ! ProductVersion = "7.10.3077" ! SchemaVersion = "2.0" ! ProjectGuid = "{8FD33592-3C87-46DD-9516-B435E8268554}" ! > ! <Build> ! <Settings ! ApplicationIcon = "" ! AssemblyKeyContainerName = "" ! AssemblyName = "Spring.Context" ! AssemblyOriginatorKeyFile = "" ! DefaultClientScript = "JScript" ! DefaultHTMLPageLayout = "Grid" ! DefaultTargetSchema = "IE50" ! DelaySign = "false" ! OutputType = "Library" ! PreBuildEvent = "" ! PostBuildEvent = "" ! RootNamespace = "Spring" ! RunPostBuildEvent = "OnBuildSuccess" ! StartupObject = "" ! > ! <Config ! Name = "Debug" ! AllowUnsafeBlocks = "false" ! BaseAddress = "285212672" ! CheckForOverflowUnderflow = "false" ! ConfigurationOverrideFile = "" ! DefineConstants = "DEBUG;TRACE" ! DocumentationFile = "" ! DebugSymbols = "true" ! FileAlignment = "4096" ! IncrementalBuild = "false" ! NoStdLib = "false" ! NoWarn = "" ! Optimize = "false" ! OutputPath = "..\..\..\build\VS.Net\Debug\" ! RegisterForComInterop = "false" ! RemoveIntegerChecks = "false" ! TreatWarningsAsErrors = "false" ! WarningLevel = "4" ! /> ! <Config ! Name = "Release" ! AllowUnsafeBlocks = "false" ! BaseAddress = "285212672" ! CheckForOverflowUnderflow = "false" ! ConfigurationOverrideFile = "" ! DefineConstants = "TRACE" ! DocumentationFile = "" ! DebugSymbols = "false" ! FileAlignment = "4096" ! IncrementalBuild = "false" ! NoStdLib = "false" ! NoWarn = "" ! Optimize = "true" ! OutputPath = "..\..\..\build\VS.Net\Release\" ! RegisterForComInterop = "false" ! RemoveIntegerChecks = "false" ! TreatWarningsAsErrors = "false" ! WarningLevel = "4" ! /> ! </Settings> ! <References> ! <Reference ! Name = "System" ! AssemblyName = "System" ! /> ! </References> ! </Build> ! <Files> ! <Include> ! <File ! RelPath = "AssemblyInfo.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Spring.Context.build" ! BuildAction = "None" ! /> ! </Include> ! </Files> ! </CSHARP> ! </VisualStudioProject> ! --- 1,153 ---- ! <VisualStudioProject> ! <CSHARP ! ProjectType = "Local" ! ProductVersion = "7.10.3077" ! SchemaVersion = "2.0" ! ProjectGuid = "{8FD33592-3C87-46DD-9516-B435E8268554}" ! > ! <Build> ! <Settings ! ApplicationIcon = "" ! AssemblyKeyContainerName = "" ! AssemblyName = "Spring.Context" ! AssemblyOriginatorKeyFile = "" ! DefaultClientScript = "JScript" ! DefaultHTMLPageLayout = "Grid" ! DefaultTargetSchema = "IE50" ! DelaySign = "false" ! OutputType = "Library" ! PreBuildEvent = "" ! PostBuildEvent = "" ! RootNamespace = "Spring" ! RunPostBuildEvent = "OnBuildSuccess" ! StartupObject = "" ! > ! <Config ! Name = "Debug" ! AllowUnsafeBlocks = "false" ! BaseAddress = "285212672" ! CheckForOverflowUnderflow = "false" ! ConfigurationOverrideFile = "" ! DefineConstants = "DEBUG;TRACE" ! DocumentationFile = "" ! DebugSymbols = "true" ! FileAlignment = "4096" ! IncrementalBuild = "false" ! NoStdLib = "false" ! NoWarn = "" ! Optimize = "false" ! OutputPath = "..\..\..\build\VS.Net\Debug\" ! RegisterForComInterop = "false" ! RemoveIntegerChecks = "false" ! TreatWarningsAsErrors = "false" ! WarningLevel = "4" ! /> ! <Config ! Name = "Release" ! AllowUnsafeBlocks = "false" ! BaseAddress = "285212672" ! CheckForOverflowUnderflow = "false" ! ConfigurationOverrideFile = "" ! DefineConstants = "TRACE" ! DocumentationFile = "" ! DebugSymbols = "false" ! FileAlignment = "4096" ! IncrementalBuild = "false" ! NoStdLib = "false" ! NoWarn = "" ! Optimize = "true" ! OutputPath = "..\..\..\build\VS.Net\Release\" ! RegisterForComInterop = "false" ! RemoveIntegerChecks = "false" ! TreatWarningsAsErrors = "false" ! WarningLevel = "4" ! /> ! </Settings> ! <References> ! <Reference ! Name = "System" ! AssemblyName = "System" ! /> ! <Reference ! Name = "System.Data" ! AssemblyName = "System.Data" ! HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll" ! /> ! <Reference ! Name = "System.XML" ! AssemblyName = "System.XML" ! HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" ! /> ! <Reference ! Name = "Spring.Core" ! Project = "{710961A3-0DF4-49E4-A26E-F5B9C044AC84}" ! Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" ! /> ! </References> ! </Build> ! <Files> ! <Include> ! <File ! RelPath = "AssemblyInfo.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Spring.Context.build" ! BuildAction = "None" ! /> ! <File ! RelPath = "Context\ApplicationContextException.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Context\ApplicationEvent.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Context\IApplicationContext.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Context\IApplicationContextAware.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Context\IConfigurableApplicationContext.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Context\IHierarchicalMessageSource.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Context\IMessageSource.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Context\IMessageSourceResolvable.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Context\IResourceLoaderAware.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Context\NoSuchMessageException.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! </Include> ! </Files> ! </CSHARP> ! </VisualStudioProject> ! Index: AssemblyInfo.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Context/AssemblyInfo.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** AssemblyInfo.cs 29 Apr 2004 00:46:34 -0000 1.1.1.1 --- AssemblyInfo.cs 30 Jul 2004 06:07:54 -0000 1.2 *************** *** 1,5 **** ! using System.Reflection; ! using System.Runtime.CompilerServices; ! ! [assembly: AssemblyTitle("Spring.Net Context functionality")] ! [assembly: AssemblyDescription("ApplicationContext functionality for Spring.Net IoC container")] --- 1,5 ---- ! using System.Reflection; ! using System.Runtime.CompilerServices; ! ! [assembly: AssemblyTitle("Spring.Net Context functionality")] ! [assembly: AssemblyDescription("This package builds on the object package to add support for message sources and for the Observer design pattern, and the ability for application objects to obtain resources using a consistent API.")] |
From: Mark P. <mar...@us...> - 2004-07-30 06:08:03
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6819/src/Spring/Spring.Core Modified Files: Spring.Core.csproj Log Message: initial port of interfaces of context package. Index: Spring.Core.csproj =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Spring.Core.csproj,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Spring.Core.csproj 27 Jul 2004 01:58:01 -0000 1.16 --- Spring.Core.csproj 30 Jul 2004 06:07:54 -0000 1.17 *************** *** 148,151 **** --- 148,156 ---- /> <File + RelPath = "Core\IO\IResourceLoader.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Objects\FatalObjectException.cs" SubType = "Code" |
From: Mark P. <mar...@us...> - 2004-07-30 06:06:33
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Context/Context In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6597/Context Log Message: Directory /cvsroot/springnet/Spring.Net/src/Spring/Spring.Context/Context added to the repository |
From: Mark P. <mar...@us...> - 2004-07-27 01:58:11
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/TypeConverters In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2633/src/Spring/Spring.Core/Objects/TypeConverters Added Files: UriConverter.cs Log Message: add support for string to uri conversion --- NEW FILE: UriConverter.cs --- #region Licence /* * Copyright 2002-2004 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #endregion #region Imports using System; using System.ComponentModel; using System.Globalization; #endregion namespace Spring.Objects.TypeConverters { /// <summary> /// Converter for Uri /// </summary> /// <author>Juergen Hoeller</author> /// <author>Mark Pollack (.NET)</author> public class UriConverter : TypeConverter { #region Constructor (s) / Destructor /// <summary> /// Creates a new instance of the /// <see cref="Spring.Objects.TypeConverters.UriConverter"/> class. /// </summary> public UriConverter () {} #endregion #region Methods /// <summary> /// Returns whether this converter can convert an object of one /// <see cref="System.Type"/> to a <see cref="System.Uri"/> /// </summary> /// <remarks> /// <p> /// Currently only supports conversion from a /// <see cref="System.String"/> instance. /// </p> /// </remarks> /// <param name="context"> /// A <see cref="System.ComponentModel.ITypeDescriptorContext"/> /// that provides a format context. /// </param> /// <param name="sourceType"> /// A <see cref="System.Type"/> that represents the /// <see cref="System.Type"/> you want to convert from. /// </param> /// <returns>True if the conversion is possible.</returns> public override bool CanConvertFrom ( ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof (string)) { return true; } return base.CanConvertFrom (context, sourceType); } /// <summary> /// Convert from a string value to a <see cref="System.Uri"/> instance. /// </summary> /// <param name="context"> /// A <see cref="System.ComponentModel.ITypeDescriptorContext"/> /// that provides a format context. /// </param> /// <param name="culture"> /// The <see cref="System.Globalization.CultureInfo"/> to use /// as the current culture. /// </param> /// <param name="value"> /// The value that is to be converted. /// </param> /// <returns> /// A <see cref="System.Uri"/> if successful. /// </returns> public override object ConvertFrom ( ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { try { return new Uri(value as string); } catch (System.UriFormatException ex) { throw new System.ArgumentException("Malformed URL: ", ex); } } return base.ConvertFrom (context, culture, value); } #endregion } } |
From: Mark P. <mar...@us...> - 2004-07-27 01:58:11
|
Update of /cvsroot/springnet/Spring.Net/test/Spring/Spring.Core.Tests/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2633/test/Spring/Spring.Core.Tests/Objects Modified Files: ObjectWrapperTestSuite.cs Log Message: add support for string to uri conversion Index: ObjectWrapperTestSuite.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/test/Spring/Spring.Core.Tests/Objects/ObjectWrapperTestSuite.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** ObjectWrapperTestSuite.cs 26 Jul 2004 07:42:53 -0000 1.19 --- ObjectWrapperTestSuite.cs 27 Jul 2004 01:58:01 -0000 1.20 *************** *** 417,420 **** --- 417,443 ---- Assert.IsTrue(pt.stringArray[0].Equals("foo") && pt.stringArray[1].Equals("fi") && pt.stringArray[2].Equals("fi") && pt.stringArray[3].Equals("fum"), "in correct values of string array"); } + #region Tests for URI Properties + + internal class URITestObject + { + private Uri _uri; + public Uri ResourceIdentifier + { + get { return _uri; } + set { _uri = value; } + } + } + + [Test] + public void SetURIProperty() + { + URITestObject o = new URITestObject(); + ObjectWrapper ow = new ObjectWrapper(o); + + ow.SetPropertyValue("ResourceIdentifier", "http://www.springframework.net"); + Assert.AreEqual("www.springframework.net", o.ResourceIdentifier.Host); + } + #endregion + #region Tests for Indexed Array Properties |
From: Mark P. <mar...@us...> - 2004-07-27 01:58:11
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2633/src/Spring/Spring.Core Modified Files: Spring.Core.csproj Log Message: add support for string to uri conversion Index: Spring.Core.csproj =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Spring.Core.csproj,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Spring.Core.csproj 26 Jul 2004 07:47:54 -0000 1.15 --- Spring.Core.csproj 27 Jul 2004 01:58:01 -0000 1.16 *************** *** 1,611 **** ! <VisualStudioProject> ! <CSHARP ! ProjectType = "Local" ! ProductVersion = "7.10.3077" ! SchemaVersion = "2.0" ! ProjectGuid = "{710961A3-0DF4-49E4-A26E-F5B9C044AC84}" ! > ! <Build> ! <Settings ! ApplicationIcon = "" [...1198 lines suppressed...] ! <File ! RelPath = "Util\StringUtils.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Util\TypeAliasResolver.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Util\TypeResolver.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! </Include> ! </Files> ! </CSHARP> ! </VisualStudioProject> ! |
From: Mark P. <mar...@us...> - 2004-07-27 01:58:10
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2633/src/Spring/Spring.Core/Objects Modified Files: ObjectWrapper.cs Log Message: add support for string to uri conversion Index: ObjectWrapper.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/ObjectWrapper.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** ObjectWrapper.cs 26 Jul 2004 07:47:55 -0000 1.20 --- ObjectWrapper.cs 27 Jul 2004 01:58:01 -0000 1.21 *************** *** 169,172 **** --- 169,173 ---- _defaultConverters [typeof (string [])] = new StringArrayConverter (); _defaultConverters [typeof (Type)] = new RuntimeTypeConverter (); + _defaultConverters [typeof (Uri)] = new UriConverter (); } #endregion |
From: Springboy <spr...@us...> - 2004-07-26 08:07:51
|
Update of /cvsroot/springnet/Spring.Net/test/Spring/Spring.Core.Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21084 Modified Files: Spring.Core.Tests.csproj Log Message: NAntAddin? NUnitAddin now picks up config file. Index: Spring.Core.Tests.csproj =================================================================== RCS file: /cvsroot/springnet/Spring.Net/test/Spring/Spring.Core.Tests/Spring.Core.Tests.csproj,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Spring.Core.Tests.csproj 26 Jul 2004 08:03:13 -0000 1.17 --- Spring.Core.Tests.csproj 26 Jul 2004 08:07:41 -0000 1.18 *************** *** 18,22 **** OutputType = "Library" PreBuildEvent = "" ! PostBuildEvent = 'echo "Copying .xml files for tests"
xcopy $(ProjectDir)Data ..\..\..\..\build\VS.Net\Spring.Core.Tests\Debug\ /y /s /q' RootNamespace = "Spring" RunPostBuildEvent = "OnOutputUpdated" --- 18,22 ---- OutputType = "Library" PreBuildEvent = "" ! PostBuildEvent = 'echo "Copying .xml files for tests"
xcopy $(ProjectDir)Data ..\..\..\..\build\VS.Net\Spring.Core.Tests\Debug\ /y /s /q
xcopy $(ProjectDir)$(TargetFileName).config ..\..\..\..\build\VS.Net\Spring.Core.Tests\Debug\ /y /s /q' RootNamespace = "Spring" RunPostBuildEvent = "OnOutputUpdated" |
From: Springboy <spr...@us...> - 2004-07-26 08:03:21
|
Update of /cvsroot/springnet/Spring.Net/test/Spring/Spring.Core.Tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20591 Modified Files: Spring.Core.Tests.csproj Log Message: NAntAddin doesnt support config file yet... modded xcopy. Index: Spring.Core.Tests.csproj =================================================================== RCS file: /cvsroot/springnet/Spring.Net/test/Spring/Spring.Core.Tests/Spring.Core.Tests.csproj,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Spring.Core.Tests.csproj 26 Jul 2004 07:42:53 -0000 1.16 --- Spring.Core.Tests.csproj 26 Jul 2004 08:03:13 -0000 1.17 *************** *** 18,24 **** OutputType = "Library" PreBuildEvent = "" ! PostBuildEvent = "" RootNamespace = "Spring" ! RunPostBuildEvent = "OnBuildSuccess" StartupObject = "" > --- 18,24 ---- OutputType = "Library" PreBuildEvent = "" ! PostBuildEvent = 'echo "Copying .xml files for tests"
xcopy $(ProjectDir)Data ..\..\..\..\build\VS.Net\Spring.Core.Tests\Debug\ /y /s /q' RootNamespace = "Spring" ! RunPostBuildEvent = "OnOutputUpdated" StartupObject = "" > *************** *** 422,423 **** --- 422,424 ---- </CSHARP> </VisualStudioProject> + |
From: Springboy <spr...@us...> - 2004-07-26 07:48:37
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18183/Spring/Spring.Core/Objects Modified Files: FatalObjectException.cs IObjectWrapper.cs MutablePropertyValues.cs NotWritablePropertyException.cs ObjectUtils.cs ObjectWrapper.cs ObjectsException.cs PropertyChangeEventArgs.cs PropertyValue.cs TypeMismatchException.cs Log Message: Added centralised Type resolution mechanism, runtime type converter, Xml Config handler, multiple documentation updates. Index: FatalObjectException.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/FatalObjectException.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FatalObjectException.cs 3 May 2004 10:26:28 -0000 1.2 --- FatalObjectException.cs 26 Jul 2004 07:47:55 -0000 1.3 *************** *** 18,23 **** namespace Spring.Objects { ! /// <summary> Thrown on an unrecoverable problem encountered in the ! /// beans packages or sub-packages, e.g. bad class or field. /// </summary> /// <author>Rod Johnson</author> --- 18,24 ---- namespace Spring.Objects { ! /// <summary> ! /// Thrown on an unrecoverable problem encountered in the ! /// objects namespace or sub-namespaces, e.g. bad class or field. /// </summary> /// <author>Rod Johnson</author> Index: PropertyValue.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/PropertyValue.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PropertyValue.cs 3 May 2004 10:26:28 -0000 1.1 --- PropertyValue.cs 26 Jul 2004 07:47:55 -0000 1.2 *************** *** 14,32 **** * limitations under the License. */ using System; namespace Spring.Objects { ! /// <summary> Class to hold information and value for an individual property. /// Using an object here, rather than just storing all properties in a /// map keyed by property name, allows for more flexibility, and the /// ability to handle indexed properties etc in a special way if necessary. - /// - /// <p>Note that the value doesn't need to be the final required type: - /// A ObjectWrapper implementation should handle any necessary conversion, as - /// this object doesn't know anything about the objects it will be applied to. /// </p> ! /// ! /// </summary> /// <author>Rod Johnson</author> /// <author>Mark Pollack (.NET)</author> --- 14,39 ---- * limitations under the License. */ + using System; + namespace Spring.Objects { ! /// <summary> ! /// Class to hold information and value for an individual property. ! /// </summary> ! /// <remarks> ! /// <p> /// Using an object here, rather than just storing all properties in a /// map keyed by property name, allows for more flexibility, and the /// ability to handle indexed properties etc in a special way if necessary. /// </p> ! /// <p> ! /// Note that the value doesn't need to be the final required type: ! /// A <see cref="Spring.Objects.IObjectWrapper"/> implementation should ! /// handle any necessary conversion, as this object doesn't know anything ! /// about the objects it will be applied to. ! /// </p> ! /// </remarks> /// <author>Rod Johnson</author> /// <author>Mark Pollack (.NET)</author> *************** *** 34,40 **** public class PropertyValue { ! /// <summary> Return the name of the property.</summary> ! /// <returns> the name of the property ! /// </returns> virtual public string Name { --- 41,46 ---- public class PropertyValue { ! /// <summary>Gets the name of the property.</summary> ! /// <returns>The name of the property.</returns> virtual public string Name { *************** *** 45,55 **** } ! /// <summary> Return the value of the property. ! /// <p>Note that type conversion will <i>not</i> have occurred here. ! /// It is the responsibility of the BeanWrapper implementation to ! /// perform type conversion.</p> /// </summary> ! /// <returns> the value of the property ! /// </returns> virtual public object Value { --- 51,66 ---- } ! /// <summary> ! /// Return the value of the property. /// </summary> ! /// <remarks> ! /// <p> ! /// Note that type conversion will <i>not</i> have occurred here. ! /// It is the responsibility of the ! /// <see cref="Spring.Objects.IObjectWrapper"/> implementation to ! /// perform type conversion. ! /// </p> ! /// </remarks> ! /// <returns>The value of the property.</returns> virtual public object Value { *************** *** 67,80 **** private object _val; ! /// <summary> Creates new PropertyValue.</summary> ! /// <param name="name">name of the property ! /// </param> ! /// <param name="val">value of the property (possibly before type conversion) /// </param> ! public PropertyValue(string name, object val) { ! if ((object) name == null) { ! throw new System.ArgumentException("Property name cannot be null"); } _name = name; --- 78,93 ---- private object _val; ! /// <summary> ! /// Creates a new instance of the PropertyValue class. ! /// </summary> ! /// <param name="name">The name of the property.</param> ! /// <param name="val"> ! /// The value of the property (possibly before type conversion). /// </param> ! public PropertyValue (string name, object val) { ! if (name == null) { ! throw new ArgumentNullException ("Property name cannot be null"); } _name = name; *************** *** 83,93 **** /// <summary> ! /// Print a string representation of the property /// </summary> ! /// <returns></returns> ! public override string ToString() { ! //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043_3"' ! return "PropertyValue: name='" + _name + "'; value=[" + _val + "]"; } --- 96,105 ---- /// <summary> ! /// Print a string representation of the property. /// </summary> ! /// <returns>A string representation of the property.</returns> ! public override string ToString () { ! return string.Format ("PropertyValue: name='{0}'; value=[{1}].", _name, _val); } *************** *** 95,101 **** /// Test if another object is equal in value to this one. /// </summary> ! /// <param name="other">the other instance</param> ! /// <returns>true if they are equal in content, false otherwise</returns> ! public override bool Equals(object other) { if (this == other) --- 107,113 ---- /// Test if another object is equal in value to this one. /// </summary> ! /// <param name="other">The other instance.</param> ! /// <returns>True if they are equal in content, false otherwise.</returns> ! public override bool Equals (object other) { if (this == other) *************** *** 108,112 **** } PropertyValue otherPv = (PropertyValue) other; ! return (_name.Equals(otherPv._name) && ((_val == null && otherPv._val == null) || _val.Equals(otherPv._val))); } --- 120,124 ---- } PropertyValue otherPv = (PropertyValue) other; ! return (_name.Equals (otherPv._name) && ((_val == null && otherPv._val == null) || _val.Equals (otherPv._val))); } *************** *** 114,121 **** /// The hashcode of the property /// </summary> ! /// <returns>the hashcode of the property</returns> public override int GetHashCode() { ! return _name.GetHashCode() * 29 + (_val != null?_val.GetHashCode():0); } } --- 126,133 ---- /// The hashcode of the property /// </summary> ! /// <returns>The hashcode of the property.</returns> public override int GetHashCode() { ! return _name.GetHashCode () * 29 + (_val != null ? _val.GetHashCode () : 0); } } Index: IObjectWrapper.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/IObjectWrapper.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IObjectWrapper.cs 6 Jul 2004 12:54:10 -0000 1.5 --- IObjectWrapper.cs 26 Jul 2004 07:47:55 -0000 1.6 *************** *** 138,142 **** /// <param name="pvs">PropertyValues to set on the target object /// </param> ! /// <param name="ignoreUnknown">should we ignore unknown values (not found in the bean!?) /// </param> void SetPropertyValues(IPropertyValues pvs, bool ignoreUnknown); --- 138,142 ---- /// <param name="pvs">PropertyValues to set on the target object /// </param> ! /// <param name="ignoreUnknown">should we ignore unknown values (not found in the object!?) /// </param> void SetPropertyValues(IPropertyValues pvs, bool ignoreUnknown); Index: NotWritablePropertyException.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/NotWritablePropertyException.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NotWritablePropertyException.cs 3 May 2004 10:26:28 -0000 1.1 --- NotWritablePropertyException.cs 26 Jul 2004 07:47:55 -0000 1.2 *************** *** 29,33 **** /// <param name="propertyName">The name of the property that is not writable</param> /// <param name="objectType">The type in which the property is not writable.</param> ! public NotWritablePropertyException(string propertyName, Type objectType):base("Property '" + propertyName + "' is not writable in bean class [" + objectType.FullName + "]") { } --- 29,33 ---- /// <param name="propertyName">The name of the property that is not writable</param> /// <param name="objectType">The type in which the property is not writable.</param> ! public NotWritablePropertyException(string propertyName, Type objectType):base("Property '" + propertyName + "' is not writable in object class [" + objectType.FullName + "]") { } *************** *** 39,43 **** /// <param name="objectType">The type in which the property is not writable.</param> /// <param name="ex">The root cause indicating why the property was not writable.</param> ! public NotWritablePropertyException(string propertyName, Type objectType, System.Exception ex):base("Property '" + propertyName + "' is not writable in bean class [" + objectType.FullName + "]", ex) { } --- 39,43 ---- /// <param name="objectType">The type in which the property is not writable.</param> /// <param name="ex">The root cause indicating why the property was not writable.</param> ! public NotWritablePropertyException(string propertyName, Type objectType, System.Exception ex):base("Property '" + propertyName + "' is not writable in object class [" + objectType.FullName + "]", ex) { } Index: ObjectUtils.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/ObjectUtils.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ObjectUtils.cs 16 Jul 2004 13:59:03 -0000 1.2 --- ObjectUtils.cs 26 Jul 2004 07:47:55 -0000 1.3 *************** *** 24,27 **** --- 24,29 ---- using System.Reflection; + using Spring.Util; + #endregion *************** *** 34,43 **** /// <author>Juergen Hoeller</author> /// <author>Rick Evans (.NET)</author> public sealed class ObjectUtils { - #region Constants - #endregion - #region Constructor (s) / Destructor /// <summary> --- 36,43 ---- /// <author>Juergen Hoeller</author> /// <author>Rick Evans (.NET)</author> + /// <version>$Id$</version> public sealed class ObjectUtils { #region Constructor (s) / Destructor /// <summary> *************** *** 52,99 **** #endregion - #region Properties - #endregion - #region Methods /// <summary> ! /// Convenience method to instantiate a type using its no-arg constructor. ! /// As this method doesn't try to instantiate types by name, it should avoid class-loading issues. /// </summary> ! /// <param name="type">the type to instantiate</param> ! /// <exception cref="Spring.Objects.FatalObjectException"></exception> ! /// <returns>the new instance</returns> ! public static object InstantiateType(Type type) { try { ! return Activator.CreateInstance(type); } catch (Exception e) { ! throw new FatalObjectException("Could not instantiate type [" + type.Name + ! "]; Is it an interface or an abstract class? Does it have a no-arg constructor?", e); } } /// <summary> ! /// Convenience method to instantiate a type using the given constructor. ! /// As this method doesn't try to instantiate types by name, it should avoid class-loading issues. ! /// ! /// TODO: check this uses the correct constructor. /// </summary> ! /// <param name="constructor">constructor to instantiate</param> ! /// <param name="arguments">the arguments to be passed to the constructor</param> ! /// <returns>the new instance</returns> ! public static object InstantiateType(ConstructorInfo constructor, object[] arguments) { ! object obj = null ; try { ! obj = constructor.Invoke(arguments); } catch (Exception e) { ! throw new FatalObjectException("Could not instantiate type [" + constructor.DeclaringType.Name + ! "]; Is it an interface or an abstract class? Does it have a no-arg constructor?", e); } return obj; --- 52,116 ---- #endregion #region Methods /// <summary> ! /// Convenience method to instantiate a <see cref="System.Type"/> using its no-arg constructor. /// </summary> ! /// <remarks> ! /// <p> ! /// As this method doesn't try to instantiate types by name, it should avoid type loading issues. ! /// </p> ! /// </remarks> ! /// <param name="type"> ! /// The <see cref="System.Type"/> to instantiate</param> ! /// <exception cref="Spring.Objects.FatalObjectException"> ! /// If the <see cref="System.Type"/> could not be instantiated. ! /// </exception> ! /// <returns>A new instance of the <see cref="System.Type"/>.</returns> ! public static object InstantiateType (Type type) { try { ! // TODO : use explicit reflection (c.f. Aleksander Seovic's recommendation) ! return Activator.CreateInstance (type); } catch (Exception e) { ! throw new FatalObjectException ( ! string.Format ( ! "Could not instantiate type [{0}]; is it an interface or an abstract class? Does it have a no-arg constructor?", type), ! e); } } /// <summary> ! /// Convenience method to instantiate a <see cref="System.Type"/> using the given constructor. /// </summary> ! /// <remarks> ! /// <p> ! /// As this method doesn't try to instantiate types by name, it should avoid type loading issues. ! /// </p> ! /// </remarks> ! /// <param name="constructor"> ! /// The constructor to use for the instantiation. ! /// </param> ! /// <param name="arguments"> ! /// The arguments to be passed to the constructor. ! /// </param> ! /// <returns>A new instance.</returns> ! public static object InstantiateType ( ! ConstructorInfo constructor, object[] arguments) { ! // TODO: check this uses the correct constructor. ! object obj = null; try { ! obj = constructor.Invoke (arguments); } catch (Exception e) { ! throw new FatalObjectException ( ! string.Format ( ! "Could not instantiate type [{0}]; is it an interface or an abstract class? Does it have a no-arg constructor?", constructor), ! e); } return obj; *************** *** 101,167 **** /// <summary> ! /// Converts a string into a type. ! /// ! /// TODO: seems like a silly thing to have to do, but haven't found a better way ! /// of doing it yet! ! /// </summary> ! /// <param name="s">the string to convert</param> ! /// <returns>the type, or null if the conversion could not be performed</returns> ! public static Type LocateType(string s) ! { ! if (s == null) ! { ! throw new ArgumentException("Cannot convert null to primitive type."); ! } ! ! return LocateTypeFromAssemblies(s); ! } ! ! /// <summary> ! /// Tries to locate the specified type by trying each assembly within the current domain. ! /// ! /// TODO: This must be slow (and probably a VERY wrong way of doing this!), however ! /// it works so for now live with it!!!!!!! FIX ME !!!!!!! ! /// </summary> ! /// <param name="typeName">the type to locate</param> ! /// <returns>the type, or null if the type could not be located</returns> ! private static Type LocateTypeFromAssemblies(string typeName) ! { ! Type type = null ; ! Assembly[] asses = System.AppDomain.CurrentDomain.GetAssemblies(); ! foreach(Assembly ass in asses) ! { ! type = ass.GetType(typeName, false, false); ! if (type != null) ! { ! break; ! } ! } ! return type; ! } ! ! /// <summary> ! /// Determine if the given type is assignable from the given value, ! /// assuming setting by reflection. Considers primitive wrapper classes ! /// as assignable to the corresponding primitive types. ! /// For example used in a object factory's constructor resolution. /// </summary> ! /// <param name="type">the target type</param> ! /// <param name="obj">the value that should be assigned to the type</param> ! /// <returns>if the type is assignable from the value</returns> ! public static bool IsAssignable(Type type, object obj) { ! return (type.IsInstanceOfType(obj) || (!type.IsPrimitive && obj == null) || ! (type.Equals(typeof(bool)) && obj is Boolean) || ! (type.Equals(typeof(byte)) && obj is Byte) || ! (type.Equals(typeof(char)) && obj is Char) || ! (type.Equals(typeof(sbyte)) && obj is SByte) || ! (type.Equals(typeof(int)) && obj is Int32) || // TODO: what to do here? ! (type.Equals(typeof(short)) && obj is Int16) || ! (type.Equals(typeof(long)) && obj is Int64) || ! (type.Equals(typeof(float)) && obj is Single) || ! (type.Equals(typeof(double)) && obj is Double)); } --- 118,150 ---- /// <summary> ! /// Determine if the given <see cref="System.Type"/> is assignable from the ! /// given value, assuming setting by reflection. /// </summary> ! /// <remarks> ! /// <p> ! /// Considers primitive wrapper classes as assignable to the ! /// corresponding primitive types. ! /// </p> ! /// <p> ! /// For example used in an object factory's constructor resolution. ! /// </p> ! /// </remarks> ! /// <param name="type">The target <see cref="System.Type"/>.</param> ! /// <param name="obj">The value that should be assigned to the type.</param> ! /// <returns>True if the type is assignable from the value.</returns> ! public static bool IsAssignable (Type type, object obj) { ! return (type.IsInstanceOfType (obj) || (!type.IsPrimitive && obj == null) || ! (type.Equals (typeof (bool)) && obj is Boolean) || ! (type.Equals (typeof (byte)) && obj is Byte) || ! (type.Equals (typeof (char)) && obj is Char) || ! (type.Equals (typeof (sbyte)) && obj is SByte) || ! (type.Equals (typeof (int)) && obj is Int32) || // TODO: what to do here? ! (type.Equals (typeof(short)) && obj is Int16) || ! (type.Equals (typeof(long)) && obj is Int64) || ! (type.Equals (typeof(float)) && obj is Single) || ! (type.Equals (typeof(double)) && obj is Double)); } *************** *** 183,187 **** return type.IsPrimitive || IsPrimitiveArray (type) - || IsPrimitiveWrapperArray (type) || type.Equals (typeof (string)) || type.Equals (typeof (string [])) --- 166,169 ---- *************** *** 190,194 **** } ! /// <summary> Check if the given class represents a primitive array, /// i.e. boolean, byte, char, short, int, long, float, or double. /// </summary> --- 172,177 ---- } ! /// <summary> ! /// Check if the given class represents a primitive array, /// i.e. boolean, byte, char, short, int, long, float, or double. /// </summary> *************** *** 204,223 **** || typeof (double []).Equals (type); } ! ! /// <summary> Check if the given class represents an array of primitive wrappers, ! /// i.e. Boolean, Byte, Character, Short, Integer, Long, Float, or Double. /// </summary> ! public static bool IsPrimitiveWrapperArray (Type type) { ! return typeof (bool []).Equals (type) ! || typeof (sbyte []).Equals (type) ! || typeof (char []).Equals (type) ! || typeof (short []).Equals (type) ! || typeof (int []).Equals (type) ! || typeof (long []).Equals (type) ! || typeof (float []).Equals (type) ! || typeof (double []).Equals (type); } #endregion } } --- 187,213 ---- || typeof (double []).Equals (type); } ! ! /// <summary> ! /// Resolves the supplied type name into a <see cref="System.Type"/> ! /// instance. /// </summary> ! /// <param name="typeName"> ! /// The (possibly partially assembly qualified) name of a <see cref="System.Type"/>. ! /// </param> ! /// <returns> ! /// A resolved <see cref="System.Type"/> instance. ! /// </returns> ! /// <exception cref="System.TypeLoadException"> ! /// If the type could not be resolved. ! /// </exception> ! public static Type ResolveType (string typeName) { ! return typeResolver.Resolve (typeName); } #endregion + + #region Fields + private static TypeResolver typeResolver = new CachedTypeResolver (); + #endregion } } Index: PropertyChangeEventArgs.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/PropertyChangeEventArgs.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PropertyChangeEventArgs.cs 11 May 2004 22:23:32 -0000 1.2 --- PropertyChangeEventArgs.cs 26 Jul 2004 07:47:55 -0000 1.3 *************** *** 61,64 **** } } - - --- 61,62 ---- Index: ObjectWrapper.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/ObjectWrapper.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** ObjectWrapper.cs 18 Jul 2004 09:37:00 -0000 1.19 --- ObjectWrapper.cs 26 Jul 2004 07:47:55 -0000 1.20 *************** *** 73,84 **** private string _nestedPath = string.Empty; ! /// <summary> /// Dictionary with cached nested ObjectWrappers /// </summary> private IDictionary _nestedObjectWrappers; ! /// <summary>Map with custom TypeConverter instances </summary> private IDictionary _customConverters; ! /// <summary> /// The default converts used to convert string to object types. /// </summary> private static readonly IDictionary _defaultConverters = new Hashtable (); ! /// <summary> /// The path separator for nested properties. Moved from /// </summary> public const string NestedPropertySeparator = "."; --- 73,92 ---- private string _nestedPath = string.Empty; ! /// <summary> ! /// Dictionary with cached nested ObjectWrappers ! /// </summary> ! private IDictionary _nestedObjectWrappers; ! /// <summary>Map with custom TypeConverter instances </summary> ! private IDictionary _customConverters; ! /// <summary> ! /// The default converts used to convert string to object types. ! /// </summary> private static readonly IDictionary _defaultConverters = new Hashtable (); ! /// <summary> ! /// The path separator for nested properties. Moved from ! /// </summary> public const string NestedPropertySeparator = "."; *************** *** 123,142 **** } ! /// <summary> /// Create new ObjectWrapper for the given object, registering a nested path that /// the object is in. /// </summary> /// <param name="instance"> /// The object wrapped by this ObjectWrapper. /// </param> /// <param name="nestedPath"> /// The nested path of the object. /// </param> public ObjectWrapper (object instance, string nestedPath) { WrappedInstance = instance; _nestedPath = nestedPath; } ! /// <summary> /// Create new ObjectWrapper for the given object, instantiating a new /// instance of the specified <see cref="System.Type"/>. /// </summary> /// <param name="type"> /// The <see cref="System.Type"/> to instantiate and wrap. /// </param> /// <exception cref="Spring.Objects.FatalObjectException"> /// If the <see cref="System.Type"/> could not be wrapped. /// </exception> public ObjectWrapper (Type type) { try ! { WrappedInstance = Activator.CreateInstance (type); } ! catch (Exception ex) ! { throw new FatalObjectException ( ! string.Format ( ! "Could not instantiate Type [{0}]; is it an interface or an abstract class? " + ! "Does it have a no-arg constructor?", ! type.FullName, ! ex)); } } ! /// <summary> /// Initialize the default converters. /// </summary> static ObjectWrapper () { _defaultConverters [typeof (string [])] = new StringArrayConverter (); } #endregion --- 131,172 ---- } ! /// <summary> ! /// Create new ObjectWrapper for the given object, registering a nested path that ! /// the object is in. ! /// </summary> ! /// <param name="instance"> ! /// The object wrapped by this ObjectWrapper. ! /// </param> ! /// <param name="nestedPath"> ! /// The nested path of the object. ! /// </param> ! public ObjectWrapper (object instance, string nestedPath) ! { ! WrappedInstance = instance; ! _nestedPath = nestedPath; ! } ! /// <summary> ! /// Create new ObjectWrapper for the given object, instantiating a new ! /// instance of the specified <see cref="System.Type"/>. ! /// </summary> ! /// <param name="type"> ! /// The <see cref="System.Type"/> to instantiate and wrap. ! /// </param> ! /// <exception cref="Spring.Objects.FatalObjectException"> ! /// If the <see cref="System.Type"/> could not be wrapped. ! /// </exception> ! public ObjectWrapper (Type type) ! { ! WrappedInstance = ObjectUtils.InstantiateType (type); ! } ! /// <summary> ! /// Initialize the default converters. ! /// </summary> static ObjectWrapper () { _defaultConverters [typeof (string [])] = new StringArrayConverter (); + _defaultConverters [typeof (Type)] = new RuntimeTypeConverter (); } #endregion *************** *** 175,181 **** /// <summary> ! /// Convenience method to return the type of the wrapped object. /// </summary> ! /// <returns>The type of the wrapped object. /// </returns> public Type WrappedType --- 205,212 ---- /// <summary> ! /// Convenience method to return the <see cref="System.Type"/> of the wrapped object. /// </summary> ! /// <returns> ! /// The <see cref="System.Type"/> of the wrapped object. /// </returns> public Type WrappedType *************** *** 189,193 **** #region Methods ! /// <summary> /// Register the given custom <see cref="System.ComponentModel.TypeConverter"/> /// for all properties of the given <see cref="System.Type"/>. /// </summary> /// <param name="requiredType"> /// The <see cref="System.Type"/> of property. /// </param> /// <param name="typeConverter"> /// The <see cref="System.ComponentModel.TypeConverter"/> to register. /// </param> --- 220,231 ---- #region Methods ! /// <summary> ! /// Register the given custom <see cref="System.ComponentModel.TypeConverter"/> ! /// for all properties of the given <see cref="System.Type"/>. ! /// </summary> ! /// <param name="requiredType"> ! /// The <see cref="System.Type"/> of property. ! /// </param> ! /// <param name="typeConverter"> /// The <see cref="System.ComponentModel.TypeConverter"/> to register. /// </param> *************** *** 198,202 **** } ! /// <summary> /// Register the given custom <see cref="System.ComponentModel.TypeConverter"/> /// for all properties of the given type. /// </summary> /// <param name="requiredType"> /// The <see cref="System.Type"/> of property. /// </param> /// <param name="typeConverter"> /// The <see cref="System.ComponentModel.TypeConverter"/> to register. /// </param> --- 236,247 ---- } ! /// <summary> ! /// Register the given custom <see cref="System.ComponentModel.TypeConverter"/> ! /// for all properties of the given <see cref="System.Type"/>. ! /// </summary> ! /// <param name="requiredType"> ! /// The <see cref="System.Type"/> of property. ! /// </param> ! /// <param name="typeConverter"> /// The <see cref="System.ComponentModel.TypeConverter"/> to register. /// </param> *************** *** 239,249 **** } ! /// <summary> /// Is the property nested? That is, does it contain the nested property /// separator (usually "."). /// </summary> /// <param name="path">The property path.</param> /// <returns>True if the property is nested.</returns> private bool IsNestedProperty (string path) { return path.IndexOf (NestedPropertySeparator) != - 1; } ! /// <summary> /// Get the last component of the path. Also works if not nested. /// </summary> /// <param name="nestedPath"> /// The property path we know is nested. /// </param> /// <returns> /// The last component of the path (the property on the target object). /// </returns> private string GetFinalPath (string nestedPath) { return nestedPath.Substring ( nestedPath.LastIndexOf (NestedPropertySeparator) + 1); } ! /// <summary> /// Recursively navigate to return a <see cref="Spring.Objects.ObjectWrapper"/> /// for the nested property path. /// </summary> /// <param name="propertyPath"> /// The property property path, which may be nested. /// </param> /// <returns> /// A <see cref="Spring.Objects.ObjectWrapper"/> for the target object. /// </returns> private ObjectWrapper GetObjectWrapperForPropertyPath (string propertyPath) { int pos = propertyPath.IndexOf (NestedPropertySeparator); // handle nested properties recursively if (pos > - 1) { string nestedProperty = propertyPath.Substring (0, pos - 0); string nestedPath = propertyPath.Substring (pos + 1); ObjectWrapper nestedOw = GetNestedObjectWrapper (nestedProperty); return nestedOw.GetObjectWrapperForPropertyPath (nestedPath); } else { return this; } } ! /// <summary> /// Find a custom <see cref="System.ComponentModel.TypeConverter"/> for the /// given <see cref="System.Type"/> and property.</summary> /// <param name="requiredType"> /// The <see cref="System.Type"/> of the property, can be null if a property /// is given but should be specified in any case for consistency checking. /// </param> /// <param name="propertyPath"> /// The path of the property (name or nested path), or null if looking for a /// <see cref="System.ComponentModel.TypeConverter"/> for all properties of /// the given <see cref="System.Type"/>. /// </param> /// <returns> /// The registered <see cref="System.ComponentModel.TypeConverter"/>, or null /// if none. /// </returns> public TypeConverter FindCustomConverter ( Type requiredType, string propertyPath) --- 284,356 ---- } ! /// <summary> ! /// Is the property nested? That is, does it contain the nested property ! /// separator (usually "."). ! /// </summary> ! /// <param name="path">The property path.</param> ! /// <returns>True if the property is nested.</returns> ! private bool IsNestedProperty (string path) ! { ! return path.IndexOf (NestedPropertySeparator) != - 1; ! } ! /// <summary> ! /// Get the last component of the path. Also works if not nested. ! /// </summary> ! /// <param name="nestedPath"> ! /// The property path we know is nested. ! /// </param> ! /// <returns> ! /// The last component of the path (the property on the target object). ! /// </returns> ! private string GetFinalPath (string nestedPath) ! { ! return nestedPath.Substring ( ! nestedPath.LastIndexOf (NestedPropertySeparator) + 1); ! } ! /// <summary> ! /// Recursively navigate to return a <see cref="Spring.Objects.ObjectWrapper"/> ! /// for the nested property path. ! /// </summary> ! /// <param name="propertyPath"> ! /// The property property path, which may be nested. ! /// </param> ! /// <returns> ! /// A <see cref="Spring.Objects.ObjectWrapper"/> for the target object. ! /// </returns> ! private ObjectWrapper GetObjectWrapperForPropertyPath (string propertyPath) ! { ! int pos = propertyPath.IndexOf (NestedPropertySeparator); ! // handle nested properties recursively ! if (pos > - 1) ! { ! string nestedProperty = propertyPath.Substring (0, pos - 0); ! string nestedPath = propertyPath.Substring (pos + 1); ! ObjectWrapper nestedOw = GetNestedObjectWrapper (nestedProperty); ! return nestedOw.GetObjectWrapperForPropertyPath (nestedPath); ! } ! else ! { ! return this; ! } ! } ! /// <summary> ! /// Find a custom <see cref="System.ComponentModel.TypeConverter"/> for the ! /// given <see cref="System.Type"/> and property.</summary> ! /// <param name="requiredType"> ! /// The <see cref="System.Type"/> of the property, can be null if a property ! /// is given but should be specified in any case for consistency checking. ! /// </param> ! /// <param name="propertyPath"> ! /// The path of the property (name or nested path), or null if looking for a ! /// <see cref="System.ComponentModel.TypeConverter"/> for all properties of ! /// the given <see cref="System.Type"/>. ! /// </param> ! /// <returns> ! /// The registered <see cref="System.ComponentModel.TypeConverter"/>, or null ! /// if none. ! /// </returns> public TypeConverter FindCustomConverter ( Type requiredType, string propertyPath) *************** *** 262,266 **** } ! private TypeConverter DoFindCustomConverter (Type requiredType, string propertyName) { if (_customConverters == null) { return null; } if (propertyName != null) { // check property-specific type converter first try { TypeConverter editor = (TypeConverter) _customConverters [propertyName]; if (editor == null) { //TODO check for usage with arrays. int keyIndex = propertyName.IndexOf ('['); if (keyIndex != - 1) { editor = (TypeConverter) _customConverters [ propertyName.Substring (0, keyIndex - 0)]; } } if (editor != null) { return editor; } else { if (requiredType == null) { // try property type requiredType = GetPropertyInfo (propertyName).PropertyType; } } } catch (ObjectsException) { // probably an indexed or mapped property // we need to retrieve the value to determine the type requiredType = GetPropertyInfo (propertyName).PropertyType; } } return (TypeConverter) _customConverters [requiredType]; } /// <summary> --- 369,418 ---- } ! private TypeConverter DoFindCustomConverter ! (Type requiredType, string propertyName) ! { ! if (_customConverters == null) ! { ! return null; ! } ! if (propertyName != null) ! { ! // check property-specific type converter first ! try ! { ! TypeConverter editor ! = (TypeConverter) _customConverters [propertyName]; ! if (editor == null) ! { ! //TODO check for usage with arrays. ! int keyIndex = propertyName.IndexOf ('['); ! if (keyIndex != - 1) ! { ! editor = (TypeConverter) _customConverters [ ! propertyName.Substring (0, keyIndex - 0)]; ! } ! } ! if (editor != null) ! { ! return editor; ! } ! else ! { ! if (requiredType == null) ! { ! // try property type ! requiredType = GetPropertyInfo (propertyName).PropertyType; ! } ! } ! } ! catch (ObjectsException) ! { ! // probably an indexed or mapped property ! // we need to retrieve the value to determine the type ! requiredType = GetPropertyInfo (propertyName).PropertyType; ! } ! } ! return (TypeConverter) _customConverters [requiredType]; ! } /// <summary> *************** *** 373,379 **** } ! /// <summary> /// Retrieve an <see cref="Spring.Objects.ObjectWrapper"/> for the given nested property. /// </summary> /// <remarks> /// <p> /// Create a new one if not found in the cache. /// </p> /// <p> /// Note: Caching nested <see cref="Spring.Objects.ObjectWrapper"/>s is necessary now, /// to keep registered custom editors for nested properties. /// </p> /// </remarks> /// <param name="nestedProperty"> /// The property to create the <see cref="Spring.Objects.ObjectWrapper"/> for. /// </param> /// <returns> /// The <see cref="Spring.Objects.ObjectWrapper"/> instance, either cached or newly created. /// </returns> private ObjectWrapper GetNestedObjectWrapper (string nestedProperty) { if (_nestedObjectWrappers == null) { _nestedObjectWrappers = new Hashtable (); } // get value of object property string [] tokens = GetPropertyNameTokens (nestedProperty); object propertyValue = GetPropertyValue (tokens [0], tokens [1], tokens [2]); string canonicalName = tokens [0]; if (propertyValue == null) { throw new NullValueInNestedPathException (WrappedType, canonicalName); } // lookup cached sub-ObjectWrapper, create new one if not found ObjectWrapper nestedOw = (ObjectWrapper) _nestedObjectWrappers [canonicalName]; if (nestedOw == null) { //logger.debug("Creating new nested BeanWrapper for property '" + canonicalName + "'"); nestedOw = new ObjectWrapper (propertyValue, _nestedPath + canonicalName + NestedPropertySeparator); // inherit all type-specific TypeConverters if (_customConverters != null) { ICollection types = _customConverters.Keys; foreach (Type requiredType in types) { TypeConverter typeConverter = (TypeConverter)_customConverters[requiredType]; nestedOw.RegisterCustomConverter(requiredType, null, typeConverter); } } _nestedObjectWrappers[canonicalName] = nestedOw; } else { #region Instrumentation if (log.IsDebugEnabled) ! { log.Debug ( "Using cached nested ObjectWrapper for property '" + canonicalName + "'"); } #endregion } return nestedOw; } ! private string [] GetPropertyNameTokens (string propertyName) { string actualName = propertyName; string key = null; int keyStart = propertyName.IndexOf ('['); if (keyStart != - 1 && propertyName.EndsWith ("]")) { actualName = propertyName.Substring (0, keyStart - 0); key = propertyName.Substring(keyStart + 1, (propertyName.Length - 1) - (keyStart + 1)); if (key.StartsWith ("'") && key.EndsWith ("'")) { key = key.Substring (1, (key.Length - 1) - (1)); } else if (key.StartsWith ("\"") && key.EndsWith("\"")) { key = key.Substring (1, (key.Length - 1) - (1)); } } string canonicalName = actualName; if (key != null) { canonicalName += ("[" + key + "]"); } return new string [] {canonicalName, actualName, key}; } /// <summary>Get the value of a property.</summary> --- 525,624 ---- } ! /// <summary> ! /// Retrieve an <see cref="Spring.Objects.ObjectWrapper"/> for the given nested property. ! /// </summary> ! /// <remarks> ! /// <p> ! /// Create a new one if not found in the cache. ! /// </p> ! /// <p> ! /// Note: Caching nested <see cref="Spring.Objects.ObjectWrapper"/>s is necessary now, ! /// to keep registered custom editors for nested properties. ! /// </p> ! /// </remarks> ! /// <param name="nestedProperty"> ! /// The property to create the <see cref="Spring.Objects.ObjectWrapper"/> for. ! /// </param> ! /// <returns> ! /// The <see cref="Spring.Objects.ObjectWrapper"/> instance, either cached or newly created. ! /// </returns> ! private ObjectWrapper GetNestedObjectWrapper (string nestedProperty) ! { ! if (_nestedObjectWrappers == null) ! { ! _nestedObjectWrappers = new Hashtable (); ! } ! // get value of object property ! string [] tokens = GetPropertyNameTokens (nestedProperty); ! object propertyValue = GetPropertyValue (tokens [0], tokens [1], tokens [2]); ! string canonicalName = tokens [0]; ! if (propertyValue == null) ! { ! throw new NullValueInNestedPathException (WrappedType, canonicalName); ! } ! // lookup cached sub-ObjectWrapper, create new one if not found ! ObjectWrapper nestedOw = (ObjectWrapper) _nestedObjectWrappers [canonicalName]; ! if (nestedOw == null) ! { ! #region Instrumentation ! if (log.IsDebugEnabled) ! { ! log.Debug ("Creating new nested ObjectWrapper for property '" + canonicalName + "'."); ! } ! #endregion ! ! nestedOw = new ObjectWrapper (propertyValue, _nestedPath + canonicalName + NestedPropertySeparator); ! // inherit all type-specific TypeConverters ! if (_customConverters != null) ! { ! ICollection types = _customConverters.Keys; ! foreach (Type requiredType in types) ! { ! TypeConverter typeConverter = (TypeConverter)_customConverters[requiredType]; ! nestedOw.RegisterCustomConverter(requiredType, null, typeConverter); ! } ! } ! _nestedObjectWrappers[canonicalName] = nestedOw; ! } ! else ! { ! #region Instrumentation ! if (log.IsDebugEnabled) ! { ! log.Debug ( ! "Using cached nested ObjectWrapper for property '" + ! canonicalName + "'"); ! } ! #endregion ! } ! return nestedOw; ! } ! ! private string [] GetPropertyNameTokens (string propertyName) ! { ! string actualName = propertyName; ! string key = null; ! int keyStart = propertyName.IndexOf ('['); ! if (keyStart != - 1 ! && propertyName.EndsWith ("]")) ! { ! actualName = propertyName.Substring (0, keyStart - 0); ! key = propertyName.Substring(keyStart + 1, (propertyName.Length - 1) - (keyStart + 1)); ! if (key.StartsWith ("'") && key.EndsWith ("'")) ! { ! key = key.Substring (1, (key.Length - 1) - (1)); ! } ! else if (key.StartsWith ("\"") && key.EndsWith("\"")) ! { ! key = key.Substring (1, (key.Length - 1) - (1)); ! } ! } ! string canonicalName = actualName; ! if (key != null) ! { ! canonicalName += ("[" + key + "]"); ! } ! return new string [] {canonicalName, actualName, key}; ! } /// <summary>Get the value of a property.</summary> *************** *** 383,387 **** /// <returns>The value of the property.</returns> /// <exception cref="Spring.Objects.FatalObjectException"> ! /// If there is no such property, if the property isn&t readable, or /// if getting the property value throws an exception. /// </exception> --- 628,632 ---- /// <returns>The value of the property.</returns> /// <exception cref="Spring.Objects.FatalObjectException"> ! /// If there is no such property, if the property isn't readable, or /// if getting the property value throws an exception. /// </exception> *************** *** 441,449 **** ! /// <summary> /// Look for a default <see cref="System.ComponentModel.TypeConverter"/> /// to handle common cases. /// </summary> /// <param name="requiredType"> /// The <see cref="System.Type"/> that is registered to be converted. /// </param> /// <returns> /// The default <see cref="System.ComponentModel.TypeConverter"/> for the /// supplied <see cref="System.Type"/>. /// </returns> ! public virtual TypeConverter FindDefaultConverter(Type requiredType) { return (TypeConverter) _defaultConverters [requiredType]; --- 686,701 ---- ! /// <summary> ! /// Look for a default <see cref="System.ComponentModel.TypeConverter"/> ! /// to handle common cases. ! /// </summary> ! /// <param name="requiredType"> ! /// The <see cref="System.Type"/> that is registered to be converted. ! /// </param> ! /// <returns> /// The default <see cref="System.ComponentModel.TypeConverter"/> for the /// supplied <see cref="System.Type"/>. /// </returns> ! public virtual TypeConverter FindDefaultConverter (Type requiredType) { return (TypeConverter) _defaultConverters [requiredType]; *************** *** 452,483 **** /// <summary> ! /// Convert the value to the required type (if necessary from a string). /// </summary> ! /// <param name="newValue">proposed change value</param> ! /// <param name="requiredType">type we must convert to</param> ! /// <exception cref="Spring.Objects.ObjectsException">if there is an internal error</exception> ! /// <returns>new value, possibly the result of type convertion</returns> ! public virtual object DoTypeConversionIfNecessary(object newValue, Type requiredType) { ! return DoTypeConversionIfNecessary(null, null, null, newValue, requiredType); } ! /// <summary> /// Convert the value to the required <see cref="System.Type"/> (if necessary /// from a <see cref="System.String"/>), for the specified property. /// </summary> /// <param name="propertyName">The name of the property.</param> /// <param name="fullPropertyName"> /// Legacy, not used. Will refactor out later. /// </param> /// <param name="oldValue"> /// The previous value, if available (may be null). /// </param> /// <param name="newValue">The proposed change value.</param> /// <param name="requiredType"> /// The <see cref="System.Type"/> we are trying to convert to. /// </param> /// <returns> /// The new value, possibly the result of type conversion. /// </returns> /// <exception cref="Spring.Objects.ObjectsException"> /// If there is an internal error. /// </exception> protected internal virtual object DoTypeConversionIfNecessary ( string propertyName, string fullPropertyName, object oldValue, object newValue, Type requiredType) { if (newValue != null) { ! if (requiredType != null && requiredType.IsArray) { // convert individual elements to array elements Type componentType = requiredType.GetElementType (); if (newValue is IList) { IList list = (IList) newValue; Array result = Array.CreateInstance (componentType, list.Count); for (int i = 0; i < list.Count; ++i) { //TODO look into this. //PropertyInfo pi2 = list[i].GetType().GetProperty("Item"); object val = DoTypeConversionIfNecessary(propertyName, propertyName + "[" + i + "]", null, list[i], componentType); result.SetValue (val, i); } return result; } //TODO arrays are treated as IList..... else if (newValue is object []) { object [] array = (object []) newValue; object result = Array.CreateInstance (componentType, array.Length); for (int i = 0; i < array.Length; ++i) { //TODO look into this //object value_Renamed = DoTypeConversionIfNecessary(propertyName, propertyName + "[" + i + "]", (object) null, array[i], componentType); // ((Array) result).SetValue(value_Renamed, i); } return result; } } TypeConverter typeConverter = FindCustomConverter (requiredType, fullPropertyName); // value not of required type? ! if (typeConverter != null || requiredType != null && !requiredType.IsAssignableFrom (newValue.GetType ()) ) { if (newValue is string []) { newValue = StringUtils.ArrayToCommaDelimitedString ((string []) newValue); } if (newValue is string) { if (typeConverter == null) { //no custom type converter found -> check ObjectWrappers default editors typeConverter = FindDefaultConverter (requiredType); if (typeConverter == null) { // mmm... is there a TypeConverter for System.Type from a string? if (requiredType.FullName == typeof (Type).FullName && ! newValue is string) ! { // TODO: if newValue references a type from a third party // assembly, the original version returns null, so // changed to use ObjectUtils instead. Is this right?? //return Type.GetType (newValue as string); return ObjectUtils.LocateType(newValue as string); } ! else ! { //get standard converter typeConverter = TypeDescriptor.GetConverter (requiredType); } } } if (typeConverter != null) { try { return typeConverter.ConvertFrom (newValue); } catch (Exception ex) { throw new TypeMismatchException ( CreatePropertyChangeEventArgs ( fullPropertyName, oldValue, newValue), requiredType, ex); } } else { throw new TypeMismatchException ( CreatePropertyChangeEventArgs ( fullPropertyName, oldValue, newValue), requiredType); } } else if (typeConverter != null) { try { //return typeConverter.ConvertTo(newValue, requiredType); return typeConverter.ConvertFrom (newValue); } catch (Exception ex) { throw new TypeMismatchException ( CreatePropertyChangeEventArgs ( fullPropertyName, oldValue, newValue), requiredType, ex); } } } ! if (requiredType != null && requiredType.IsArray && !newValue.GetType ().IsArray) { Type componentType = requiredType.GetElementType (); Array result = Array.CreateInstance (componentType, 1); object val = DoTypeConversionIfNecessary (propertyName, propertyName + "[0]", null, newValue, componentType); result.SetValue (val, 0); return result; } } return newValue; } ! /// <summary> /// Utility method to create a property change eve... [truncated message content] |
From: Springboy <spr...@us...> - 2004-07-26 07:48:33
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Core/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18183/Spring/Spring.Core/Core/IO Modified Files: AbstractResource.cs IInputStreamSource.cs Log Message: Added centralised Type resolution mechanism, runtime type converter, Xml Config handler, multiple documentation updates. Index: IInputStreamSource.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Core/IO/IInputStreamSource.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IInputStreamSource.cs 12 Jul 2004 07:50:15 -0000 1.2 --- IInputStreamSource.cs 26 Jul 2004 07:47:54 -0000 1.3 *************** *** 33,37 **** /// <remarks> /// <p> ! /// Base interface for Spring&'s <see cref="Spring.Core.IO.IResource"/> interface. /// </p> /// </remarks> --- 33,37 ---- /// <remarks> /// <p> ! /// Base interface for Spring''s <see cref="Spring.Core.IO.IResource"/> interface. /// </p> /// </remarks> Index: AbstractResource.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Core/IO/AbstractResource.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AbstractResource.cs 12 Jul 2004 07:50:15 -0000 1.2 --- AbstractResource.cs 26 Jul 2004 07:47:54 -0000 1.3 *************** *** 173,177 **** /// <summary> ! /// This implementation returns the description&s hash code. /// </summary> /// <seealso cref="Description"/> --- 173,177 ---- /// <summary> ! /// This implementation returns the description's hash code. /// </summary> /// <seealso cref="Description"/> |
From: Springboy <spr...@us...> - 2004-07-26 07:48:33
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18183/Spring/Spring.Core Modified Files: Spring.Core.csproj Log Message: Added centralised Type resolution mechanism, runtime type converter, Xml Config handler, multiple documentation updates. Index: Spring.Core.csproj =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Spring.Core.csproj,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Spring.Core.csproj 23 Jul 2004 10:13:00 -0000 1.14 --- Spring.Core.csproj 26 Jul 2004 07:47:54 -0000 1.15 *************** *** 493,501 **** /> <File - RelPath = "Objects\Factory\Xml\ObjectsDefinitionConfigResource.cs" - SubType = "Code" - BuildAction = "Compile" - /> - <File RelPath = "Objects\Factory\Xml\ObjectsDtd.cs" SubType = "Code" --- 493,496 ---- *************** *** 512,515 **** --- 507,515 ---- /> <File + RelPath = "Objects\Factory\Xml\XmlConfigObjectFactoryHandler.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Objects\Factory\Xml\XmlObjectDefinitionReader.cs" SubType = "Code" *************** *** 542,545 **** --- 542,550 ---- /> <File + RelPath = "Objects\TypeConverters\RuntimeTypeConverter.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Objects\TypeConverters\StringArrayConverter.cs" SubType = "Code" *************** *** 561,564 **** --- 566,574 ---- /> <File + RelPath = "Util\CachedTypeResolver.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Util\LinkedList.cs" SubType = "Code" *************** *** 590,593 **** --- 600,608 ---- BuildAction = "Compile" /> + <File + RelPath = "Util\TypeResolver.cs" + SubType = "Code" + BuildAction = "Compile" + /> </Include> </Files> |
From: Springboy <spr...@us...> - 2004-07-26 07:48:26
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18183/Spring/Spring.Core/Util Modified Files: MethodInvoker.cs StringUtils.cs TypeAliasResolver.cs Log Message: Added centralised Type resolution mechanism, runtime type converter, Xml Config handler, multiple documentation updates. Index: StringUtils.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Util/StringUtils.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** StringUtils.cs 16 Jul 2004 13:59:03 -0000 1.6 --- StringUtils.cs 26 Jul 2004 07:47:57 -0000 1.7 *************** *** 1,27 **** /* ! * Copyright 2002-2004 the original author or authors. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. ! */ using System; using System.Collections; using System.Text; namespace Spring.Util { /// <summary> ! /// Miscellaneous string utility methods. Mainly for internal use ! /// within the framework. /// </summary> /// <author>Rod Johnson</author> --- 1,36 ---- + #region Licence + /* ! * Copyright 2002-2004 the original author or authors. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. ! */ ! ! #endregion ! ! #region Imports ! using System; using System.Collections; using System.Text; + #endregion + namespace Spring.Util { /// <summary> ! /// Miscellaneous <see cref="System.String"/> utility methods. ! /// Mainly for internal use within the framework. /// </summary> /// <author>Rod Johnson</author> *************** *** 34,44 **** public abstract class StringUtils { ! /// <summary> Count the occurrences of the substring in string s.</summary> ! /// <param name="s">string to search in. Return 0 if this is null.</param> ! /// <param name="sub">string to search for. Return 0 if this is null.</param> ! /// <returns>number of times <paramref>sub</paramref> occurs in string <paramref>s</paramref></returns> ! public static int CountOccurrencesOf(string s, string sub) { ! if (s == null || sub == null || "".Equals(sub) || sub.Length > s.Length) { return 0; --- 43,64 ---- public abstract class StringUtils { ! /// <summary> ! /// Count the occurrences of the substring in ! /// <see cref="System.String"/> <paramref name="s"/>. ! /// </summary> ! /// <param name="s"> ! /// The <see cref="System.String"/> to search in. Return 0 if this is null. ! /// </param> ! /// <param name="sub"> ! /// The <see cref="System.String"/> to search for. Return 0 if this is null. ! /// </param> ! /// <returns> ! /// The number of times <paramref name="sub"/> occurs in string <paramref name="s"/>. ! /// </returns> ! public static int CountOccurrencesOf (string s, string sub) { ! if (s == null ! || !StringUtils.HasText (sub) ! || sub.Length > s.Length) { return 0; *************** *** 48,52 **** return 1; } - int count = 0, pos = 0, idx = 0; while ((idx = s.IndexOf(sub, pos)) != -1) --- 68,71 ---- *************** *** 58,120 **** } ! /// <summary> Delete all occurrences of the given substring.</summary> ! /// <param name="inString">string to delete from</param> ! /// <param name="pattern">the pattern to delete all occurrences of</param> ! /// <returns>modified string</returns> ! public static string Delete(string inString, string pattern) { ! if (inString == null || pattern == null || "".Equals(pattern)) { return inString; } ! return inString.Replace(pattern, ""); } ! /// <summary> Delete any character in a given string.</summary> ! /// <param name="inString">string to delete from</param> ! /// <param name="chars">characters to delete. E.g. az\n will delete "a"s, "z"s and new lines.</param> ! public static string DeleteAny(string inString, string chars) { ! if (inString == null || chars == null || "".Equals(chars) || inString.IndexOfAny(chars.ToCharArray()) == -1) { return inString; } ! ! StringBuilder sb = new StringBuilder(); ! for (int i = 0; i < inString.Length; i++) { ! char c = inString[i]; ! if (chars.IndexOf(c) == -1) { ! sb.Append(c); } } ! return sb.ToString(); } ! /// <summary> Tokenize the given String into a String array</summary> /// <remarks> ! /// <p>If <paramref>s</paramref> is null, mehod returns empty string array.</p> ! /// <p>If <paramref>delimiters</paramref> is null or empty string, ! /// mehod returns a string array with one element: <paramref>s</paramref> itself</p> /// </remarks> ! /// <param name="s">the string to tokenize</param> ! /// <param name="delimiters">the delimiter characters, assembled as String</param> ! /// <param name="trimTokens">trim the tokens via String.Trim</param> ! /// <param name="ignoreEmptyTokens">omit empty tokens from the result array</param> ! /// <returns> an array of the tokens</returns> ! public static string[] Split(string s, string delimiters, bool trimTokens, bool ignoreEmptyTokens) { if (s == null) { ! return new string[0]; } ! if (delimiters == null || "".Equals(delimiters)) { ! return new string[] {s}; } ! ! string[] tmp = s.Split(delimiters.ToCharArray()); ! // short circuit if String.Split default behavior is ok if (!trimTokens && !ignoreEmptyTokens) --- 77,166 ---- } ! /// <summary> ! /// Delete all occurrences of the given substring.</summary> ! /// <param name="inString"> ! /// The <see cref="System.String"/> to delete from. ! /// </param> ! /// <param name="pattern"> ! /// The pattern to delete all occurrences of. ! /// </param> ! /// <returns>The modified <see cref="System.String"/>.</returns> ! public static string Delete (string inString, string pattern) { ! if (inString == null ! || !StringUtils.HasText (pattern)) { return inString; } ! return inString.Replace (pattern, ""); } ! /// <summary> ! /// Delete any character in a given <see cref="System.String"/>. ! /// </summary> ! /// <param name="inString"> ! /// The <see cref="System.String"/> to delete from. ! /// </param> ! /// <param name="chars">The characters to delete.</param> ! /// <example> ! /// az\n as the characters to delete will delete "a"s, "z"s and new lines. ! /// </example> ! public static string DeleteAny (string inString, string chars) { ! if (inString == null ! || !StringUtils.HasText (chars) ! || inString.IndexOfAny (chars.ToCharArray ()) == -1) { return inString; } ! StringBuilder sb = new StringBuilder (); ! for (int i = 0; i < inString.Length; ++i) { ! char c = inString [i]; ! if (chars.IndexOf (c) == -1) { ! sb.Append (c); } } ! return sb.ToString (); } ! /// <summary> ! /// Tokenize the given <see cref="System.String"/> into a ! /// <see cref="System.String"/> array. ! /// </summary> /// <remarks> ! /// <p> ! /// If <paramref name="s"/> is null, mehod returns an empty ! /// <see cref="System.String"/> array. ! /// </p> ! /// <p> ! /// If <paramref name="delimiters"/> is null or empty <see cref="System.String"/>, ! /// mehod returns a <see cref="System.String"/> array with one ! /// element: <paramref name="s"/> itself. ! /// </p> /// </remarks> ! /// <param name="s">The <see cref="System.String"/> to tokenize.</param> ! /// <param name="delimiters"> ! /// The delimiter characters, assembled as a <see cref="System.String"/>. ! /// </param> ! /// <param name="trimTokens"> ! /// Trim the tokens via <see cref="System.String.Trim"/>. ! /// </param> ! /// <param name="ignoreEmptyTokens"> ! /// Omit empty tokens from the result array.</param> ! /// <returns>An array of the tokens.</returns> ! public static string [] Split ( ! string s, string delimiters, bool trimTokens, bool ignoreEmptyTokens) { if (s == null) { ! return new string [0]; } ! if (!StringUtils.HasText (delimiters)) { ! return new string [] {s}; } ! string[] tmp = s.Split (delimiters.ToCharArray ()); // short circuit if String.Split default behavior is ok if (!trimTokens && !ignoreEmptyTokens) *************** *** 124,169 **** else { ! ArrayList tokens = new ArrayList(tmp.Length); ! for (int i = 0; i < tmp.Length; i++) { ! string token = (trimTokens ? tmp[i].Trim() : tmp[i]); if (!(ignoreEmptyTokens && token.Length == 0)) { ! tokens.Add(token); } } ! ! return (string[]) tokens.ToArray(typeof(string)); } } /// <summary> ! /// Append the given String to the given String array, returning a new array ! /// consisting of the input array contents plus the given String. /// </summary> ! /// <param name="arr">the array to append to</param> ! /// <param name="s">the string to append</param> ! /// <returns> the new array </returns> ! public static string[] AddStringToArray(string[] arr, string s) { ! string[] newArr = new string[arr.Length + 1]; ! Array.Copy(arr, 0, newArr, 0, arr.Length); ! newArr[arr.Length] = s; return newArr; } ! /// <summary> Convert a CSV list into an array of Strings.</summary> /// <param name="s">CSV list /// </param> /// <returns> an array of Strings, or the empty array if s is null /// </returns> public static string[] CommaDelimitedListToStringArray(string s) { return DelimitedListToStringArray(s, ","); } ! /// <summary> Take a String which is a delimited list and convert it to a String array.</summary> /// <param name="s">String /// </param> /// <param name="delim">delim (this will not be returned) /// </param> /// <returns> an array of the tokens in the list /// </returns> public static string[] DelimitedListToStringArray(string s, string delim) { if (s == null) { return new string[0]; } if (delim == null) { return new string[]{s}; } ! return s.Split(delim[0]); } /// <summary> ! /// Convenience method to return a ICollection as a delimited (e.g. CSV) ! /// string. E.g. useful for ToString() implementations. /// </summary> ! /// <param name="c">ICollection to display</param> ! /// <param name="delim">delimiter to use (probably a ",")</param> ! /// <returns>the delimited string representation</returns> ! public static string CollectionToDelimitedString(ICollection c, string delim) { if (c == null) --- 170,228 ---- else { ! ArrayList tokens = new ArrayList (tmp.Length); ! for (int i = 0; i < tmp.Length; ++i) { ! string token = (trimTokens ? tmp [i].Trim () : tmp [i]); if (!(ignoreEmptyTokens && token.Length == 0)) { ! tokens.Add (token); } } ! return (string []) tokens.ToArray (typeof (string)); } } /// <summary> ! /// Append the given <see cref="System.String"/> to the given ! /// <see cref="System.String"/> array, returning a new array ! /// consisting of the input array contents plus the given ! /// <see cref="System.String"/>. /// </summary> ! /// <param name="arr">The array to append to.</param> ! /// <param name="s"> ! /// The <see cref="System.String"/> to append (may be null). ! /// </param> ! /// <returns>The new array.</returns> ! public static string [] AddStringToArray (string [] arr, string s) { ! if (s == null) ! { ! return arr; ! } ! string [] newArr = new string [arr.Length + 1]; ! Array.Copy (arr, 0, newArr, 0, arr.Length); ! newArr [arr.Length] = s; return newArr; } ! /// <summary> /// Convert a CSV list into an array of <see cref="System.String"/>s. /// </summary> /// <param name="s">A CSV list.</param> /// <returns> /// An array of <see cref="System.String"/>s, or the empty array /// if <paramref name="s"/> is null. /// </returns> public static string [] CommaDelimitedListToStringArray (string s) { return DelimitedListToStringArray (s, ","); } ! /// <summary> /// Take a <see cref="System.String"/> which is a delimited list /// and convert it to a <see cref="System.String"/> array. /// </summary> /// <param name="s"> /// The <see cref="System.String"/> to be parsed. /// </param> /// <param name="delim"> /// The delimeter (this will not be returned). /// </param> /// <returns> /// An array of the tokens in the list. /// </returns> public static string[] DelimitedListToStringArray ( string s, string delim) { if (s == null) { return new string [0]; } if (delim == null) { return new string [] {s}; } ! return s.Split (delim [0]); } /// <summary> ! /// Convenience method to return an ! /// <see cref="System.Collections.ICollection"/> as a delimited ! /// (e.g. CSV) <see cref="System.String"/>. /// </summary> ! /// <param name="c"> ! /// The <see cref="System.Collections.ICollection"/> to parse. ! /// </param> ! /// <param name="delim"> ! /// The delimiter to use (probably a ','). ! /// </param> ! /// <returns>The delimited string representation.</returns> ! public static string CollectionToDelimitedString ( ! ICollection c, string delim) { if (c == null) *************** *** 171,218 **** return "null"; } ! ! StringBuilder sb = new StringBuilder(); int i = 0; ! foreach(object obj in c) { if (i++ > 0) { ! sb.Append(delim); } ! sb.Append(obj); } ! return sb.ToString(); } /// <summary> ! /// Convenience method to return a ICollection as a CSV String. ! /// E.g. useful for ToString() implementations. /// </summary> ! /// <param name="c">ICollection to display</param> ! /// <returns>the delimited string representation</returns> ! public static string CollectionToCommaDelimitedString(ICollection c) { ! return CollectionToDelimitedString(c, ","); } ! /// <summary> Convenience method to return a String array as a CSV String. ! /// E.g. useful for toString() implementations. /// </summary> ! /// <param name="arr">array to display. Elements may be of any type (toString /// will be called on each element). /// </param> ! public static string ArrayToCommaDelimitedString(System.Object[] arr) { ! return ArrayToDelimitedString(arr, ","); } ! /// <summary> Convenience method to return a String array as a delimited (e.g. CSV) ! /// String. E.g. useful for toString() implementations. /// </summary> ! /// <param name="arr">array to display. Elements may be of any type (toString /// will be called on each element). /// </param> ! /// <param name="delim">delimiter to use (probably a ,) /// </param> ! public static string ArrayToDelimitedString(System.Object[] arr, string delim) { if (arr == null) --- 230,287 ---- return "null"; } ! StringBuilder sb = new StringBuilder (); int i = 0; ! foreach (object obj in c) { if (i++ > 0) { ! sb.Append (delim); } ! sb.Append (obj); } ! return sb.ToString (); } /// <summary> ! /// Convenience method to return an ! /// <see cref="System.Collections.ICollection"/> as a CSV ! /// <see cref="System.String"/>. /// </summary> ! /// <param name="c"> ! /// The <see cref="System.Collections.ICollection"/> to display. ! /// </param> ! /// <returns>The delimited string representation.</returns> ! public static string CollectionToCommaDelimitedString ( ! ICollection c) { ! return CollectionToDelimitedString (c, ","); } ! /// <summary> ! /// Convenience method to return a <see cref="System.String"/> ! /// array as a CSV <see cref="System.String"/>. /// </summary> ! /// <param name="arr"> ! /// The array to parse. Elements may be of any type (ToString /// will be called on each element). /// </param> ! public static string ArrayToCommaDelimitedString (object [] arr) { ! return ArrayToDelimitedString (arr, ","); } ! ! /// <summary> ! /// Convenience method to return a <see cref="System.String"/> ! /// array as a delimited (e.g. CSV) <see cref="System.String"/>. /// </summary> ! /// <param name="arr"> ! /// The array to parse. Elements may be of any type (ToString /// will be called on each element). /// </param> ! /// <param name="delim"> ! /// The delimiter to use (probably a ','). /// </param> ! public static string ArrayToDelimitedString ( ! object [] arr, string delim) { if (arr == null) *************** *** 222,239 **** else { ! System.Text.StringBuilder sb = new System.Text.StringBuilder(); ! for (int i = 0; i < arr.Length; i++) ! { ! if (i > 0) ! sb.Append(delim); ! sb.Append(arr[i]); ! } ! return sb.ToString(); } } /// <summary>Checks if a string has length.</summary> ! /// <param name="str">the string to check, may be null</param> ! /// <returns> <c>true</c> if the string has length and is not null</returns> /// <example> /// <code> --- 291,303 ---- else { ! return StringUtils.CollectionToDelimitedString (arr, delim); } } /// <summary>Checks if a string has length.</summary> ! /// <param name="str">The string to check, may be null.</param> ! /// <returns> ! /// True if the string has length and is not null. ! /// </returns> /// <example> /// <code> *************** *** 244,258 **** /// </code> /// </example> ! public static bool HasLength(string str) { return (str != null && str.Length > 0); } ! /// <summary> Checks if a String has text. More specifically, returns <c>true</c> ! /// if the string not <c>null</c>, it's <c>length is > 0</c>, and ! /// it has at least one non-whitespace character. /// </summary> ! /// <param name="str">the string to check, may be null</param> ! /// <returns> <c>true</c> if the String is not null, length > 0, and not whitespace only</returns> /// <example> /// <code> --- 308,331 ---- /// </code> /// </example> ! public static bool HasLength (string str) { return (str != null && str.Length > 0); } ! /// <summary> ! /// Checks if a <see cref="System.String"/> has text. /// </summary> ! /// <remarks> ! /// <p> ! /// More specifically, returns <c>true</c> if the string is not ! /// <c>null</c>, it's <c>length is > 0</c>, and it has at least ! /// one non-whitespace character. ! /// </p> ! /// </remarks> ! /// <param name="str">The string to check, may be null</param> ! /// <returns> ! /// True if the <paramref name="str"/> is not null, length > 0, ! /// and not whitespace only. ! /// </returns> /// <example> /// <code> *************** *** 264,268 **** /// </code> /// </example> ! public static bool HasText(string str) { if (str == null) --- 337,341 ---- /// </code> /// </example> ! public static bool HasText (string str) { if (str == null) *************** *** 272,294 **** else { ! return HasLength(str.Trim()); } } ! /// <summary> Unqualifies a string qualified by a '.' dot character. ! /// For example, "this.name.is.qualified", returns "qualified". /// </summary> ! /// <param name="qualifiedName">the qualified name</param> ! public static string Unqualify(string qualifiedName) { ! return Unqualify(qualifiedName, '.'); } ! /// <summary> Unqualifies a string qualified by a separator character. For example, ! /// "this:name:is:qualified" returns "qualified" if using a ':' separator. /// </summary> ! /// <param name="qualifiedName">the qualified name</param> ! /// <param name="separator">the separator character</param> ! public static string Unqualify(string qualifiedName, char separator) { if (qualifiedName == null) --- 345,376 ---- else { ! return HasLength (str.Trim ()); } } ! /// <summary> ! /// Unqualifies a string qualified by a '.' dot character. /// </summary> ! /// <param name="qualifiedName">The qualified name.</param> ! /// <returns>The unqualified string.</returns> ! /// <example> ! /// "this.name.is.qualified", returns "qualified". ! /// </example> ! public static string Unqualify (string qualifiedName) { ! return Unqualify (qualifiedName, '.'); } ! /// <summary> ! /// Unqualifies a string qualified by a separator character. /// </summary> ! /// <param name="qualifiedName">The qualified name.</param> ! /// <param name="separator">The separator character.</param> ! /// <example> ! /// "this:name:is:qualified" returns "qualified" if using a ! /// ':' separator. ! /// </example> ! public static string Unqualify ( ! string qualifiedName, char separator) { if (qualifiedName == null) *************** *** 296,309 **** return null; } ! ! return qualifiedName.Substring(qualifiedName.LastIndexOf(separator) + 1); } ! /// <summary> Uncapitalizes a string, changing the first letter to /// lower case. No other letters are changed. /// </summary> ! /// <param name="str">the string to uncapitalize, may be null</param> ! /// <returns> the uncapitalized string, <c>null</c> if input string is null</returns> ! public static string Uncapitalize(string str) { int strLen; --- 378,395 ---- return null; } ! return qualifiedName.Substring ( ! qualifiedName.LastIndexOf (separator) + 1); } ! /// <summary> ! /// Uncapitalizes a string, changing the first letter to /// lower case. No other letters are changed. /// </summary> ! /// <param name="str"> ! /// The string to uncapitalize, may be null.</param> ! /// <returns> ! /// The uncapitalized string, <c>null</c> if input string is null. ! /// </returns> ! public static string Uncapitalize (string str) { int strLen; *************** *** 312,320 **** return str; } ! ! StringBuilder sb = new StringBuilder(strLen); ! sb.Append(Char.ToLower(str[0])); ! sb.Append(str.Substring(1)); ! return sb.ToString(); } } --- 398,405 ---- return str; } ! StringBuilder sb = new StringBuilder (strLen); ! sb.Append (Char.ToLower (str[0])); ! sb.Append (str.Substring (1)); ! return sb.ToString (); } } Index: MethodInvoker.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Util/MethodInvoker.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MethodInvoker.cs 23 Jul 2004 10:14:53 -0000 1.1 --- MethodInvoker.cs 26 Jul 2004 07:47:57 -0000 1.2 *************** *** 146,150 **** string typeName = staticMethod.Substring(0, lastDotIndex); string methodName = staticMethod.Substring(lastDotIndex + 1); ! TargetType = ObjectUtils.LocateType(typeName); TargetMethod = methodName; } --- 146,150 ---- string typeName = staticMethod.Substring(0, lastDotIndex); string methodName = staticMethod.Substring(lastDotIndex + 1); ! TargetType = ObjectUtils.ResolveType(typeName); TargetMethod = methodName; } Index: TypeAliasResolver.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Util/TypeAliasResolver.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TypeAliasResolver.cs 23 Jul 2004 10:14:53 -0000 1.1 --- TypeAliasResolver.cs 26 Jul 2004 07:47:57 -0000 1.2 *************** *** 45,48 **** --- 45,49 ---- /// </p> /// </remarks> + /// <version>$Id$</version> public sealed class TypeAliasResolver { *************** *** 182,186 **** if (type != null) { ! if (TypeAliasResolver.Aliases.ContainsKey (type)) { return TypeAliasResolver.Aliases [type] as string; --- 183,187 ---- if (type != null) { ! if (TypeAliasResolver.Aliases.ContainsKey (type.ToLower ())) { return TypeAliasResolver.Aliases [type] as string; |
From: Springboy <spr...@us...> - 2004-07-26 07:48:09
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Support In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18183/Spring/Spring.Core/Objects/Factory/Support Modified Files: AbstractAutowireCapableObjectFactory.cs AbstractObjectFactory.cs DefaultListableObjectFactory.cs IObjectDefinitionRegistry.cs PropertiesObjectDefinitionReader.cs RootObjectDefinition.cs Log Message: Added centralised Type resolution mechanism, runtime type converter, Xml Config handler, multiple documentation updates. Index: RootObjectDefinition.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Support/RootObjectDefinition.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RootObjectDefinition.cs 16 Jul 2004 13:59:03 -0000 1.4 --- RootObjectDefinition.cs 26 Jul 2004 07:47:57 -0000 1.5 *************** *** 458,462 **** throw new ObjectDefinitionValidationException ( "IFactoryObject must be defined as singleton - " + ! "IFactoryObjects themselves are not allowed to be prototypes"); } if (ObjectClass.GetConstructors ().Length == 0) --- 458,462 ---- throw new ObjectDefinitionValidationException ( "IFactoryObject must be defined as singleton - " + ! "IFactoryObjects themselves are not allowed to be prototypes."); } if (ObjectClass.GetConstructors ().Length == 0) Index: AbstractAutowireCapableObjectFactory.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Support/AbstractAutowireCapableObjectFactory.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AbstractAutowireCapableObjectFactory.cs 16 Jul 2004 13:59:03 -0000 1.2 --- AbstractAutowireCapableObjectFactory.cs 26 Jul 2004 07:47:56 -0000 1.3 *************** *** 59,62 **** --- 59,63 ---- /// <author>Juergen Hoeller</author> /// <author>Rick Evans (.NET)</author> + /// <version>$Id$</version> public abstract class AbstractAutowireCapableObjectFactory : AbstractObjectFactory, IAutowireCapableObjectFactory *************** *** 132,136 **** /// <remarks> /// <p> ! /// Must use deep copy, so that we don&t permanently modify this property. /// </p> /// </remarks> --- 133,137 ---- /// <remarks> /// <p> ! /// Must use deep copy, so that we don't permanently modify this property. /// </p> /// </remarks> *************** *** 147,151 **** MutablePropertyValues deepCopy = new MutablePropertyValues (pvs); PropertyValue [] pvals = deepCopy.PropertyValues; ! for (int i = 0; i < pvals.Length; i++) { object value = ResolveValueIfNecessary ( --- 148,152 ---- MutablePropertyValues deepCopy = new MutablePropertyValues (pvs); PropertyValue [] pvals = deepCopy.PropertyValues; ! for (int i = 0; i < pvals.Length; ++i) { object value = ResolveValueIfNecessary ( *************** *** 847,851 **** /// </p> /// <p> ! /// Custom init methods are reolved in a <b>case-insensitive</b> manner. /// </p> /// </remarks> --- 848,852 ---- /// </p> /// <p> ! /// Custom init methods are resolved in a <b>case-insensitive</b> manner. /// </p> /// </remarks> *************** *** 854,858 **** /// </param> /// <param name="objectName"> ! /// The object has in the factory. Used for debug output. /// </param> /// <param name="mergedObjectDefinition"> --- 855,859 ---- /// </param> /// <param name="objectName"> ! /// The name the object has in the factory. Used for debug output. /// </param> /// <param name="mergedObjectDefinition"> *************** *** 864,868 **** RootObjectDefinition mergedObjectDefinition) { - if (target is IInitializingObject) { --- 865,868 ---- *************** *** 879,883 **** ((IInitializingObject) target).AfterPropertiesSet (); } - if (mergedObjectDefinition.InitMethodName != null) { --- 879,882 ---- *************** *** 946,950 **** /// </p> /// <p> ! /// Custom destroy methods are reolved in a <b>case-insensitive</b> manner. /// </p> /// </remarks> --- 945,949 ---- /// </p> /// <p> ! /// Custom destroy methods are resolved in a <b>case-insensitive</b> manner. /// </p> /// </remarks> *************** *** 1080,1084 **** } } - try { --- 1079,1082 ---- Index: AbstractObjectFactory.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AbstractObjectFactory.cs 9 Jul 2004 15:03:37 -0000 1.2 --- AbstractObjectFactory.cs 26 Jul 2004 07:47:57 -0000 1.3 *************** *** 65,69 **** /// <p> /// For example, if the/ managed object identified as <code>foo</code> is a ! /// factory, getting <code>&foo</code> will return the factory, not the /// instance returned by the factory. /// </p> --- 65,69 ---- /// <p> /// For example, if the/ managed object identified as <code>foo</code> is a ! /// factory, getting <code>'foo</code> will return the factory, not the /// instance returned by the factory. /// </p> Index: PropertiesObjectDefinitionReader.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Support/PropertiesObjectDefinitionReader.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PropertiesObjectDefinitionReader.cs 23 Jul 2004 10:17:58 -0000 1.2 --- PropertiesObjectDefinitionReader.cs 26 Jul 2004 07:47:57 -0000 1.3 *************** *** 404,411 **** if (typeName != null) { ! // Load the type using a special class loader if one is available. ! // Otherwise rely on the thread context classloader. ! // Class clazz = Class.forName(className, true, getBeanClassLoader()); ! Type type = ObjectUtils.LocateType(typeName) ; if (type == null) { --- 404,408 ---- if (typeName != null) { ! Type type = ObjectUtils.ResolveType (typeName) ; if (type == null) { *************** *** 418,422 **** objectDefinition = new ChildObjectDefinition(parent, pvs); } - objectDefinition.IsSingleton = singleton; objectDefinition.LazyInit = lazyInit; --- 415,418 ---- Index: IObjectDefinitionRegistry.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Support/IObjectDefinitionRegistry.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IObjectDefinitionRegistry.cs 6 Jul 2004 12:54:27 -0000 1.1 --- IObjectDefinitionRegistry.cs 26 Jul 2004 07:47:57 -0000 1.2 *************** *** 48,52 **** public interface IObjectDefinitionRegistry { - /// <summary> /// Return the number of objects defined in the registry. --- 48,51 ---- *************** *** 58,62 **** { get; - } --- 57,60 ---- *************** *** 104,108 **** /// <summary> /// Register a new object definition with this registry. ! /// Must support RootBeanDefinition and ChildBeanDefinition. /// </summary> /// <param name="name"> --- 102,108 ---- /// <summary> /// Register a new object definition with this registry. ! /// Must support ! /// <see cref="Spring.Objects.Factory.Support.RootObjectDefinition"/> ! /// and <see cref="Spring.Objects.Factory.Support.ChildObjectDefinition"/>. /// </summary> /// <param name="name"> Index: DefaultListableObjectFactory.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Support/DefaultListableObjectFactory.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DefaultListableObjectFactory.cs 16 Jul 2004 13:59:03 -0000 1.2 --- DefaultListableObjectFactory.cs 26 Jul 2004 07:47:57 -0000 1.3 *************** *** 284,288 **** objectDefinition.ResourceDescription, name, ! "Validation of object definition with name failed", ex); } --- 284,288 ---- objectDefinition.ResourceDescription, name, ! "Validation of object definition with name failed.", ex); } |
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18183/Spring/Spring.Core/Objects/Factory/Xml Modified Files: DefaultXmlObjectDefinitionParser.cs IXmlObjectDefinitionParser.cs ObjectsDtd.cs ObjectsDtdResolver.cs XmlObjectFactory.cs Log Message: Added centralised Type resolution mechanism, runtime type converter, Xml Config handler, multiple documentation updates. Index: IXmlObjectDefinitionParser.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Xml/IXmlObjectDefinitionParser.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IXmlObjectDefinitionParser.cs 6 Jul 2004 12:54:27 -0000 1.1 --- IXmlObjectDefinitionParser.cs 26 Jul 2004 07:47:57 -0000 1.2 *************** *** 36,45 **** /// <remarks> /// <p> ! /// Used by XmlBeanDefinitionReader for actually parsing a DOM document. /// </p> /// <p> /// Instantiated per document to parse: implementations can hold state in ! /// instance variables during the execution of the registerBeanDefinitions ! /// method, for example global settings that are defined for all bean /// definitions in the document. /// </p> --- 36,46 ---- /// <remarks> /// <p> ! /// Used by XmlObjectDefinitionReader for actually parsing a DOM document. /// </p> /// <p> /// Instantiated per document to parse: implementations can hold state in ! /// instance variables during the execution of the ! /// <see cref="Spring.Objects.Factory.Xml.IXmlObjectDefinitionParser.RegisterObjectDefinitions"/> ! /// method, for example global settings that are defined for all object /// definitions in the document. /// </p> *************** *** 49,53 **** public interface IXmlObjectDefinitionParser { - /// <summary> /// Parse object definitions from the given DOM node, and register them with the --- 50,53 ---- Index: ObjectsDtdResolver.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsDtdResolver.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ObjectsDtdResolver.cs 9 Jul 2004 15:03:37 -0000 1.1 --- ObjectsDtdResolver.cs 26 Jul 2004 07:47:57 -0000 1.2 *************** *** 37,41 **** /// <summary> /// <see cref="System.Xml.XmlResolver"/> implementation for the Spring objects DTD, ! /// to load the DTD from the... /// </summary> /// <author>Juergen Hoeller</author> --- 37,41 ---- /// <summary> /// <see cref="System.Xml.XmlResolver"/> implementation for the Spring objects DTD, ! /// to load the DTD from an embedded resource. /// </summary> /// <author>Juergen Hoeller</author> *************** *** 45,49 **** #region Constants ! private const string DtdLookup = "spring-objects.dtd"; private const string DtdResourceKey = "spring.net.dtd"; --- 45,49 ---- #region Constants ! private const string DtdLookup = "SPRING/DTD"; private const string DtdResourceKey = "spring.net.dtd"; *************** *** 117,140 **** { object entity = null; ! try ! { ! // #$%£"! try load it from a resource embedded within this assembly ! string dtd = MyResources.GetString ( ! DtdResourceKey, ! CultureInfo.CurrentUICulture); ! byte [] dtdBytes = new UTF8Encoding ().GetBytes (dtd); ! // mmm... ! entity = new MemoryStream (dtdBytes, false); ! } ! catch (Exception ex) { ! #region Instrumentation ! if (log.IsDebugEnabled) { ! log.Debug ( ! "Exception thrown when retrieving DTD resource.", ! ex); } - #endregion } // if null, try the default behaviour -> download from a website or wherever --- 117,143 ---- { object entity = null; ! if (absoluteUri.AbsoluteUri.IndexOf (DtdLookup) >= 0) { ! try { ! // #$%£"! try load it from a resource embedded within this assembly ! string dtd = MyResources.GetString ( ! DtdResourceKey, ! CultureInfo.CurrentUICulture); ! byte [] dtdBytes = new UTF8Encoding ().GetBytes (dtd); ! // mmm... ! entity = new MemoryStream (dtdBytes, false); ! } ! catch (Exception ex) ! { ! #region Instrumentation ! if (log.IsDebugEnabled) ! { ! log.Debug ( ! "Exception thrown when retrieving DTD resource.", ! ex); ! } ! #endregion } } // if null, try the default behaviour -> download from a website or wherever Index: XmlObjectFactory.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Xml/XmlObjectFactory.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XmlObjectFactory.cs 16 Jul 2004 13:59:03 -0000 1.2 --- XmlObjectFactory.cs 26 Jul 2004 07:47:57 -0000 1.3 *************** *** 64,67 **** --- 64,68 ---- /// <author>Juergen Hoeller</author> /// <author>Rick Evans (.NET)</author> + /// <version>$Id$</version> public class XmlObjectFactory : DefaultListableObjectFactory { *************** *** 69,90 **** #region Constructor (s) / Destructor /// <summary> - /// Creates a new instance of the XmlObjectFactory class. - /// </summary> - public XmlObjectFactory () - { - } - - /// <summary> - /// Creates a new instance of the XmlObjectFactory class. - /// </summary> - /// <param name="parentFactory"> - /// The parent object factory. - /// </param> - public XmlObjectFactory (IObjectFactory parentFactory) - : base (parentFactory) - { - } - - /// <summary> /// Creates a new instance of the XmlObjectFactory class, with the /// given resource, which must be parsable using DOM. --- 70,73 ---- *************** *** 128,159 **** #endregion - #region Methods - /// <summary> - /// Loads object definitions from an application / web config file section. - /// </summary> - /// <seealso cref="Spring.Objects.Factory.Xml.ObjectsDefinitionConfigResource"/> - public void LoadObjectDefinitionsFromConfig () - { - LoadObjectDefinitionsFromConfig ( - ObjectsDefinitionConfigResource.DefaultConfigSectionName); - } - - /// <summary> - /// Loads object definitions from an application / web config file section. - /// </summary> - /// <param name="name"> - /// The name of the config section element containing object definitions. - /// </param> - /// <seealso cref="Spring.Objects.Factory.Xml.ObjectsDefinitionConfigResource"/> - public void LoadObjectDefinitionsFromConfig (string name) - { - _reader = new XmlObjectDefinitionReader (this); - XmlElement objectsElement - = ConfigurationSettings.GetConfig (name) as XmlElement; - _reader.LoadObjectDefinitions ( - objectsElement, new ObjectsDefinitionConfigResource ()); - } - #endregion - #region Fields private XmlObjectDefinitionReader _reader; --- 111,114 ---- Index: ObjectsDtd.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Xml/ObjectsDtd.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ObjectsDtd.cs 13 Jul 2004 07:47:45 -0000 1.2 --- ObjectsDtd.cs 26 Jul 2004 07:47:57 -0000 1.3 *************** *** 39,43 **** public sealed class ObjectsDtd { - /// <summary> /// Value of a T/F attribute that represents true. --- 39,42 ---- *************** *** 51,55 **** /// <summary> ! /// /// </summary> public const string DefaultValue = "default"; --- 50,54 ---- /// <summary> ! /// Signifies that a default value is to be applied. /// </summary> public const string DefaultValue = "default"; *************** *** 218,221 **** --- 217,230 ---- /// /// </summary> + public const string AutowireAttribute = "autowire"; + + /// <summary> + /// The string of characters that delimit object names. + /// </summary> + public const string ObjectNameDelimeters = ",; "; + + /// <summary> + /// + /// </summary> public static readonly string DependencyCheckAllAttributeValue = Enum.GetName (typeof (DependencyCheckingMode), DependencyCheckingMode.All); *************** *** 236,244 **** /// /// </summary> - public const string AutowireAttribute = "autowire"; - - /// <summary> - /// - /// </summary> public static readonly string AutowireByNameValue = Enum.GetName (typeof (AutoWiringMode), AutoWiringMode.ByName); --- 245,248 ---- *************** *** 271,275 **** /// </p> /// </remarks> ! private ObjectsDtd () { } --- 275,279 ---- /// </p> /// </remarks> ! private ObjectsDtd () { } Index: DefaultXmlObjectDefinitionParser.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Xml/DefaultXmlObjectDefinitionParser.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DefaultXmlObjectDefinitionParser.cs 23 Jul 2004 10:18:28 -0000 1.6 --- DefaultXmlObjectDefinitionParser.cs 26 Jul 2004 07:47:57 -0000 1.7 *************** *** 41,68 **** { ! /// <summary> ! /// Default implementation of the ! /// <see cref="Spring.Objects.Factory.Xml.IXmlObjectDefinitionParser"/> interface. ! /// </summary> ! /// <remarks> ! /// <p> ! /// Parses object definitions according to the "spring-objects" DTD. ! /// </p> /// </remarks> /// <author>Rod Johnson</author> /// <author>Juergen Hoeller</author> /// <author>Rick Evans (.NET)</author> ! public class DefaultXmlObjectDefinitionParser : IXmlObjectDefinitionParser { #region Constants /// <summary> - /// The string of characters that delimit object names. - /// </summary> - public const string ObjectNameDelimeters = ",; "; - - /// <summary> /// The shared ILog instance for this class (and derived classes). /// </summary> ! protected static readonly ILog logger = LogManager.GetLogger (typeof (DefaultXmlObjectDefinitionParser)); #endregion --- 41,65 ---- { ! /// <summary> ! /// Default implementation of the ! /// <see cref="Spring.Objects.Factory.Xml.IXmlObjectDefinitionParser"/> interface. ! /// </summary> ! /// <remarks> ! /// <p> ! /// Parses object definitions according to the "spring-objects" DTD. ! /// </p> /// </remarks> /// <author>Rod Johnson</author> /// <author>Juergen Hoeller</author> /// <author>Rick Evans (.NET)</author> ! public class DefaultXmlObjectDefinitionParser ! : IXmlObjectDefinitionParser ! { #region Constants /// <summary> /// The shared ILog instance for this class (and derived classes). /// </summary> ! protected static readonly ILog log = LogManager.GetLogger (typeof (DefaultXmlObjectDefinitionParser)); #endregion *************** *** 72,76 **** /// Creates a new instance of the DefaultXmlObjectDefinitionParser class. /// </summary> ! public DefaultXmlObjectDefinitionParser () { } --- 69,73 ---- /// Creates a new instance of the DefaultXmlObjectDefinitionParser class. /// </summary> ! public DefaultXmlObjectDefinitionParser () { } *************** *** 82,90 **** /// that is being (or is to be) populated with object definitions. /// </summary> ! protected IObjectDefinitionRegistry ObjectFactory { get { ! return _objectFactory; } } --- 79,87 ---- /// that is being (or is to be) populated with object definitions. /// </summary> ! protected IObjectDefinitionRegistry ObjectRegistry { get { ! return _objectRegistry; } } *************** *** 190,201 **** bool resolveTypes) { ! _objectFactory = objectRegistry; _resolveTypes = resolveTypes; _resource = resource; #region Instrumentation ! if (logger.IsDebugEnabled) { ! logger.Debug ("Loading object definitions..."); } #endregion --- 187,198 ---- bool resolveTypes) { ! _objectRegistry = objectRegistry; _resolveTypes = resolveTypes; _resource = resource; #region Instrumentation ! if (log.IsDebugEnabled) { ! log.Debug ("Loading object definitions..."); } #endregion *************** *** 204,210 **** #region Instrumentation ! if (logger.IsDebugEnabled) { ! logger.Debug ( string.Format ( System.Globalization.CultureInfo.CurrentUICulture, --- 201,207 ---- #region Instrumentation ! if (log.IsDebugEnabled) { ! log.Debug ( string.Format ( System.Globalization.CultureInfo.CurrentUICulture, *************** *** 217,223 **** #region Instrumentation ! if (logger.IsDebugEnabled) { ! logger.Debug ( string.Format ( System.Globalization.CultureInfo.CurrentUICulture, --- 214,220 ---- #region Instrumentation ! if (log.IsDebugEnabled) { ! log.Debug ( string.Format ( System.Globalization.CultureInfo.CurrentUICulture, *************** *** 230,236 **** #region Instrumentation ! if (logger.IsDebugEnabled) { ! logger.Debug ( string.Format ( System.Globalization.CultureInfo.CurrentUICulture, --- 227,233 ---- #region Instrumentation ! if (log.IsDebugEnabled) { ! log.Debug ( string.Format ( System.Globalization.CultureInfo.CurrentUICulture, *************** *** 248,259 **** #region Instrumentation ! if (logger.IsDebugEnabled) { ! logger.Debug ( string.Format ( ! System.Globalization.CultureInfo.CurrentUICulture, ! "Found {0} <{1}> elements defining objects.", ! objectDefinitionCounter, ! ObjectsDtd.ObjectElement)); } #endregion --- 245,256 ---- #region Instrumentation ! if (log.IsDebugEnabled) { ! log.Debug ( string.Format ( ! System.Globalization.CultureInfo.CurrentUICulture, ! "Found {0} <{1}> elements defining objects.", ! objectDefinitionCounter, ! ObjectsDtd.ObjectElement)); } #endregion *************** *** 279,285 **** && nameAttr.Length > 0) { ! string [] names = ! StringUtils.Split ( ! nameAttr, ObjectNameDelimeters, true, true); foreach (string name in names) { --- 276,280 ---- && nameAttr.Length > 0) { ! string [] names = GetObjectNames (nameAttr); foreach (string name in names) { *************** *** 288,294 **** } // if we ain't got an id, assign any existing (first) alias ! if (id == null ! || string.Empty.Equals (id) ! && aliases.Count > 0) { string firstAlias = aliases [0]; --- 283,287 ---- } // if we ain't got an id, assign any existing (first) alias ! if (!StringUtils.HasText (id) && aliases.Count > 0) { string firstAlias = aliases [0]; *************** *** 297,301 **** #region Instrumentation ! if (logger.IsDebugEnabled) { StringBuilder buffer = new StringBuilder (); --- 290,294 ---- #region Instrumentation ! if (log.IsDebugEnabled) { StringBuilder buffer = new StringBuilder (); *************** *** 304,313 **** buffer.Append (alias).Append (","); } ! logger.Debug ( string.Format ( ! System.Globalization.CultureInfo.CurrentUICulture, ! "No XML 'id' specified - using '{0}' as ID and {1} as aliases.", ! id, ! buffer.ToString ())); } #endregion --- 297,306 ---- buffer.Append (alias).Append (","); } ! log.Debug ( string.Format ( ! System.Globalization.CultureInfo.CurrentUICulture, ! "No XML 'id' specified - using '{0}' as ID and {1} as aliases.", ! id, ! buffer.ToString ())); } #endregion *************** *** 315,319 **** AbstractObjectDefinition objectDefinition = ParseObjectDefinition (ele, id); ! if (id == null || string.Empty.Equals (id)) { if (objectDefinition is RootObjectDefinition) --- 308,312 ---- AbstractObjectDefinition objectDefinition = ParseObjectDefinition (ele, id); ! if (!StringUtils.HasText (id)) { if (objectDefinition is RootObjectDefinition) *************** *** 322,328 **** #region Instrumentation ! if (logger.IsDebugEnabled) { ! logger.Debug ( string.Format ( System.Globalization.CultureInfo.CurrentUICulture, --- 315,321 ---- #region Instrumentation ! if (log.IsDebugEnabled) { ! log.Debug ( string.Format ( System.Globalization.CultureInfo.CurrentUICulture, *************** *** 342,348 **** #region Instrumentation ! if (logger.IsDebugEnabled) { ! logger.Debug ( string.Format ( System.Globalization.CultureInfo.CurrentUICulture, --- 335,341 ---- #region Instrumentation ! if (log.IsDebugEnabled) { ! log.Debug ( string.Format ( System.Globalization.CultureInfo.CurrentUICulture, *************** *** 352,358 **** #endregion ! _objectFactory.RegisterObjectDefinition (id, objectDefinition); ! foreach (string alias in aliases) { ! _objectFactory.RegisterAlias (id, alias); } } --- 345,352 ---- #endregion ! ObjectRegistry.RegisterObjectDefinition (id, objectDefinition); ! foreach (string alias in aliases) ! { ! ObjectRegistry.RegisterAlias (id, alias); } } *************** *** 391,398 **** objectName, string.Format ( ! System.Globalization.CultureInfo.CurrentUICulture, ! "Either '{0}' or '{1}' is required.", ! ObjectsDtd.ClassAttribute, ! ObjectsDtd.ParentAttribute)); } AbstractObjectDefinition bd = null; --- 385,392 ---- objectName, string.Format ( ! System.Globalization.CultureInfo.CurrentUICulture, ! "Either '{0}' or '{1}' is required.", ! ObjectsDtd.ClassAttribute, ! ObjectsDtd.ParentAttribute)); } AbstractObjectDefinition bd = null; *************** *** 406,420 **** if (ResolveTypes) { ! Type type = ResolveType(className); ! rbd = new RootObjectDefinition(type, cargs, pvs); } else { ! rbd = new RootObjectDefinition(className, cargs, pvs); } if (ele.HasAttribute (ObjectsDtd.DependsOnAttribute)) { string dependsOn = ele.GetAttribute (ObjectsDtd.DependsOnAttribute); ! rbd.DependsOn = StringUtils.Split (dependsOn, ObjectNameDelimeters, true, true); } string dependencyCheck = ele.GetAttribute (ObjectsDtd.DependencyCheckAttribute); --- 400,414 ---- if (ResolveTypes) { ! Type type = ObjectUtils.ResolveType (className); ! rbd = new RootObjectDefinition (type, cargs, pvs); } else { ! rbd = new RootObjectDefinition (className, cargs, pvs); } if (ele.HasAttribute (ObjectsDtd.DependsOnAttribute)) { string dependsOn = ele.GetAttribute (ObjectsDtd.DependsOnAttribute); ! rbd.DependsOn = GetObjectNames (dependsOn); } string dependencyCheck = ele.GetAttribute (ObjectsDtd.DependencyCheckAttribute); *************** *** 431,467 **** rbd.AutowireMode = GetAutowireMode(autowire); string initMethodName = ele.GetAttribute(ObjectsDtd.InitMethodAttribute); ! if (!initMethodName.Equals(string.Empty)) { rbd.InitMethodName = initMethodName; } ! string destroyMethodName = ele.GetAttribute(ObjectsDtd.DestroyMethodAttribute); ! if (!destroyMethodName.Equals(string.Empty)) { rbd.DestroyMethodName = destroyMethodName; } - bd = rbd; } else { ! bd = new ChildObjectDefinition(parent, pvs); } ! ! if (ele.HasAttribute(ObjectsDtd.SingletonAttribute)) { ! bd.IsSingleton = ObjectsDtd.TrueValue.Equals (ele.GetAttribute(ObjectsDtd.SingletonAttribute)); } ! ! string lazyInit = ele.GetAttribute(ObjectsDtd.LazyInitAttribute); ! if (ObjectsDtd.DefaultValue.Equals(lazyInit) && bd.IsSingleton) { // just apply default to singletons, as lazy-init has no meaning for prototypes lazyInit = _defaultLazyInit; } ! bd.LazyInit = ObjectsDtd.TrueValue.Equals(lazyInit); bd.ResourceDescription = _resource.Description; return bd; } ! catch (TypeLoadException ex) { throw new ObjectDefinitionStoreException ( --- 425,458 ---- rbd.AutowireMode = GetAutowireMode(autowire); string initMethodName = ele.GetAttribute(ObjectsDtd.InitMethodAttribute); ! if (StringUtils.HasText (initMethodName)) { rbd.InitMethodName = initMethodName; } ! string destroyMethodName = ele.GetAttribute (ObjectsDtd.DestroyMethodAttribute); ! if (StringUtils.HasText (destroyMethodName)) { rbd.DestroyMethodName = destroyMethodName; } bd = rbd; } else { ! bd = new ChildObjectDefinition (parent, pvs); } ! if (ele.HasAttribute (ObjectsDtd.SingletonAttribute)) { ! bd.IsSingleton = ObjectsDtd.TrueValue.Equals (ele.GetAttribute (ObjectsDtd.SingletonAttribute)); } ! string lazyInit = ele.GetAttribute (ObjectsDtd.LazyInitAttribute); ! if (ObjectsDtd.DefaultValue.Equals (lazyInit) && bd.IsSingleton) { // just apply default to singletons, as lazy-init has no meaning for prototypes lazyInit = _defaultLazyInit; } ! bd.LazyInit = ObjectsDtd.TrueValue.Equals (lazyInit); bd.ResourceDescription = _resource.Description; return bd; } ! catch (TypeLoadException ex) { throw new ObjectDefinitionStoreException ( *************** *** 469,478 **** objectName, string.Format ( ! System.Globalization.CultureInfo.CurrentUICulture, ! "Object class [{0}] not found.", ! className), ex); } ! catch (ApplicationException err) { throw new ObjectDefinitionStoreException ( --- 460,469 ---- objectName, string.Format ( ! System.Globalization.CultureInfo.CurrentUICulture, ! "Object class [{0}] not found.", ! className), ex); } ! catch (ApplicationException ex) { throw new ObjectDefinitionStoreException ( *************** *** 480,535 **** objectName, string.Format ( ! System.Globalization.CultureInfo.CurrentUICulture, ! "Class that object class [{0}] depends on not found.", ! className), ! err); } } ! /// <summary> ! /// Try to convert a string definig a type to a System.Type ! /// </summary> ! /// <param name="partialOrFullClassName"></param> ! /// <returns></returns> ! Type ResolveType (string partialOrFullClassName) ! { ! Type type = Type.GetType (partialOrFullClassName); ! if (type != null) ! return type; ! ! string[] splitted = partialOrFullClassName.Split (new char[] {','}); ! if (splitted.Length > 1) ! { ! Assembly assembly = LoadAssembly (partialOrFullClassName); ! return assembly.GetType (splitted[0]); ! } ! throw new ObjectDefinitionException (partialOrFullClassName); ! } ! ! private Assembly LoadAssembly (string className) ! { ! string assemblyName = ! className.Substring (className.IndexOf (',') + 1).Trim (); ! ! Assembly assembly = ! assembly = Assembly.LoadWithPartialName (assemblyName); ! return assembly; ! } ! ! /// <summary> ! /// Parse constructor argument subelements of the given object element. /// </summary> ! /// <param name="objectName"></param> ! /// <param name="objectEle"></param> ! /// <returns></returns> ! protected internal virtual ConstructorArgumentValues GetConstructorArgSubElements ( string objectName, XmlElement objectEle) { XmlNodeList nl = objectEle.ChildNodes; ConstructorArgumentValues cargs = new ConstructorArgumentValues (); ! for (int i = 0; i < nl.Count; ++i) { ! XmlNode node = nl.Item(i); ! if (node is XmlElement && ObjectsDtd.ConstructorArgElement.Equals (node.Name)) { ParseConstructorArgElement (objectName, cargs, (XmlElement) node); --- 471,493 ---- objectName, string.Format ( ! System.Globalization.CultureInfo.CurrentUICulture, ! "Class that object class [{0}] depends on not found.", ! className), ! ex); } } ! /// <summary> ! /// Parse constructor argument subelements of the given object element. /// </summary> ! protected ConstructorArgumentValues GetConstructorArgSubElements ( string objectName, XmlElement objectEle) { XmlNodeList nl = objectEle.ChildNodes; ConstructorArgumentValues cargs = new ConstructorArgumentValues (); ! foreach (XmlNode node in nl) { ! if (node is XmlElement ! && ObjectsDtd.ConstructorArgElement.Equals (node.Name)) { ParseConstructorArgElement (objectName, cargs, (XmlElement) node); *************** *** 548,553 **** /// The element containing the top level object definition. /// </param> ! /// <returns>The property (s) associated with the object (definition).</returns> ! protected internal virtual MutablePropertyValues GetPropertyValueSubElements ( string objectName, XmlElement objectEle) { --- 506,513 ---- /// The element containing the top level object definition. /// </param> ! /// <returns> ! /// The property (s) associated with the object (definition). ! /// </returns> ! protected virtual MutablePropertyValues GetPropertyValueSubElements ( string objectName, XmlElement objectEle) { *************** *** 577,581 **** /// The name of the element containing the ctor arg definition. /// </param> ! protected internal virtual void ParseConstructorArgElement ( string objectName, ConstructorArgumentValues cargs, XmlElement ele) { --- 537,541 ---- /// The name of the element containing the ctor arg definition. /// </param> ! protected virtual void ParseConstructorArgElement ( string objectName, ConstructorArgumentValues cargs, XmlElement ele) { *************** *** 583,587 **** string indexAttr = ele.GetAttribute (ObjectsDtd.IndexAttribute); string typeAttr = ele.GetAttribute (ObjectsDtd.TypeAttribute); ! if (!string.Empty.Equals (indexAttr)) { try --- 543,547 ---- string indexAttr = ele.GetAttribute (ObjectsDtd.IndexAttribute); string typeAttr = ele.GetAttribute (ObjectsDtd.TypeAttribute); ! if (StringUtils.HasText (indexAttr)) { try *************** *** 594,598 **** "'index' cannot be lower than 0"); } ! if (!string.Empty.Equals(typeAttr)) { cargs.AddIndexedArgumentValue (index, val, TypeAliasResolver.Resolve(typeAttr)); --- 554,558 ---- "'index' cannot be lower than 0"); } ! if (StringUtils.HasText (typeAttr)) { cargs.AddIndexedArgumentValue (index, val, TypeAliasResolver.Resolve(typeAttr)); *************** *** 612,616 **** else { ! if (!string.Empty.Equals (typeAttr)) { cargs.AddGenericArgumentValue (val, TypeAliasResolver.Resolve(typeAttr)); --- 572,576 ---- else { ! if (StringUtils.HasText (typeAttr)) { cargs.AddGenericArgumentValue (val, TypeAliasResolver.Resolve(typeAttr)); *************** *** 656,660 **** /// The name of the object associated with the property. /// </param> ! protected internal virtual object GetPropertyValue ( XmlElement ele, string objectName) { --- 616,620 ---- /// The name of the object associated with the property. /// </param> ! protected virtual object GetPropertyValue ( XmlElement ele, string objectName) { *************** *** 697,701 **** /// The name of the object (definition) associated with the top level property. /// </param> ! protected internal virtual object ParsePropertySubElement ( XmlElement ele, string objectName) { --- 657,661 ---- /// The name of the object (definition) associated with the top level property. /// </param> ! protected virtual object ParsePropertySubElement ( XmlElement ele, string objectName) { *************** *** 782,786 **** /// </param> /// <returns>The list definition.</returns> ! protected internal virtual IList GetList ( XmlElement collectionEle, string objectName) { --- 742,746 ---- /// </param> /// <returns>The list definition.</returns> ! protected virtual IList GetList ( XmlElement collectionEle, string objectName) { *************** *** 834,838 **** protected IDictionary GetMap (XmlElement mapEle, string objectName) { ! ManagedMap m = new ManagedMap(); IList l = GetChildElementsByTagName (mapEle, ObjectsDtd.EntryElement); foreach (XmlElement entryEle in l) --- 794,798 ---- protected IDictionary GetMap (XmlElement mapEle, string objectName) { ! ManagedMap m = new ManagedMap (); IList l = GetChildElementsByTagName (mapEle, ObjectsDtd.EntryElement); foreach (XmlElement entryEle in l) *************** *** 847,851 **** /// <summary> ! /// Don&t use the horrible DOM API to get child elements: get an element&s /// children with a given element name. /// </summary> --- 807,811 ---- /// <summary> ! /// Don't use the horrible DOM API to get child elements: get an element's /// children with a given element name. /// </summary> *************** *** 925,930 **** { DependencyCheckingMode code = DependencyCheckingMode.None; ! if (att != null ! && att.Trim ().Length > 0) { try --- 885,889 ---- { DependencyCheckingMode code = DependencyCheckingMode.None; ! if (StringUtils.HasText (att)) { try *************** *** 936,942 **** { #region Instrumentation ! if (logger.IsDebugEnabled) { ! logger.Debug ("Error while parsing dependency checking mode.", ex); } #endregion --- 895,901 ---- { #region Instrumentation ! if (log.IsDebugEnabled) { ! log.Debug ("Error while parsing dependency checking mode.", ex); } #endregion *************** *** 956,961 **** { AutoWiringMode mode = AutoWiringMode.No; ! if (att != null ! && att.Trim ().Length > 0) { try --- 915,919 ---- { AutoWiringMode mode = AutoWiringMode.No; ! if (StringUtils.HasText (att)) { try *************** *** 967,973 **** { #region Instrumentation ! if (logger.IsDebugEnabled) { ! logger.Debug ("Error while parsing autowire mode.", ex); } #endregion --- 925,931 ---- { #region Instrumentation ! if (log.IsDebugEnabled) { ! log.Debug ("Error while parsing autowire mode.", ex); } #endregion *************** *** 976,983 **** return mode; } #endregion #region Fields ! private IObjectDefinitionRegistry _objectFactory; private IResource _resource; private string _defaultLazyInit; --- 934,957 ---- return mode; } + + /// <summary> + /// Given a string containing delimited object names, returns + /// a string array split on the objects name delimeter. + /// </summary> + /// <param name="value"> + /// The string containing delimited object names. + /// </param> + /// <returns> + /// A string array split on the objects name delimeter. + /// </returns> + private string [] GetObjectNames (string value) + { + return StringUtils.Split ( + value, ObjectsDtd.ObjectNameDelimeters, true, true); + } #endregion #region Fields ! private IObjectDefinitionRegistry _objectRegistry; private IResource _resource; private string _defaultLazyInit; *************** *** 986,989 **** private bool _resolveTypes; #endregion ! } } --- 960,963 ---- private bool _resolveTypes; #endregion ! } } |
From: Springboy <spr...@us...> - 2004-07-26 07:48:07
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18183/Spring/Spring.Core/Objects/Factory/Config Modified Files: AbstractFactoryObject.cs AutoWiringMode.cs CustomConverterConfigurer.cs IObjectPostProcessor.cs MethodInvokingFactoryObject.cs ObjectFactoryCreatingFactoryObject.cs SetFactoryObject.cs Log Message: Added centralised Type resolution mechanism, runtime type converter, Xml Config handler, multiple documentation updates. Index: ObjectFactoryCreatingFactoryObject.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Config/ObjectFactoryCreatingFactoryObject.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ObjectFactoryCreatingFactoryObject.cs 23 Jul 2004 10:17:15 -0000 1.1 --- ObjectFactoryCreatingFactoryObject.cs 26 Jul 2004 07:47:56 -0000 1.2 *************** *** 21,35 **** /// <summary> /// IFactoryObject which returns a value which is an IGenericObjectFactory that returns ! /// a object from an IObjectFactory. /// </summary> /// <remarks> /// As such, this may be used to avoid having a client object directly ! /// calling GetObject() on the IObjectFactory to get a prototype object out ! /// of the IObjectFactory, a violation of inversion of control. Instead, with the use ! /// of this class, the client object can be fed an IObjectFactory as a property which ! /// directly returns only the one target (usually prototype) object. ! /// ! /// A Sample config in an XML IObjectFactory might look as follows: ! /// /// <objects> /// <!-- Prototype object since we have state --> --- 21,42 ---- /// <summary> /// IFactoryObject which returns a value which is an IGenericObjectFactory that returns ! /// a object from a <see cref="Spring.Objects.Factory.IObjectFactory"/>. /// </summary> /// <remarks> + /// <p> /// As such, this may be used to avoid having a client object directly ! /// calling GetObject() on the ! /// <see cref="Spring.Objects.Factory.IObjectFactory"/> to get a prototype ! /// object out of the <see cref="Spring.Objects.Factory.IObjectFactory"/>, ! /// a violation of inversion of control. Instead, with the use of this ! /// class, the client object can be fed an ! /// <see cref="Spring.Objects.Factory.IObjectFactory"/> as a property ! /// that directly returns only the one target (usually prototype) object. ! /// </p> ! /// <p> ! /// A sample config in an XML <see cref="Spring.Objects.Factory.IObjectFactory"/> ! /// might look as follows: ! /// </p> ! /// <p> /// <objects> /// <!-- Prototype object since we have state --> *************** *** 45,52 **** /// </object> /// </objects> /// </remarks> /// <author>Colin Sampaleanu</author> ! /// <author>Simon White (.NET)</author> ! public class ObjectFactoryCreatingFactoryObject : AbstractFactoryObject, IObjectFactoryAware { private string _targetObjectName; --- 52,62 ---- /// </object> /// </objects> + /// </p> /// </remarks> /// <author>Colin Sampaleanu</author> ! /// <author>Simon White (.NET)</author> ! /// <version>$Id$</version> ! public class ObjectFactoryCreatingFactoryObject ! : AbstractFactoryObject, IObjectFactoryAware { private string _targetObjectName; *************** *** 54,57 **** --- 64,71 ---- #region Properties + /// <summary> + /// Sets the name of the target object. The target has to be a + /// prototype object. + /// </summary> public string TargetObjectName { *************** *** 62,65 **** --- 76,97 ---- } + /// <summary> + /// Callback that supplies the owning factory to an object instance. + /// </summary> + /// <value> + /// Owning <see cref="Spring.Objects.Factory.IObjectFactory"/> + /// (may not be null). The object can immediately call methods on the factory. + /// </value> + /// <remarks> + /// <p> + /// Invoked after population of normal object properties but before an init + /// callback like <see cref="Spring.Objects.Factory.IInitializingObject"/>'s + /// <see cref="Spring.Objects.Factory.IInitializingObject.AfterPropertiesSet"/> + /// method or a custom init-method. + /// </p> + /// </remarks> + /// <exception cref="Spring.Objects.ObjectsException"> + /// In case of initialization errors. + /// </exception> public IObjectFactory ObjectFactory { *************** *** 70,78 **** } public override Type ObjectType { get { ! return typeof(IObjectFactory); } } --- 102,113 ---- } + /// <summary> + /// The type of object created by this factory. + /// </summary> public override Type ObjectType { get { ! return typeof (IObjectFactory); } } *************** *** 82,89 **** /// Returns an instance of the object factory. /// </summary> ! /// <returns>the object factory</returns> ! protected override object CreateInstance() { ! return new GenericObjectFactory(this) ; } --- 117,124 ---- /// Returns an instance of the object factory. /// </summary> ! /// <returns>The object factory.</returns> ! protected override object CreateInstance () { ! return new GenericObjectFactory (this) ; } *************** *** 99,104 **** /// Constructs a new GenericObjectFactory. /// </summary> ! /// <param name="enclosing">the enclosing ObjectFactoryCreatingFactoryObject</param> ! public GenericObjectFactory(ObjectFactoryCreatingFactoryObject enclosing) { this._enclosing = enclosing; --- 134,143 ---- /// Constructs a new GenericObjectFactory. /// </summary> ! /// <param name="enclosing"> ! /// The enclosing ! /// <see cref="Spring.Objects.Factory.Config.ObjectFactoryCreatingFactoryObject"/>. ! /// </param> ! public GenericObjectFactory ( ! ObjectFactoryCreatingFactoryObject enclosing) { this._enclosing = enclosing; *************** *** 108,115 **** /// Returns the object created by the enclosed object factory. /// </summary> ! /// <returns>the created object</returns> ! public object GetObject() { ! return _enclosing._objectFactory.GetObject(_enclosing._targetObjectName); } } --- 147,154 ---- /// Returns the object created by the enclosed object factory. /// </summary> ! /// <returns>The created object.</returns> ! public object GetObject () { ! return _enclosing._objectFactory.GetObject (_enclosing._targetObjectName); } } Index: CustomConverterConfigurer.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Config/CustomConverterConfigurer.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CustomConverterConfigurer.cs 16 Jul 2004 14:06:17 -0000 1.1 --- CustomConverterConfigurer.cs 26 Jul 2004 07:47:56 -0000 1.2 *************** *** 31,35 **** /// Configuration example, assuming XML object definitions and inner /// objects for <see cref="System.ComponentModel.TypeConverter"/> instances: ! /// /// <object id="customConverterConfigurer" class="Spring.Objects.Factory.Config.CustomConverterConfigurer, Spring.Core"> /// <property name="CustomConverters"> --- 31,35 ---- /// Configuration example, assuming XML object definitions and inner /// objects for <see cref="System.ComponentModel.TypeConverter"/> instances: ! /// <code> /// <object id="customConverterConfigurer" class="Spring.Objects.Factory.Config.CustomConverterConfigurer, Spring.Core"> /// <property name="CustomConverters"> *************** *** 46,49 **** --- 46,50 ---- /// </property> /// </object> + /// </code> /// </remarks> /// <author>Juergen Hoeller</author> *************** *** 121,125 **** { string typeName = (string) key; ! requiredType = ObjectUtils.LocateType(typeName); if (requiredType == null) --- 122,126 ---- { string typeName = (string) key; ! requiredType = ObjectUtils.ResolveType (typeName); if (requiredType == null) Index: MethodInvokingFactoryObject.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Config/MethodInvokingFactoryObject.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MethodInvokingFactoryObject.cs 23 Jul 2004 10:17:15 -0000 1.1 --- MethodInvokingFactoryObject.cs 26 Jul 2004 07:47:56 -0000 1.2 *************** *** 74,80 **** } ! /// <summary> ! /// ! /// </summary> public Type ObjectType { --- 74,82 ---- } ! /// <summary> ! /// Return the type of object that this ! /// <see cref="Spring.Objects.Factory.IFactoryObject"/> creates, or null ! /// if not known in advance. ! /// </summary> public Type ObjectType { *************** *** 89,93 **** } #endregion - #region IFactoryObject Methods --- 91,94 ---- Index: AbstractFactoryObject.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Config/AbstractFactoryObject.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AbstractFactoryObject.cs 16 Jul 2004 14:06:17 -0000 1.1 --- AbstractFactoryObject.cs 26 Jul 2004 07:47:56 -0000 1.2 *************** *** 32,36 **** /// <author>Juergen Hoeller</author> /// <author>Keith Donald</author> ! /// <author>Simon White (.NET)</author> public abstract class AbstractFactoryObject : IFactoryObject, IInitializingObject { --- 32,37 ---- /// <author>Juergen Hoeller</author> /// <author>Keith Donald</author> ! /// <author>Simon White (.NET)</author> ! /// <version>$Id$</version> public abstract class AbstractFactoryObject : IFactoryObject, IInitializingObject { Index: IObjectPostProcessor.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Config/IObjectPostProcessor.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IObjectPostProcessor.cs 6 Jul 2004 12:54:27 -0000 1.2 --- IObjectPostProcessor.cs 26 Jul 2004 07:47:56 -0000 1.3 *************** *** 27,41 **** /// Allows for custom modification of new object instances, e.g. /// checking for marker interfaces or wrapping them with proxies. /// <p> ! /// Application contexts can auto-detect BeanPostProcessor objects in their /// object definitions and apply them before any other objects get created. /// Plain object factories allow for programmatic registration of post-processors. /// </p> /// <p> ! /// Typically, post-processors that populate beans via marker interfaces /// or the like will implement PostProcessBeforeInitialization, and post-processors /// that wrap objects with proxies will normally implement PostProcessAfterInitialization. /// </p> ! /// </summary> /// <author>Juergen Hoeller</author> /// <author>Aleksandar Seovic (.Net)</author> --- 27,43 ---- /// Allows for custom modification of new object instances, e.g. /// checking for marker interfaces or wrapping them with proxies. + /// </summary> + /// <remarks> /// <p> ! /// Application contexts can auto-detect IObjectPostProcessor objects in their /// object definitions and apply them before any other objects get created. /// Plain object factories allow for programmatic registration of post-processors. /// </p> /// <p> ! /// Typically, post-processors that populate objects via marker interfaces /// or the like will implement PostProcessBeforeInitialization, and post-processors /// that wrap objects with proxies will normally implement PostProcessAfterInitialization. /// </p> ! /// </remarks> /// <author>Juergen Hoeller</author> /// <author>Aleksandar Seovic (.Net)</author> *************** *** 43,53 **** public interface IObjectPostProcessor { - /// <summary> /// Apply this <see cref="Spring.Objects.Factory.Config.IObjectPostProcessor"/> /// to the given new object instance <i>before</i> any object initialization callbacks. - /// The object will already be populated with property values. - /// The returned object instance may be a wrapper around the original. /// </summary> /// <param name="obj"> /// The new object instance. --- 45,58 ---- public interface IObjectPostProcessor { /// <summary> /// Apply this <see cref="Spring.Objects.Factory.Config.IObjectPostProcessor"/> /// to the given new object instance <i>before</i> any object initialization callbacks. /// </summary> + /// <remarks> + /// <p> + /// The object will already be populated with property values. + /// The returned object instance may be a wrapper around the original. + /// </p> + /// </remarks> /// <param name="obj"> /// The new object instance. *************** *** 66,73 **** /// <summary> /// Apply this <see cref="Spring.Objects.Factory.Config.IObjectPostProcessor"/> to the ! /// given new object instance <i>after</i> any object initialization callbacks. The ! /// object will already be populated with property values. The returned object ! /// instance may be a wrapper around the original. ! /// </summary> /// <param name="obj"> /// The new object instance. --- 71,82 ---- /// <summary> /// Apply this <see cref="Spring.Objects.Factory.Config.IObjectPostProcessor"/> to the ! /// given new object instance <i>after</i> any object initialization callbacks. ! /// </summary> ! /// <remarks> ! /// <p> ! /// The object will already be populated with property values. The returned object ! /// instance may be a wrapper around the original. ! /// </p> ! /// </remarks> /// <param name="obj"> /// The new object instance. Index: SetFactoryObject.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Config/SetFactoryObject.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SetFactoryObject.cs 16 Jul 2004 14:06:17 -0000 1.1 --- SetFactoryObject.cs 26 Jul 2004 07:47:56 -0000 1.2 *************** *** 23,27 **** /// <summary> /// Simple factory for shared Set instances. Allows for central setup ! /// of Sets via the "set" element in XML bean definitions. /// </summary> /// <author>Juergen Hoeller</author> --- 23,27 ---- /// <summary> /// Simple factory for shared Set instances. Allows for central setup ! /// of Sets via the "set" element in XML object definitions. /// </summary> /// <author>Juergen Hoeller</author> Index: AutoWiringMode.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/Config/AutoWiringMode.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AutoWiringMode.cs 13 Jul 2004 07:47:45 -0000 1.2 --- AutoWiringMode.cs 26 Jul 2004 07:47:56 -0000 1.3 *************** *** 34,38 **** public enum AutoWiringMode { - /// <summary> /// Do not autowire. --- 34,37 ---- *************** *** 57,61 **** /// <summary> /// The autowiring strategy is to be determined by introspection ! /// of the object&s <see cref="System.Type"/>. /// </summary> AutoDetect = 4 --- 56,60 ---- /// <summary> /// The autowiring strategy is to be determined by introspection ! /// of the object's <see cref="System.Type"/>. /// </summary> AutoDetect = 4 |
From: Springboy <spr...@us...> - 2004-07-26 07:48:06
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18183/Spring/Spring.Core/Objects/Factory Modified Files: IGenericObjectFactory.cs IObjectFactory.cs IObjectFactoryAware.cs IObjectNameAware.cs Log Message: Added centralised Type resolution mechanism, runtime type converter, Xml Config handler, multiple documentation updates. Index: IGenericObjectFactory.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/IGenericObjectFactory.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IGenericObjectFactory.cs 23 Jul 2004 10:16:02 -0000 1.1 --- IGenericObjectFactory.cs 26 Jul 2004 07:47:55 -0000 1.2 *************** *** 29,33 **** /// are normally meant to be defined as instances by the user in a IObjectFactory, /// while implementations of this class are normally meant to be fed as a ! /// property to other beans. As such, the GetObject method has different /// exception handling behavior. /// </remarks> --- 29,33 ---- /// are normally meant to be defined as instances by the user in a IObjectFactory, /// while implementations of this class are normally meant to be fed as a ! /// property to other objects. As such, the GetObject method has different /// exception handling behavior. /// </remarks> Index: IObjectFactory.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/IObjectFactory.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IObjectFactory.cs 12 Jul 2004 07:50:56 -0000 1.2 --- IObjectFactory.cs 26 Jul 2004 07:47:55 -0000 1.3 *************** *** 92,96 **** /// <item> /// <description> ! /// PostProcessBeforeInitialization methods of ObjectPostProcessors. /// </description> /// </item> --- 92,99 ---- /// <item> /// <description> ! /// The ! /// <see cref="Spring.Objects.Factory.Config.IObjectPostProcessor.PostProcessBeforeInitialization"/> ! /// method of ! /// <see cref="Spring.Objects.Factory.Config.IObjectPostProcessor"/>s. /// </description> /// </item> *************** *** 108,116 **** /// <item> /// <description> ! /// PostProcessAfterInitialization methods of ObjectPostProcessors. /// </description> /// </item> /// </list> /// </p> /// <p> /// On shutdown of an object factory, the following lifecycle methods apply: --- 111,123 ---- /// <item> /// <description> ! /// The ! /// <see cref="Spring.Objects.Factory.Config.IObjectPostProcessor.PostProcessAfterInitialization"/> ! /// method of ! /// <see cref="Spring.Objects.Factory.Config.IObjectPostProcessor"/>s. /// </description> /// </item> /// </list> /// </p> + /// <p/> /// <p> /// On shutdown of an object factory, the following lifecycle methods apply: Index: IObjectNameAware.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/IObjectNameAware.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IObjectNameAware.cs 12 Jul 2004 07:50:56 -0000 1.2 --- IObjectNameAware.cs 26 Jul 2004 07:47:55 -0000 1.3 *************** *** 54,58 **** /// <p> /// Invoked after population of normal object properties but before an init ! /// callback like <see cref="Spring.Objects.Factory.IInitializingObject"/>&s /// <see cref="Spring.Objects.Factory.IInitializingObject.AfterPropertiesSet"/> /// method or a custom init-method. --- 54,58 ---- /// <p> /// Invoked after population of normal object properties but before an init ! /// callback like <see cref="Spring.Objects.Factory.IInitializingObject"/>'s /// <see cref="Spring.Objects.Factory.IInitializingObject.AfterPropertiesSet"/> /// method or a custom init-method. Index: IObjectFactoryAware.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/Factory/IObjectFactoryAware.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IObjectFactoryAware.cs 12 Jul 2004 07:50:56 -0000 1.2 --- IObjectFactoryAware.cs 26 Jul 2004 07:47:55 -0000 1.3 *************** *** 58,62 **** /// <p> /// Invoked after population of normal object properties but before an init ! /// callback like <see cref="Spring.Objects.Factory.IInitializingObject"/>&s /// <see cref="Spring.Objects.Factory.IInitializingObject.AfterPropertiesSet"/> /// method or a custom init-method. --- 58,62 ---- /// <p> /// Invoked after population of normal object properties but before an init ! /// callback like <see cref="Spring.Objects.Factory.IInitializingObject"/>'s /// <see cref="Spring.Objects.Factory.IInitializingObject.AfterPropertiesSet"/> /// method or a custom init-method. |
From: Springboy <spr...@us...> - 2004-07-26 07:48:06
|
Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/TypeConverters In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18183/Spring/Spring.Core/Objects/TypeConverters Modified Files: StringArrayConverter.cs Log Message: Added centralised Type resolution mechanism, runtime type converter, Xml Config handler, multiple documentation updates. Index: StringArrayConverter.cs =================================================================== RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Objects/TypeConverters/StringArrayConverter.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** StringArrayConverter.cs 6 Jul 2004 12:54:27 -0000 1.2 --- StringArrayConverter.cs 26 Jul 2004 07:47:57 -0000 1.3 *************** *** 14,30 **** * limitations under the License. */ ! using System; ! using System.ComponentModel; ! using System.Globalization; using Spring.Util; namespace Spring.Objects.TypeConverters { ! /// <summary> /// Convert a CVS String to a String array and vice-versa. This TypeConverter /// is auotmatically registered with ObjectWrapper. /// </summary> public class StringArrayConverter : TypeConverter { /// <summary> /// Create a converter /// </summary> public StringArrayConverter() { } ! /// <summary> /// Can we convert from a the sourcetype to a StringArray. True if the sourceType /// is a string. Otherwise see if the base TypeConverter can handle it (it can't). /// </summary> /// <param name="context">Description of the type</param> /// <param name="sourceType">The type to convert from.</param> /// <returns></returns> public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) { return true; } return base.CanConvertFrom (context, sourceType); } /// <summary> /// Convert from a string value to a string array /// </summary> /// <param name="context">The type context</param> /// <param name="culture">Culture info. Ignored for now.</param> /// <param name="val">string value to convert.</param> /// <returns>A string array if successfull. Empty zero length string of val is null.</returns> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object val) { //TODO think about including culture.... ! /* ! if (null == culture) ! { ! culture = CultureInfo.CurrentCulture; ! } ! string[] param = sValue.Split(new char[] {culture.TextInfo.ListSeparator[0] } ); ! */ ! if (val is string) { return StringUtils.CommaDelimitedListToStringArray((string)val); } return base.ConvertFrom(context, culture, val); } } } --- 14,57 ---- * limitations under the License. */ ! using System; using System.ComponentModel; using System.Globalization; using Spring.Util; namespace Spring.Objects.TypeConverters { ! /// <summary> /// Convert a CVS <see cref="System.String"/> to a <see cref="System.String"/> array and vice-versa. /// </summary> /// <remarks> /// <p> /// This <see cref="System.ComponentModel.TypeConverter"/> should be /// automatically registered with any <see cref="Spring.Objects.IObjectWrapper"/> /// implementations. /// </p> /// </remarks> /// <author></author> /// <version>$Id$</version> public class StringArrayConverter : TypeConverter { #region Constructor (s) / Destructor /// <summary> /// Create a new instance of the StringArrayConverter class. /// </summary> public StringArrayConverter () { } #endregion ! #region Methods ! /// <summary> ! /// Can we convert from a the sourcetype to a ! /// <see cref="System.String"/> array? ! /// </summary> ! /// <remarks> ! /// <p> ! /// Currently only supports conversion from a ! /// <see cref="System.String"/> instance. ! /// </p> ! /// </remarks> ! /// <param name="context"> ! /// A <see cref="System.ComponentModel.ITypeDescriptorContext"/> ! /// that provides a format context. ! /// </param> ! /// <param name="sourceType"> ! /// A <see cref="System.Type"/> that represents the ! /// <see cref="System.Type"/> you want to convert from. ! /// </param> ! /// <returns>True if the conversion is possible.</returns> public override bool CanConvertFrom ( ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof (string)) { return true; } return base.CanConvertFrom (context, sourceType); } /// <summary> ! /// Convert from a string value to a <see cref="System.String"/> array. ! /// </summary> ! /// <param name="context"> ! /// A <see cref="System.ComponentModel.ITypeDescriptorContext"/> ! /// that provides a format context. ! /// </param> ! /// <param name="culture"> ! /// The <see cref="System.Globalization.CultureInfo"/> to use ! /// as the current culture (currently ignored). ! /// </param> ! /// <param name="value"> ! /// The value that is to be converted. ! /// </param> ! /// <returns> ! /// A <see cref="System.String"/> array if successful. ! /// An empty zero length <see cref="System.String"/> if ! /// <paramref name="value"/> is null. ! /// </returns> public override object ConvertFrom ( ITypeDescriptorContext context, CultureInfo culture, object value) { //TODO think about including culture.... /* if (null == culture) { culture = CultureInfo.CurrentCulture; } string[] param = sValue.Split(new char[] {culture.TextInfo.ListSeparator[0] } ); */ if (value is string) { return StringUtils.CommaDelimitedListToStringArray ((string) value); } return base.ConvertFrom (context, culture, value); } #endregion } } |