SPRNET-1564 Remove code marked as obsolete
This commit is contained in:
@@ -2,6 +2,7 @@ Changes (1.3.2 to 2.0)
|
||||
========================
|
||||
|
||||
Protected fields were changed to private. Access is now allowed via public/protected property member.
|
||||
Members marked as Obsolete before 2.0 release were removed.
|
||||
|
||||
|
||||
Changes (1.3.1 to 1.3.2)
|
||||
|
||||
@@ -910,24 +910,6 @@ namespace Spring.Objects.Factory.Support
|
||||
return ResolveObjectType(mod, objectName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the object for the given object instance, either the object
|
||||
/// instance itself or its created object in case of an
|
||||
/// <see cref="Spring.Objects.Factory.IFactoryObject"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">
|
||||
/// The name that may include the factory dereference prefix.
|
||||
/// </param>
|
||||
/// <param name="instance">The object instance.</param>
|
||||
/// <returns>
|
||||
/// The singleton instance of the object.
|
||||
/// </returns>
|
||||
[Obsolete("")]
|
||||
protected internal virtual object GetObjectForInstance(string name, object instance)
|
||||
{
|
||||
return GetObjectForInstance(instance, name, TransformedObjectName(name), null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the object for the given object instance, either the object
|
||||
/// instance itself or its created object in case of an
|
||||
|
||||
@@ -62,34 +62,6 @@ namespace Spring.Objects.Factory.Xml
|
||||
this.containingObjectDefinition = containingObjectDefinition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ParserContext"/> class.
|
||||
/// </summary>
|
||||
/// <param name="readerContext">The reader context.</param>
|
||||
/// <param name="parserHelper">The parser helper.</param>
|
||||
[Obsolete("consider using ParserContext(ObjectDefinitionParserHelper) instead", false)]
|
||||
public ParserContext(XmlReaderContext readerContext, ObjectDefinitionParserHelper parserHelper)
|
||||
{
|
||||
this.readerContext = readerContext;
|
||||
this.parserHelper = parserHelper;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ParserContext"/> class.
|
||||
/// </summary>
|
||||
/// <param name="readerContext">The reader context.</param>
|
||||
/// <param name="parserHelper">The parser helper.</param>
|
||||
/// <param name="containingObjectDefinition">The containing object definition.</param>
|
||||
[Obsolete("consider using ParserContext(ObjectDefinitionParserHelper, IObjectDefinition) instead", false)]
|
||||
public ParserContext(XmlReaderContext readerContext, ObjectDefinitionParserHelper parserHelper, IObjectDefinition containingObjectDefinition)
|
||||
{
|
||||
this.readerContext = readerContext;
|
||||
this.parserHelper = parserHelper;
|
||||
this.containingObjectDefinition = containingObjectDefinition;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the reader context.
|
||||
/// </summary>
|
||||
|
||||
@@ -18,21 +18,8 @@
|
||||
|
||||
#endregion
|
||||
|
||||
#region Imports
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using Spring.Reflection.Dynamic;
|
||||
using Spring.Util;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Spring.Reflection.Dynamic
|
||||
{
|
||||
#region IDynamicIndexer interface
|
||||
|
||||
/// <summary>
|
||||
/// Defines methods that dynamic indexer class has to implement.
|
||||
/// </summary>
|
||||
@@ -122,175 +109,4 @@ namespace Spring.Reflection.Dynamic
|
||||
/// </param>
|
||||
void SetValue( object target, object[] index, object value );
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Safe wrapper
|
||||
|
||||
/// <summary>
|
||||
/// Safe wrapper for the dynamic indexer.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <see cref="SafeIndexer"/> will attempt to use dynamic
|
||||
/// indexer if possible, but it will fall back to standard
|
||||
/// reflection if necessary.
|
||||
/// </remarks>
|
||||
[Obsolete("Use SafeProperty instead", false)]
|
||||
public class SafeIndexer : IDynamicIndexer
|
||||
{
|
||||
private PropertyInfo indexerProperty;
|
||||
|
||||
/// <summary>
|
||||
/// Internal PropertyInfo accessor.
|
||||
/// </summary>
|
||||
internal PropertyInfo IndexerProperty
|
||||
{
|
||||
get { return indexerProperty; }
|
||||
}
|
||||
|
||||
private SafeProperty property;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the safe indexer wrapper.
|
||||
/// </summary>
|
||||
/// <param name="indexerInfo">Indexer to wrap.</param>
|
||||
public SafeIndexer( PropertyInfo indexerInfo )
|
||||
{
|
||||
AssertUtils.ArgumentNotNull( indexerInfo, "You cannot create a dynamic indexer for a null value." );
|
||||
|
||||
this.indexerProperty = indexerInfo;
|
||||
this.property = new SafeProperty( indexerInfo );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the dynamic indexer for the specified target object.
|
||||
/// </summary>
|
||||
/// <param name="target">
|
||||
/// Target object to get indexer value from.
|
||||
/// </param>
|
||||
/// <param name="index">
|
||||
/// Indexer arguments.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A indexer value.
|
||||
/// </returns>
|
||||
public object GetValue( object target, int index )
|
||||
{
|
||||
return property.GetValue( target, index );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the dynamic indexer for the specified target object.
|
||||
/// </summary>
|
||||
/// <param name="target">
|
||||
/// Target object to get the indexer value from.
|
||||
/// </param>
|
||||
/// <param name="index">
|
||||
/// Indexer argument.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A indexer value.
|
||||
/// </returns>
|
||||
public object GetValue( object target, object index )
|
||||
{
|
||||
return property.GetValue( target, index );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the dynamic indexer for the specified target object.
|
||||
/// </summary>
|
||||
/// <param name="target">
|
||||
/// Target object to get indexer value from.
|
||||
/// </param>
|
||||
/// <param name="index">
|
||||
/// Indexer arguments.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A indexer value.
|
||||
/// </returns>
|
||||
public object GetValue( object target, object[] index )
|
||||
{
|
||||
return property.GetValue( target, index );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value of the dynamic indexer for the specified target object.
|
||||
/// </summary>
|
||||
/// <param name="target">
|
||||
/// Target object to set indexer value on.
|
||||
/// </param>
|
||||
/// <param name="index">
|
||||
/// Indexer arguments.
|
||||
/// </param>
|
||||
/// <param name="value">
|
||||
/// A new indexer value.
|
||||
/// </param>
|
||||
public void SetValue( object target, int index, object value )
|
||||
{
|
||||
property.SetValue( target, value, index );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value of the dynamic indexer for the specified target object.
|
||||
/// </summary>
|
||||
/// <param name="target">
|
||||
/// Target object to set indexer value on.
|
||||
/// </param>
|
||||
/// <param name="index">
|
||||
/// Indexer arguments.
|
||||
/// </param>
|
||||
/// <param name="value">
|
||||
/// A new indexer value.
|
||||
/// </param>
|
||||
public void SetValue( object target, object index, object value )
|
||||
{
|
||||
property.SetValue( target, value, index );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value of the dynamic indexer for the specified target object.
|
||||
/// </summary>
|
||||
/// <param name="target">
|
||||
/// Target object to set indexer value on.
|
||||
/// </param>
|
||||
/// <param name="index">
|
||||
/// Indexer arguments.
|
||||
/// </param>
|
||||
/// <param name="value">
|
||||
/// A new indexer value.
|
||||
/// </param>
|
||||
public void SetValue( object target, object[] index, object value )
|
||||
{
|
||||
property.SetValue( target, value, index );
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Factory class for dynamic indexers.
|
||||
/// </summary>
|
||||
/// <author>Aleksandar Seovic</author>
|
||||
[Obsolete( "Use DynamicProperty instead", false )]
|
||||
public sealed class DynamicIndexer : BaseDynamicMember
|
||||
{
|
||||
/// <summary>
|
||||
/// Prevent instantiation
|
||||
/// </summary>
|
||||
private DynamicIndexer() { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates dynamic indexer instance for the specified <see cref="PropertyInfo"/>.
|
||||
/// </summary>
|
||||
/// <param name="indexer">Indexer info to create dynamic indexer for.</param>
|
||||
/// <returns>Dynamic indexer for the specified <see cref="PropertyInfo"/>.</returns>
|
||||
public static IDynamicIndexer Create( PropertyInfo indexer )
|
||||
{
|
||||
AssertUtils.ArgumentNotNull( indexer, "You cannot create a dynamic indexer for a null value." );
|
||||
|
||||
IDynamicIndexer dynamicIndexer = new SafeIndexer( indexer );
|
||||
return dynamicIndexer;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
}
|
||||
|
||||
@@ -764,6 +764,7 @@
|
||||
<Compile Include="Objects\IObjectMetadataElement.cs" />
|
||||
<Compile Include="Objects\ObjectMetadataAttribute.cs" />
|
||||
<Compile Include="Objects\ObjectMetadataAttributeAccessor.cs" />
|
||||
<Compile Include="Reflection\Dynamic\DynamicIndexer.cs" />
|
||||
<Compile Include="Stereotype\ControllerAttribute.cs" />
|
||||
<Compile Include="Util\ConstructorInstantiationInfo.cs" />
|
||||
<Compile Include="Objects\Factory\Support\GenericObjectDefinition.cs" />
|
||||
@@ -1156,7 +1157,6 @@
|
||||
<Compile Include="Reflection\Dynamic\BaseDynamicMember.cs" />
|
||||
<Compile Include="Reflection\Dynamic\DynamicConstructor.cs" />
|
||||
<Compile Include="Reflection\Dynamic\DynamicField.cs" />
|
||||
<Compile Include="Reflection\Dynamic\DynamicIndexer.cs" />
|
||||
<Compile Include="Reflection\Dynamic\DynamicMethod.cs" />
|
||||
<Compile Include="Reflection\Dynamic\DynamicProperty.cs" />
|
||||
<Compile Include="Reflection\Dynamic\DynamicReflectionManager.cs" />
|
||||
|
||||
@@ -1102,11 +1102,8 @@ namespace Spring.Util
|
||||
// In case of using List<CustomAttributesData> the above note makes
|
||||
// no sense (SD:)
|
||||
IList propertiesToSet = new ArrayList();
|
||||
int k = 0;
|
||||
|
||||
IList fieldsToSet = new ArrayList();
|
||||
int n = 0;
|
||||
|
||||
|
||||
// Fills arrays of the constructor named parameters
|
||||
foreach (CustomAttributeNamedArgument namedArgument in attributeData.NamedArguments)
|
||||
|
||||
@@ -1,174 +1,174 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright 2002-2010 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;
|
||||
using System.Collections;
|
||||
using System.Data;
|
||||
using System.Xml;
|
||||
using Spring.Collections;
|
||||
using Spring.Objects.Factory.Config;
|
||||
using Spring.Objects.Factory.Support;
|
||||
using Spring.Objects.Factory.Xml;
|
||||
using Spring.Transaction.Interceptor;
|
||||
using Spring.Util;
|
||||
|
||||
namespace Spring.Transaction.Config
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="IObjectDefinitionParser"/> for the <code><tx:advice></code> tag.
|
||||
/// </summary>
|
||||
/// <author>Rob Harrop</author>
|
||||
/// <author>Juergen Hoeller</author>
|
||||
/// <author>Adrian Colyer</author>
|
||||
/// <author>Mark Pollack (.NET)</author>
|
||||
public class TxAdviceObjectDefinitionParser : AbstractSingleObjectDefinitionParser
|
||||
{
|
||||
private static string TIMEOUT = "timeout";
|
||||
|
||||
private static string READ_ONLY = "read-only";
|
||||
|
||||
private static string NAME_MAP = "nameMap";
|
||||
|
||||
private static string PROPAGATION = "propagation";
|
||||
|
||||
private static string ISOLATION = "isolation";
|
||||
|
||||
private static string ROLLBACK_FOR = "rollback-for";
|
||||
|
||||
private static string NO_ROLLBACK_FOR = "no-rollback-for";
|
||||
|
||||
protected override Type GetObjectType(XmlElement element)
|
||||
{
|
||||
return typeof (TransactionInterceptor);
|
||||
}
|
||||
|
||||
protected override void DoParse(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder)
|
||||
{
|
||||
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright 2002-2010 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;
|
||||
using System.Collections;
|
||||
using System.Data;
|
||||
using System.Xml;
|
||||
using Spring.Collections;
|
||||
using Spring.Objects.Factory.Config;
|
||||
using Spring.Objects.Factory.Support;
|
||||
using Spring.Objects.Factory.Xml;
|
||||
using Spring.Transaction.Interceptor;
|
||||
using Spring.Util;
|
||||
|
||||
namespace Spring.Transaction.Config
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="IObjectDefinitionParser"/> for the <code><tx:advice></code> tag.
|
||||
/// </summary>
|
||||
/// <author>Rob Harrop</author>
|
||||
/// <author>Juergen Hoeller</author>
|
||||
/// <author>Adrian Colyer</author>
|
||||
/// <author>Mark Pollack (.NET)</author>
|
||||
public class TxAdviceObjectDefinitionParser : AbstractSingleObjectDefinitionParser
|
||||
{
|
||||
private static string TIMEOUT = "timeout";
|
||||
|
||||
private static string READ_ONLY = "read-only";
|
||||
|
||||
private static string NAME_MAP = "nameMap";
|
||||
|
||||
private static string PROPAGATION = "propagation";
|
||||
|
||||
private static string ISOLATION = "isolation";
|
||||
|
||||
private static string ROLLBACK_FOR = "rollback-for";
|
||||
|
||||
private static string NO_ROLLBACK_FOR = "no-rollback-for";
|
||||
|
||||
protected override Type GetObjectType(XmlElement element)
|
||||
{
|
||||
return typeof (TransactionInterceptor);
|
||||
}
|
||||
|
||||
protected override void DoParse(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder)
|
||||
{
|
||||
|
||||
builder.AddPropertyReference(TxNamespaceUtils.TRANSACTION_MANAGER_PROPERTY,
|
||||
GetAttributeValue(element, TxNamespaceUtils.TRANSACTION_MANAGER_ATTRIBUTE));
|
||||
XmlNodeList txAttributes = element.SelectNodes("*[local-name()='attributes' and namespace-uri()='" + element.NamespaceURI + "']");
|
||||
if (txAttributes.Count > 1 )
|
||||
{
|
||||
parserContext.ReaderContext.ReportException(element, "tx advice", "Element <attributes> is allowed at most once inside element <advice>");
|
||||
}
|
||||
else if (txAttributes.Count == 1)
|
||||
{
|
||||
//using xml defined source
|
||||
XmlElement attributeSourceElement = txAttributes[0] as XmlElement;
|
||||
AbstractObjectDefinition attributeSourceDefinition =
|
||||
ParseAttributeSource(attributeSourceElement, parserContext);
|
||||
builder.AddPropertyValue(TxNamespaceUtils.TRANSACTION_ATTRIBUTE_SOURCE, attributeSourceDefinition);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Assume attibutes source
|
||||
ObjectDefinitionBuilder txAttributeSourceBuilder =
|
||||
parserContext.ParserHelper.CreateRootObjectDefinitionBuilder(typeof (AttributesTransactionAttributeSource));
|
||||
|
||||
builder.AddPropertyValue(TxNamespaceUtils.TRANSACTION_ATTRIBUTE_SOURCE,
|
||||
txAttributeSourceBuilder.ObjectDefinition);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private AbstractObjectDefinition ParseAttributeSource(XmlElement element, ParserContext parserContext)
|
||||
{
|
||||
XmlNodeList methods = element.SelectNodes("*[local-name()='method' and namespace-uri()='" + element.NamespaceURI + "']");
|
||||
ManagedDictionary transactionAttributeMap = new ManagedDictionary();
|
||||
foreach (XmlElement methodElement in methods)
|
||||
GetAttributeValue(element, TxNamespaceUtils.TRANSACTION_MANAGER_ATTRIBUTE));
|
||||
XmlNodeList txAttributes = element.SelectNodes("*[local-name()='attributes' and namespace-uri()='" + element.NamespaceURI + "']");
|
||||
if (txAttributes.Count > 1 )
|
||||
{
|
||||
string name = GetAttributeValue(methodElement, "name");
|
||||
TypedStringValue nameHolder = new TypedStringValue(name);
|
||||
|
||||
parserContext.ReaderContext.ReportException(element, "tx advice", "Element <attributes> is allowed at most once inside element <advice>");
|
||||
}
|
||||
else if (txAttributes.Count == 1)
|
||||
{
|
||||
//using xml defined source
|
||||
XmlElement attributeSourceElement = txAttributes[0] as XmlElement;
|
||||
AbstractObjectDefinition attributeSourceDefinition =
|
||||
ParseAttributeSource(attributeSourceElement, parserContext);
|
||||
builder.AddPropertyValue(TxNamespaceUtils.TRANSACTION_ATTRIBUTE_SOURCE, attributeSourceDefinition);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Assume attibutes source
|
||||
ObjectDefinitionBuilder txAttributeSourceBuilder =
|
||||
parserContext.ParserHelper.CreateRootObjectDefinitionBuilder(typeof (AttributesTransactionAttributeSource));
|
||||
|
||||
builder.AddPropertyValue(TxNamespaceUtils.TRANSACTION_ATTRIBUTE_SOURCE,
|
||||
txAttributeSourceBuilder.ObjectDefinition);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private AbstractObjectDefinition ParseAttributeSource(XmlElement element, ParserContext parserContext)
|
||||
{
|
||||
XmlNodeList methods = element.SelectNodes("*[local-name()='method' and namespace-uri()='" + element.NamespaceURI + "']");
|
||||
ManagedDictionary transactionAttributeMap = new ManagedDictionary();
|
||||
foreach (XmlElement methodElement in methods)
|
||||
{
|
||||
string name = GetAttributeValue(methodElement, "name");
|
||||
TypedStringValue nameHolder = new TypedStringValue(name);
|
||||
|
||||
RuleBasedTransactionAttribute attribute = new RuleBasedTransactionAttribute();
|
||||
string propagation = GetAttributeValue(methodElement, PROPAGATION);
|
||||
string isolation = GetAttributeValue(methodElement, ISOLATION);
|
||||
string timeout = GetAttributeValue(methodElement, TIMEOUT);
|
||||
string readOnly = GetAttributeValue(methodElement, READ_ONLY);
|
||||
if (StringUtils.HasText(propagation))
|
||||
{
|
||||
attribute.PropagationBehavior = (TransactionPropagation) Enum.Parse(typeof (TransactionPropagation), propagation, true);
|
||||
}
|
||||
if (StringUtils.HasText(isolation))
|
||||
{
|
||||
attribute.TransactionIsolationLevel =
|
||||
(IsolationLevel) Enum.Parse(typeof (IsolationLevel), isolation, true);
|
||||
}
|
||||
if (StringUtils.HasText(timeout))
|
||||
{
|
||||
try
|
||||
{
|
||||
attribute.TransactionTimeout = Int32.Parse(timeout);
|
||||
}
|
||||
catch (FormatException ex)
|
||||
{
|
||||
parserContext.ReaderContext.ReportException(methodElement,"tx advice","timeout must be an integer value: [" + timeout + "]", ex);
|
||||
}
|
||||
}
|
||||
if (StringUtils.HasText(readOnly))
|
||||
string readOnly = GetAttributeValue(methodElement, READ_ONLY);
|
||||
if (StringUtils.HasText(propagation))
|
||||
{
|
||||
attribute.ReadOnly = Boolean.Parse(GetAttributeValue(methodElement, READ_ONLY));
|
||||
}
|
||||
IList rollbackRules = new LinkedList();
|
||||
if (methodElement.HasAttribute(ROLLBACK_FOR))
|
||||
attribute.PropagationBehavior = (TransactionPropagation) Enum.Parse(typeof (TransactionPropagation), propagation, true);
|
||||
}
|
||||
if (StringUtils.HasText(isolation))
|
||||
{
|
||||
string rollbackForValue = GetAttributeValue(methodElement, ROLLBACK_FOR);
|
||||
AddRollbackRuleAttributesTo(rollbackRules, rollbackForValue);
|
||||
}
|
||||
if (methodElement.HasAttribute(NO_ROLLBACK_FOR))
|
||||
attribute.TransactionIsolationLevel =
|
||||
(IsolationLevel) Enum.Parse(typeof (IsolationLevel), isolation, true);
|
||||
}
|
||||
if (StringUtils.HasText(timeout))
|
||||
{
|
||||
string noRollbackForValue = GetAttributeValue(methodElement, NO_ROLLBACK_FOR);
|
||||
AddNoRollbackRuleAttributesTo(rollbackRules, noRollbackForValue);
|
||||
}
|
||||
attribute.RollbackRules = rollbackRules;
|
||||
|
||||
transactionAttributeMap[nameHolder] = attribute;
|
||||
}
|
||||
|
||||
ObjectDefinitionBuilder builder = parserContext
|
||||
.ParserHelper
|
||||
.CreateRootObjectDefinitionBuilder(typeof (NameMatchTransactionAttributeSource));
|
||||
builder.AddPropertyValue(NAME_MAP, transactionAttributeMap);
|
||||
return builder.ObjectDefinition;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void AddRollbackRuleAttributesTo(IList rollbackRules, string rollbackForValue)
|
||||
{
|
||||
string[] exceptionTypeNames = StringUtils.CommaDelimitedListToStringArray(rollbackForValue);
|
||||
foreach (string exceptionTypeName in exceptionTypeNames)
|
||||
{
|
||||
rollbackRules.Add(new RollbackRuleAttribute(exceptionTypeName.Trim()));
|
||||
}
|
||||
}
|
||||
|
||||
private void AddNoRollbackRuleAttributesTo(IList rollbackRules, string noRollbackForValue)
|
||||
{
|
||||
string[] exceptionTypeNames = StringUtils.CommaDelimitedListToStringArray(noRollbackForValue);
|
||||
foreach (string exceptionTypeName in exceptionTypeNames)
|
||||
{
|
||||
rollbackRules.Add(new NoRollbackRuleAttribute(exceptionTypeName.Trim()));
|
||||
}
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
attribute.TransactionTimeout = Int32.Parse(timeout);
|
||||
}
|
||||
catch (FormatException ex)
|
||||
{
|
||||
parserContext.ReaderContext.ReportException(methodElement,"tx advice","timeout must be an integer value: [" + timeout + "]", ex);
|
||||
}
|
||||
}
|
||||
if (StringUtils.HasText(readOnly))
|
||||
{
|
||||
attribute.ReadOnly = Boolean.Parse(GetAttributeValue(methodElement, READ_ONLY));
|
||||
}
|
||||
IList rollbackRules = new LinkedList();
|
||||
if (methodElement.HasAttribute(ROLLBACK_FOR))
|
||||
{
|
||||
string rollbackForValue = GetAttributeValue(methodElement, ROLLBACK_FOR);
|
||||
AddRollbackRuleAttributesTo(rollbackRules, rollbackForValue);
|
||||
}
|
||||
if (methodElement.HasAttribute(NO_ROLLBACK_FOR))
|
||||
{
|
||||
string noRollbackForValue = GetAttributeValue(methodElement, NO_ROLLBACK_FOR);
|
||||
AddNoRollbackRuleAttributesTo(rollbackRules, noRollbackForValue);
|
||||
}
|
||||
attribute.RollbackRules = rollbackRules;
|
||||
|
||||
transactionAttributeMap[nameHolder] = attribute;
|
||||
}
|
||||
|
||||
ObjectDefinitionBuilder builder = parserContext
|
||||
.ParserHelper
|
||||
.CreateRootObjectDefinitionBuilder(typeof (NameMatchTransactionAttributeSource));
|
||||
builder.AddPropertyValue(NAME_MAP, transactionAttributeMap);
|
||||
return builder.ObjectDefinition;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void AddRollbackRuleAttributesTo(IList rollbackRules, string rollbackForValue)
|
||||
{
|
||||
string[] exceptionTypeNames = StringUtils.CommaDelimitedListToStringArray(rollbackForValue);
|
||||
foreach (string exceptionTypeName in exceptionTypeNames)
|
||||
{
|
||||
rollbackRules.Add(new RollbackRuleAttribute(exceptionTypeName.Trim()));
|
||||
}
|
||||
}
|
||||
|
||||
private void AddNoRollbackRuleAttributesTo(IList rollbackRules, string noRollbackForValue)
|
||||
{
|
||||
string[] exceptionTypeNames = StringUtils.CommaDelimitedListToStringArray(noRollbackForValue);
|
||||
foreach (string exceptionTypeName in exceptionTypeNames)
|
||||
{
|
||||
rollbackRules.Add(new NoRollbackRuleAttribute(exceptionTypeName.Trim()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -190,12 +190,6 @@ namespace Spring.Messaging.Ems.Common
|
||||
get { return nativeSession.IsTransacted; }
|
||||
}
|
||||
|
||||
public IMessageListener MessageListener
|
||||
{
|
||||
get { return nativeSession.MessageListener; }
|
||||
set { nativeSession.MessageListener = value; }
|
||||
}
|
||||
|
||||
public long SessID
|
||||
{
|
||||
get { return nativeSession.SessID; }
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
using TIBCO.EMS;
|
||||
|
||||
namespace Spring.Messaging.Ems.Common
|
||||
@@ -27,49 +28,65 @@ namespace Spring.Messaging.Ems.Common
|
||||
public interface ISession
|
||||
{
|
||||
Session NativeSession { get; }
|
||||
|
||||
void Close();
|
||||
|
||||
void Commit();
|
||||
|
||||
QueueBrowser CreateBrowser(Queue queue);
|
||||
|
||||
QueueBrowser CreateBrowser(Queue queue, string messageSelector);
|
||||
|
||||
IMessageConsumer CreateConsumer(Destination dest);
|
||||
|
||||
IMessageConsumer CreateConsumer(Destination dest, string messageSelector);
|
||||
|
||||
IMessageConsumer CreateConsumer(Destination dest, string messageSelector, bool noLocal);
|
||||
|
||||
ITopicSubscriber CreateDurableSubscriber(Topic topic, string name);
|
||||
|
||||
ITopicSubscriber CreateDurableSubscriber(Topic topic, string name, string messageSelector, bool noLocal);
|
||||
|
||||
IMessageProducer CreateProducer(Destination dest);
|
||||
|
||||
|
||||
Queue CreateQueue(string queueName);
|
||||
|
||||
Topic CreateTopic(string topicName);
|
||||
|
||||
TemporaryQueue CreateTemporaryQueue();
|
||||
|
||||
TemporaryTopic CreateTemporaryTopic();
|
||||
|
||||
Message CreateMessage();
|
||||
|
||||
TextMessage CreateTextMessage();
|
||||
|
||||
TextMessage CreateTextMessage(string text);
|
||||
|
||||
MapMessage CreateMapMessage();
|
||||
|
||||
BytesMessage CreateBytesMessage();
|
||||
|
||||
ObjectMessage CreateObjectMessage();
|
||||
|
||||
ObjectMessage CreateObjectMessage(object obj);
|
||||
|
||||
StreamMessage CreateStreamMessage();
|
||||
|
||||
|
||||
void Recover();
|
||||
|
||||
void Rollback();
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("Ordinary JMS clients should not use this method.")]
|
||||
void Run();
|
||||
|
||||
void Unsubscribe(string name);
|
||||
|
||||
int AcknowledgeMode { get; }
|
||||
TIBCO.EMS.Connection Connection { get; }
|
||||
bool IsClosed { get; }
|
||||
bool IsTransacted { get; }
|
||||
|
||||
[Obsolete("Use MessageConsumer.MessageListener instead.")]
|
||||
IMessageListener MessageListener { get; set; }
|
||||
|
||||
long SessID { get; }
|
||||
SessionMode SessionAcknowledgeMode { get; }
|
||||
bool Transacted { get; }
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Spring.Messaging.Ems.Common;
|
||||
using TIBCO.EMS;
|
||||
@@ -45,15 +44,15 @@ namespace Spring.Messaging.Ems.Connections
|
||||
|
||||
#endregion
|
||||
|
||||
private ISession target;
|
||||
private LinkedList sessionList;
|
||||
private int sessionCacheSize;
|
||||
private IDictionary cachedProducers = new Hashtable();
|
||||
private IDictionary cachedConsumers = new Hashtable();
|
||||
private bool shouldCacheProducers;
|
||||
private bool shouldCacheConsumers;
|
||||
private readonly ISession target;
|
||||
private readonly LinkedList sessionList;
|
||||
private readonly int sessionCacheSize;
|
||||
private readonly IDictionary cachedProducers = new Hashtable();
|
||||
private readonly IDictionary cachedConsumers = new Hashtable();
|
||||
private readonly bool shouldCacheProducers;
|
||||
private readonly bool shouldCacheConsumers;
|
||||
private bool transactionOpen = false;
|
||||
private CachingConnectionFactory ccf;
|
||||
private readonly CachingConnectionFactory ccf;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CachedSession"/> class.
|
||||
@@ -592,19 +591,6 @@ namespace Spring.Messaging.Ems.Connections
|
||||
}
|
||||
}
|
||||
|
||||
public IMessageListener MessageListener
|
||||
{
|
||||
get {
|
||||
this.transactionOpen = true;
|
||||
return target.MessageListener;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.transactionOpen = true;
|
||||
target.MessageListener = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
@@ -621,10 +607,10 @@ namespace Spring.Messaging.Ems.Connections
|
||||
|
||||
internal class ConsumerCacheKey
|
||||
{
|
||||
private Destination destination;
|
||||
private string selector;
|
||||
private bool noLocal;
|
||||
private string subscription;
|
||||
private readonly Destination destination;
|
||||
private readonly string selector;
|
||||
private readonly bool noLocal;
|
||||
private readonly string subscription;
|
||||
|
||||
public ConsumerCacheKey(Destination destination, string selector, bool noLocal, string subscription)
|
||||
{
|
||||
|
||||
@@ -20,9 +20,13 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
using Spring.Messaging.Ems.Common;
|
||||
|
||||
using TIBCO.EMS;
|
||||
|
||||
using Common.Logging;
|
||||
|
||||
using Spring.Collections;
|
||||
using Spring.Util;
|
||||
|
||||
@@ -61,7 +65,7 @@ namespace Spring.Messaging.Ems.Connections
|
||||
{
|
||||
#region Logging Definition
|
||||
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(CachingConnectionFactory));
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof (CachingConnectionFactory));
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -75,7 +79,6 @@ namespace Spring.Messaging.Ems.Connections
|
||||
|
||||
private IDictionary cachedSessions = new Hashtable();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CachingConnectionFactory"/> class.
|
||||
/// and sets the ReconnectOnException to true
|
||||
@@ -95,7 +98,6 @@ namespace Spring.Messaging.Ems.Connections
|
||||
ReconnectOnException = true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the size of the session cache.
|
||||
/// </summary>
|
||||
@@ -122,7 +124,6 @@ namespace Spring.Messaging.Ems.Connections
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to cache MessageProducers per
|
||||
/// Session instance. (more specifically: one MessageProducer per Destination
|
||||
@@ -140,7 +141,6 @@ namespace Spring.Messaging.Ems.Connections
|
||||
set { cacheProducers = value; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether o cache JMS MessageConsumers per
|
||||
/// EMS Session instance.
|
||||
@@ -197,7 +197,7 @@ namespace Spring.Messaging.Ems.Connections
|
||||
}
|
||||
}
|
||||
}
|
||||
cachedSessions.Clear();
|
||||
cachedSessions.Clear();
|
||||
}
|
||||
this.active = true;
|
||||
// Now proceed with actual closing of the shared Connection...
|
||||
@@ -240,9 +240,10 @@ namespace Spring.Messaging.Ems.Connections
|
||||
LOG.Debug("Found cached Session for mode " + mode + ": "
|
||||
+ (session is IDecoratorSession ? ((IDecoratorSession) session).TargetSession : session));
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
ISession targetSession = CreateSession(con, mode);
|
||||
ISession targetSession = CreateSession(con, mode);
|
||||
if (LOG.IsDebugEnabled)
|
||||
{
|
||||
LOG.Debug("Creating cached Session for mode " + mode + ": " + targetSession);
|
||||
@@ -259,11 +260,10 @@ namespace Spring.Messaging.Ems.Connections
|
||||
return con.CreateSession(transacted, ackMode);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Wraps the given Session so that it delegates every method call to the target session but
|
||||
/// adapts close calls. This is useful for allowing application code to
|
||||
/// handle a special framework Session just like an ordinary Session.
|
||||
/// handle a special framework Session just like an ordinary Session.
|
||||
/// </summary>
|
||||
/// <param name="targetSession">The original Session to wrap.</param>
|
||||
/// <param name="sessionList">The List of cached Sessions that the given Session belongs to.</param>
|
||||
@@ -273,6 +273,4 @@ namespace Spring.Messaging.Ems.Connections
|
||||
return new CachedSession(targetSession, sessionList, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright 2002-2010 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
|
||||
|
||||
#if !MONO
|
||||
|
||||
#region Imports
|
||||
|
||||
using System;
|
||||
using System.EnterpriseServices;
|
||||
using Spring.Context.Support;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Spring.EnterpriseServices
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles loading of <spring/context> configuration sections for
|
||||
/// in-process <see cref="ServicedComponent"/>s generated by
|
||||
/// <see cref="EnterpriseServicesExporter"/>.
|
||||
/// </summary>
|
||||
/// <author>Erich Eichinger</author>
|
||||
[Obsolete("not used anymore")]
|
||||
public class ServicedComponentContextHandler : ContextHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Prevent auto-registering the context with the global ContextRegistry
|
||||
/// </summary>
|
||||
protected override bool AutoRegisterWithContextRegistry
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -107,7 +107,6 @@
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
<Compile Include="EnterpriseServices\ExeConfigurationSystem.cs" />
|
||||
<Compile Include="EnterpriseServices\EnterpriseServicesExporter.cs" />
|
||||
<Compile Include="EnterpriseServices\ServicedComponentContextHandler.cs" />
|
||||
<Compile Include="EnterpriseServices\ServicedComponentExporter.cs" />
|
||||
<Compile Include="EnterpriseServices\ServicedComponentFactory.cs" />
|
||||
<Compile Include="EnterpriseServices\ServicedComponentHelper.cs" />
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
|
||||
using Common.Logging;
|
||||
using NHibernate;
|
||||
using Spring.Context;
|
||||
@@ -39,13 +39,12 @@ namespace Spring.Web.Conversation
|
||||
{
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(WebConversationManager));
|
||||
|
||||
private static readonly String CONVERSATION_COOKIE_ID = "WebConversationManager.activeConversationId";
|
||||
|
||||
/// <summary>
|
||||
/// Semaphore to synchronize writes to the dictionary.
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
private Mutex mutexEditDic = new Mutex();
|
||||
|
||||
private Mutex MutexEditDic
|
||||
{
|
||||
get
|
||||
@@ -212,46 +211,6 @@ namespace Spring.Web.Conversation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="IConversationManager"/>
|
||||
/// </summary>
|
||||
[Obsolete("Not used, the active conversation is defined by call 'IConversationManager.SetActiveConversation' on 'IConversationState.StartResumeConversation'")]
|
||||
public void LoadActiveConversation()
|
||||
{
|
||||
//reset this.activeConversation
|
||||
this.activeConversation = null;
|
||||
|
||||
if (LOG.IsDebugEnabled) LOG.Debug("LoadActiveConversation");
|
||||
|
||||
HttpCookie activeConveCookie = HttpContext.Current.Request.Cookies[CONVERSATION_COOKIE_ID];
|
||||
if (activeConveCookie != null && !String.IsNullOrEmpty(activeConveCookie.Value))
|
||||
{
|
||||
if (LOG.IsDebugEnabled) LOG.Debug(String.Format("LoadActiveConversation: cooking found for current active conversation: [{0}]", activeConveCookie.ToString()));
|
||||
if (this.conversations.ContainsKey(activeConveCookie.Value))
|
||||
{
|
||||
if (LOG.IsDebugEnabled) LOG.Debug(String.Format("LoadActiveConversation: active conversation found for id: '{0}'", activeConveCookie.Value));
|
||||
IConversationState conversation = this.conversations[activeConveCookie.Value];
|
||||
if (conversation != null)
|
||||
{
|
||||
if (LOG.IsDebugEnabled) LOG.Debug(String.Format("LoadActiveConversation: conversation found: '{0}'", conversation.Id));
|
||||
//find root conversation.
|
||||
IConversationState rootConversation = conversation;
|
||||
while (rootConversation.ParentConversation != null)
|
||||
{
|
||||
rootConversation = rootConversation.ParentConversation;
|
||||
}
|
||||
rootConversation.StartResumeConversation();
|
||||
this.SetActiveConversation(rootConversation);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LOG.IsDebugEnabled) LOG.Debug(String.Format("LoadActiveConversation: conversation NOT found for id on the cookie: '{0}'", activeConveCookie.Value));
|
||||
HttpContext.Current.Response.Cookies.Remove(CONVERSATION_COOKIE_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="IConversationManager"/>
|
||||
|
||||
@@ -719,18 +719,6 @@ namespace Spring.Web.UI
|
||||
RegisterHeadScriptBlock( key, Script.DefaultType, script );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers script block that should be rendered within the <c>head</c> HTML element.
|
||||
/// </summary>
|
||||
/// <param name="key">Script key.</param>
|
||||
/// <param name="language">Script language.</param>
|
||||
/// <param name="script">Script text.</param>
|
||||
[Obsolete( "The 'language' attribute is deprecated. Please use RegisterHeadScriptBlock(string key, MimeMediaType type, string script) instead", false )]
|
||||
public void RegisterHeadScriptBlock( string key, string language, string script )
|
||||
{
|
||||
headScripts[key] = new ScriptBlock( language, script );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers script block that should be rendered within the <c>head</c> HTML element.
|
||||
/// </summary>
|
||||
@@ -752,18 +740,6 @@ namespace Spring.Web.UI
|
||||
RegisterHeadScriptFile( key, Script.DefaultType, fileName );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers script file that should be referenced within the <c>head</c> HTML element.
|
||||
/// </summary>
|
||||
/// <param name="key">Script key.</param>
|
||||
/// <param name="language">Script language.</param>
|
||||
/// <param name="fileName">Script file name.</param>
|
||||
[Obsolete( "The 'language' attribute is deprecated. Please use RegisterHeadScriptFile(string key, MimeMediaType type, string filename) instead", false )]
|
||||
public void RegisterHeadScriptFile( string key, string language, string fileName )
|
||||
{
|
||||
headScripts[key] = new ScriptFile( language, fileName );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers script file that should be referenced within the <c>head</c> HTML element.
|
||||
/// </summary>
|
||||
@@ -787,20 +763,6 @@ namespace Spring.Web.UI
|
||||
RegisterHeadScriptEvent( key, Script.DefaultType, element, eventName, script );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers script block that should be rendered within the <c>head</c> HTML element.
|
||||
/// </summary>
|
||||
/// <param name="key">Script key.</param>
|
||||
/// <param name="language">Script language.</param>
|
||||
/// <param name="element">Element ID of the event source.</param>
|
||||
/// <param name="eventName">Name of the event to handle.</param>
|
||||
/// <param name="script">Script text.</param>
|
||||
[Obsolete( "The 'language' attribute is deprecated. Please use RegisterHeadScriptEvent(string key, MimeMediaType mimeType, string element, string eventName, string script) instead" )]
|
||||
public void RegisterHeadScriptEvent( string key, string language, string element, string eventName, string script )
|
||||
{
|
||||
headScripts[key] = new ScriptEvent( language, element, eventName, script );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers script block that should be rendered within the <c>head</c> HTML element.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright 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.Diagnostics;
|
||||
using System.Reflection;
|
||||
using NUnit.Framework;
|
||||
using Spring.Context.Support;
|
||||
|
||||
#endregion
|
||||
|
||||
#pragma warning disable 618
|
||||
|
||||
namespace Spring.Reflection.Dynamic
|
||||
{
|
||||
/// <summary>
|
||||
/// Unit tests for the DynamicIndexer class.
|
||||
/// </summary>
|
||||
/// <author>Aleksandar Seovic</author>
|
||||
[TestFixture]
|
||||
public sealed class DynamicIndexerTests
|
||||
{
|
||||
private Inventor tesla;
|
||||
private Inventor pupin;
|
||||
private Society ieee;
|
||||
|
||||
#region SetUp and TearDown
|
||||
|
||||
/// <summary>
|
||||
/// The setup logic executed before the execution of each individual test.
|
||||
/// </summary>
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
ContextRegistry.Clear();
|
||||
tesla = new Inventor("Nikola Tesla", new DateTime(1856, 7, 9), "Serbian");
|
||||
tesla.Inventions = new string[]
|
||||
{
|
||||
"Telephone repeater", "Rotating magnetic field principle",
|
||||
"Polyphase alternating-current system", "Induction motor",
|
||||
"Alternating-current power transmission", "Tesla coil transformer",
|
||||
"Wireless communication", "Radio", "Fluorescent lights"
|
||||
};
|
||||
tesla.PlaceOfBirth.City = "Smiljan";
|
||||
|
||||
pupin = new Inventor("Mihajlo Pupin", new DateTime(1854, 10, 9), "Serbian");
|
||||
pupin.Inventions = new string[] { "Long distance telephony & telegraphy", "Secondary X-Ray radiation", "Sonar" };
|
||||
pupin.PlaceOfBirth.City = "Idvor";
|
||||
pupin.PlaceOfBirth.Country = "Serbia";
|
||||
|
||||
ieee = new Society();
|
||||
ieee.Members.Add(tesla);
|
||||
ieee.Members.Add(pupin);
|
||||
ieee.Officers["president"] = pupin;
|
||||
ieee.Officers["advisors"] = new Inventor[] { tesla, pupin }; // not historically accurate, but I need an array in the map ;-)
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
//DynamicReflectionManager.SaveAssembly();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
[Test]
|
||||
public void TestIndexers()
|
||||
{
|
||||
IDynamicIndexer members = DynamicIndexer.Create(typeof(ArrayList).GetProperty("Item"));
|
||||
Inventor nikola = (Inventor) members.GetValue(ieee.Members, new object[] { 0 });
|
||||
Assert.AreEqual(tesla, nikola);
|
||||
members.SetValue(ieee.Members, new object[] { 0 }, new Inventor("Ana Maria Seovic", new DateTime(2004, 8, 14), "Serbian"));
|
||||
Assert.AreEqual("Ana Maria Seovic", ((Inventor) members.GetValue(ieee.Members, 0)).Name);
|
||||
members.SetValue(ieee.Members, 1, tesla);
|
||||
Assert.AreEqual("Nikola Tesla", ((Inventor) members.GetValue(ieee.Members, 1)).Name);
|
||||
|
||||
IDynamicIndexer officers = DynamicIndexer.Create(typeof(Hashtable).GetProperty("Item"));
|
||||
Assert.AreEqual(pupin, officers.GetValue(ieee.Officers, new object[] {"president"}));
|
||||
officers.SetValue(ieee.Officers, "president",
|
||||
new Inventor("Aleksandar Seovic", new DateTime(1974, 8, 24), "Serbian"));
|
||||
Assert.AreEqual("Aleksandar Seovic", ((Inventor)officers.GetValue(ieee.Officers, "president")).Name);
|
||||
}
|
||||
|
||||
#region Performance tests
|
||||
|
||||
private DateTime start, stop;
|
||||
|
||||
//[Test]
|
||||
public void PerformanceTests()
|
||||
{
|
||||
int n = 10000000;
|
||||
object x = null;
|
||||
|
||||
// ieee.Members[0]
|
||||
start = DateTime.Now;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
x = ieee.Members[0];
|
||||
}
|
||||
stop = DateTime.Now;
|
||||
PrintTest("ieee.Members[0] (direct)", n, Elapsed);
|
||||
|
||||
start = DateTime.Now;
|
||||
IDynamicIndexer members = DynamicIndexer.Create(typeof(ArrayList).GetProperty("Item"));
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
x = members.GetValue(ieee.Members, 0);
|
||||
}
|
||||
stop = DateTime.Now;
|
||||
PrintTest("ieee.Members[0] (dynamic reflection)", n, Elapsed);
|
||||
|
||||
start = DateTime.Now;
|
||||
PropertyInfo membersPi = typeof(ArrayList).GetProperty("Item");
|
||||
object[] indexArgs = new object[] { 0 };
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
x = membersPi.GetValue(ieee.Members, indexArgs);
|
||||
}
|
||||
stop = DateTime.Now;
|
||||
PrintTest("ieee.Members[0] (standard reflection)", n, Elapsed);
|
||||
}
|
||||
|
||||
private double Elapsed
|
||||
{
|
||||
get { return (stop.Ticks - start.Ticks) / 10000000f; }
|
||||
}
|
||||
|
||||
private void PrintTest(string name, int iterations, double duration)
|
||||
{
|
||||
Debug.WriteLine(String.Format("{0,-60} {1,12:#,###} {2,12:##0.000} {3,12:#,###}", name, iterations, duration, iterations / duration));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
#pragma warning restore 618
|
||||
@@ -708,7 +708,6 @@
|
||||
<EmbeddedResource Include="Reflection\Dynamic\SafePropertyTests_TestObject.vb" />
|
||||
<Compile Include="Reflection\Dynamic\DynamicConstructorTests.cs" />
|
||||
<Compile Include="Reflection\Dynamic\DynamicFieldTests.cs" />
|
||||
<Compile Include="Reflection\Dynamic\DynamicIndexerTests.cs" />
|
||||
<Compile Include="Reflection\Dynamic\DynamicMethodTests.cs" />
|
||||
<Compile Include="Reflection\Dynamic\DynamicPropertyTests.cs" />
|
||||
<Compile Include="Reflection\Dynamic\SafeFieldTests.cs" />
|
||||
|
||||
@@ -50,14 +50,11 @@ namespace Spring.Validation
|
||||
XmlDocument doc = GetValidatedXmlResource("_WhenConfigFileIsValid.xml");
|
||||
|
||||
MockObjectDefinitionRegistry registry = new MockObjectDefinitionRegistry();
|
||||
IObjectDefinitionDocumentReader reader = new DefaultObjectDefinitionDocumentReader();
|
||||
|
||||
XmlReaderContext readerContext = new XmlReaderContext(null, new XmlObjectDefinitionReader(registry));
|
||||
ObjectDefinitionParserHelper helper = new ObjectDefinitionParserHelper(readerContext);
|
||||
helper.InitDefaults(doc.DocumentElement);
|
||||
#pragma warning disable 618
|
||||
ParserContext parserContext = new ParserContext(helper.ReaderContext, helper);
|
||||
#pragma warning restore 618
|
||||
ParserContext parserContext = new ParserContext(helper);
|
||||
|
||||
ValidationNamespaceParser parser = new ValidationNamespaceParser();
|
||||
foreach (XmlElement element in doc.DocumentElement.ChildNodes)
|
||||
@@ -159,14 +156,11 @@ namespace Spring.Validation
|
||||
XmlDocument doc = GetValidatedXmlResource("_WhenConfigFileIsNotValid.xml");
|
||||
|
||||
MockObjectDefinitionRegistry registry = new MockObjectDefinitionRegistry();
|
||||
IObjectDefinitionDocumentReader reader = new DefaultObjectDefinitionDocumentReader();
|
||||
|
||||
XmlReaderContext readerContext = new XmlReaderContext(null, new XmlObjectDefinitionReader(registry));
|
||||
ObjectDefinitionParserHelper helper = new ObjectDefinitionParserHelper(readerContext);
|
||||
helper.InitDefaults(doc.DocumentElement);
|
||||
#pragma warning disable 618
|
||||
ParserContext parserContext = new ParserContext(helper.ReaderContext, helper);
|
||||
#pragma warning restore 618
|
||||
ParserContext parserContext = new ParserContext(helper);
|
||||
|
||||
ValidationNamespaceParser parser = new ValidationNamespaceParser();
|
||||
foreach (XmlElement element in doc.DocumentElement.ChildNodes)
|
||||
|
||||
Reference in New Issue
Block a user