Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Expressions
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv13355/Expressions
Modified Files:
PropertyOrFieldNode.cs
Log Message:
fixed SPRNET-725
Index: PropertyOrFieldNode.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Core/Expressions/PropertyOrFieldNode.cs,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** PropertyOrFieldNode.cs 7 Sep 2007 03:01:26 -0000 1.27
--- PropertyOrFieldNode.cs 14 Sep 2007 13:48:53 -0000 1.28
***************
*** 111,115 ****
// check the context type first
accessor = GetPropertyOrFieldAccessor(contextType, memberName, BINDING_FLAGS);
!
// if not found, probe the Type type
if (accessor == null && context is Type)
--- 111,115 ----
// check the context type first
accessor = GetPropertyOrFieldAccessor(contextType, memberName, BINDING_FLAGS);
!
// if not found, probe the Type type
if (accessor == null && context is Type)
***************
*** 184,205 ****
{
PropertyInfo pi = null;
!
// search type hierarchy
! while( contextType != typeof(object) )
{
! pi = contextType.GetProperty(memberName, bindingFlags | BindingFlags.DeclaredOnly);
! if(pi == null)
! {
! FieldInfo fi = contextType.GetField(memberName, bindingFlags | BindingFlags.DeclaredOnly);
! if(fi != null)
{
! return new FieldValueAccessor(fi);
}
! }
! else
! {
! return new PropertyValueAccessor(pi);
! }
! contextType = contextType.BaseType;
}
}
--- 184,205 ----
{
PropertyInfo pi = null;
!
// search type hierarchy
! while (contextType != typeof(object))
{
! pi = contextType.GetProperty(memberName, bindingFlags | BindingFlags.DeclaredOnly);
! if (pi == null)
{
! FieldInfo fi = contextType.GetField(memberName, bindingFlags | BindingFlags.DeclaredOnly);
! if (fi != null)
! {
! return new FieldValueAccessor(fi);
! }
}
! else
! {
! return new PropertyValueAccessor(pi);
! }
! contextType = contextType.BaseType;
}
}
***************
*** 219,237 ****
{
InitializeNode(context);
- }
! if (context == null && accessor.RequiresContext)
! {
! throw new NullValueInNestedPathException(
! "Cannot retrieve the value of a field or property '" + this.memberName
! + "', because context for its resolution is null.");
! }
! if (IsProperty || IsField)
! {
! return GetPropertyOrFieldValue(context, evalContext);
! }
! else
! {
! return accessor.Get(context);
}
}
--- 219,237 ----
{
InitializeNode(context);
! if (context == null && accessor.RequiresContext)
! {
! throw new NullValueInNestedPathException(
! "Cannot retrieve the value of a field or property '" + this.memberName
! + "', because context for its resolution is null.");
! }
! if (IsProperty || IsField)
! {
! return GetPropertyOrFieldValue(context, evalContext);
! }
! else
! {
! return accessor.Get(context);
! }
}
}
***************
*** 255,267 ****
+ "', because context for its resolution is null.");
}
! }
!
! if (IsProperty || IsField)
! {
! SetPropertyOrFieldValue(context, evalContext, newValue);
! }
! else
! {
! accessor.Set(context, newValue);
}
}
--- 255,266 ----
+ "', because context for its resolution is null.");
}
! if (IsProperty || IsField)
! {
! SetPropertyOrFieldValue(context, evalContext, newValue);
! }
! else
! {
! accessor.Set(context, newValue);
! }
}
}
***************
*** 303,311 ****
catch (InvalidOperationException)
{
! throw new NotReadablePropertyException( evalContext.RootContextType,this.memberName );
}
catch (TargetInvocationException e)
{
! throw new InvalidPropertyException( evalContext.RootContextType,this.memberName,
"Getter for property '" + this.memberName + "' threw an exception.",
e);
--- 302,310 ----
catch (InvalidOperationException)
{
! throw new NotReadablePropertyException(evalContext.RootContextType, this.memberName);
}
catch (TargetInvocationException e)
{
! throw new InvalidPropertyException(evalContext.RootContextType, this.memberName,
"Getter for property '" + this.memberName + "' threw an exception.",
e);
***************
*** 313,317 ****
catch (UnauthorizedAccessException e)
{
! throw new InvalidPropertyException( evalContext.RootContextType,this.memberName,
"Illegal attempt to get value for the property '" + this.memberName +
"'.", e);
--- 312,316 ----
catch (UnauthorizedAccessException e)
{
! throw new InvalidPropertyException(evalContext.RootContextType, this.memberName,
"Illegal attempt to get value for the property '" + this.memberName +
"'.", e);
***************
*** 430,437 ****
if (newValue is IList && !RemotingServices.IsTransparentProxy(newValue))
{
! IList currentValue = (IList) Get(context, evalContext);
if (currentValue != null && !currentValue.IsFixedSize && !currentValue.IsReadOnly)
{
! foreach (object el in (IList) newValue)
{
currentValue.Add(el);
--- 429,436 ----
if (newValue is IList && !RemotingServices.IsTransparentProxy(newValue))
{
! IList currentValue = (IList)Get(context, evalContext);
if (currentValue != null && !currentValue.IsFixedSize && !currentValue.IsReadOnly)
{
! foreach (object el in (IList)newValue)
{
currentValue.Add(el);
***************
*** 440,450 ****
}
}
! // try adding values if property is a dictionary...
else if (newValue is IDictionary && !RemotingServices.IsTransparentProxy(newValue))
{
! IDictionary currentValue = (IDictionary)Get( context, evalContext );
if (currentValue != null && !currentValue.IsFixedSize && !currentValue.IsReadOnly)
{
! foreach (DictionaryEntry entry in (IDictionary) newValue)
{
currentValue[entry.Key] = entry.Value;
--- 439,449 ----
}
}
! // try adding values if property is a dictionary...
else if (newValue is IDictionary && !RemotingServices.IsTransparentProxy(newValue))
{
! IDictionary currentValue = (IDictionary)Get(context, evalContext);
if (currentValue != null && !currentValue.IsFixedSize && !currentValue.IsReadOnly)
{
! foreach (DictionaryEntry entry in (IDictionary)newValue)
{
currentValue[entry.Key] = entry.Value;
***************
*** 453,463 ****
}
}
! // try adding values if property is a set...
else if (newValue is ISet && !RemotingServices.IsTransparentProxy(newValue))
{
! ISet currentValue = (ISet)Get( context, evalContext );
if (currentValue != null)
{
! currentValue.AddAll((ICollection) newValue);
added = true;
}
--- 452,462 ----
}
}
! // try adding values if property is a set...
else if (newValue is ISet && !RemotingServices.IsTransparentProxy(newValue))
{
! ISet currentValue = (ISet)Get(context, evalContext);
if (currentValue != null)
{
! currentValue.AddAll((ICollection)newValue);
added = true;
}
|