create netstandard2.0 targets

* Spring.Aop
* Spring.Core
* Spring.Data
* Spring.Messaging
* Spring.Testing.NUnit
This commit is contained in:
Marko Lahma
2018-09-17 21:39:25 +03:00
parent fda8281874
commit b81af45da7
212 changed files with 2338 additions and 3915 deletions

View File

@@ -1,3 +1,9 @@
Changes (2.0 to 3.0)
========================
1. .NET Framework 4.5.2 is the lowest framework supported
Changes (1.3.2 to 2.0)
========================

View File

@@ -375,7 +375,7 @@ Commandline Examples:
</items>
</in>
<do>
<echo message="Running tests for ${path}" />
<echo message="Running .NET Framework tests for ${path}" />
<property name="test.bin.dir" value="${path}/net452" />
<property name="test.assemblyname" value="${string::substring(path, string::last-index-of(path, '\') + 1, string::get-length(path) - string::last-index-of(path, '\') - 1)}" />
<property name="test.assemblyfile" value="${test.assemblyname}.dll" />
@@ -384,6 +384,9 @@ Commandline Examples:
</do>
</foreach>
<!-- run .NET Core separately for now -->
<call target="compile-test-netcore" />
<!-- build coverage summary -->
<exec program="${tool.dir}/ncoverexplorer/ncoverexplorer.console.exe" workingdir="${current.bin.dir}" failonerror="false" if="${test.coverage.tool == 'ncover' and test.withcoverage}">
<arg value="/xml:&quot;${current.bin.dir}/TestCoverageSummary.xml&quot;" />
@@ -400,8 +403,32 @@ Commandline Examples:
</exec>
</target>
<target name="compile-test-netcore">
<foreach item="File" property="file">
<in>
<items>
<include name="${spring.basedir}/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2010.csproj" />
<include name="${spring.basedir}/test/Spring/Spring.Aop.Tests/Spring.Aop.Tests.2010.csproj" />
<include name="${spring.basedir}/test/Spring/Spring.Data.Tests/Spring.Data.Tests.2010.csproj" />
<include name="${spring.basedir}/test/Spring/Spring.Testing.NUnit.Tests/Spring.Testing.NUnit.Tests.2010.csproj" />
</items>
</in>
<do>
<echo message="Running .NET Core tests for ${file}" />
<exec program="dotnet" verbose="true">
<arg line="test" />
<arg line="/nodeReuse:false" />
<arg line="-c ${current.build.config}" />
<arg line="-f netcoreapp2.1" />
<arg line="${file}" />
</exec>
</do>
</foreach>
</target>
<target name="compile-net-4.5" description="Builds .NET Framework 4.5 version"
depends="set-net-4.5-runtime-configuration, check-spring-basedir, clean-current-bin-dir, restore-nuget-packages">
depends="set-net-4.5-runtime-configuration, check-spring-basedir, restore-nuget-packages">
<property name="test.withcoverage" value="false" overwrite="true"/>
@@ -445,7 +472,7 @@ Commandline Examples:
</target>
<target name="compile-mono-2.0" description="Builds MONO Framework 2.0 version"
depends="set-mono-2.0-runtime-configuration, check-spring-basedir, clean-current-bin-dir">
depends="set-mono-2.0-runtime-configuration, check-spring-basedir">
<call target="copykeys" if="${project.build.sign}"/>
<call target="common.generate-assemblyinfo"/>
<property name="build-ems" value="false" overwrite="true" />
@@ -853,7 +880,6 @@ Commandline Examples:
<include name="**/nunit.*.xml"/>
<include name="**/NUnitAsp.dll"/>
<include name="**/NUnitAspEx.dll"/>
<include name="**/Rhino.Mocks.dll"/>
<include if="${not net-4.0}" name="**/System.Web.Extensions.dll"/>
<include name="**/Apache.NMS.dll"/>
<include name="**/Apache.NMS.pdb"/>
@@ -1089,29 +1115,6 @@ Commandline Examples:
</fileset>
</copy>
<mkdir dir="${current.package.dir}/bin/net/3.5"/>
<copy todir="${current.package.dir}/bin/net/3.5" verbose="${copy-verbose}">
<fileset basedir="./build/net/3.5">
<include name="*/Spring.Services.dll"/>
<include name="*/Spring.Services.xml"/>
<include name="*/Spring.Services.pdb"/>
<include name="*/*/Spring.Scheduling.Quartz2.dll"/>
<include name="*/*/Spring.Scheduling.Quartz2.xml"/>
<include name="*/*/Spring.Scheduling.Quartz2.pdb"/>
<include name="*/Spring.Web.Extensions.dll"/>
<include name="*/Spring.Web.Extensions.xml"/>
<include name="*/Spring.Web.Extensions.pdb"/>
<include name="*/Spring.Data.NHibernate*.dll"/>
<include name="*/Spring.Data.NHibernate*.xml"/>
<include name="*/Spring.Data.NHibernate*.pdb"/>
</fileset>
</copy>
</if>
@@ -1447,52 +1450,27 @@ Commandline Examples:
<foreach item="File" property="filename">
<in>
<items basedir="${spring.basedir}/src/spring">
<include name="**/*.nuspec" />
<items basedir="${spring.basedir}/src/Spring">
<include name="**/*.csproj" />
<exclude name="**/Spring.Messaging.Ems.csproj*" unless="${build-ems}" />
</items>
</in>
<do>
<echo message="Generating NuGet Package from nuspec file: ${filename}" />
<exec program="${tool.dir}\NuGet\NuGet.exe" workingdir="${spring.basedir}" verbose="true">
<arg value="pack" />
<arg value="${filename}" />
<arg value="-Version" />
<arg value="${nuget.package.version}" />
<arg value="-basepath" />
<arg value="${spring.basedir}" />
<arg value="-OutputDirectory" />
<arg value="${nuget.package.dir}" />
</exec>
<exec program="dotnet" verbose="true">
<arg value="pack" />
<arg value="-c" />
<arg value="Release" />
<arg value="-p:PackageVersion=${nuget.package.version}" />
<arg value="-o" />
<arg value="${nuget.package.dir}" />
<arg value="${filename}" />
</exec>
</do>
</foreach>
</target>
<target name="update-nuspec-metadata" depends="set-nuget-package-version">
<!--
INFO: this task assumes that all SPRNET components are versioned coincident with each other and
updates all version dependencies betw. SPRNET components at once
-->
<foreach item="File" property="filename">
<in>
<items basedir="${spring.basedir}/src/spring">
<include name="**/*.nuspec" />
<!--
NOTE: must exclude Spring.Core.nuspec b/c it has no Spring.* deps and so the XPATH expr. won't find a match in that case
and so would fail the XMLPOKE operation otherwise
-->
<exclude name="**/Spring.Core.nuspec" />
</items>
</in>
<do>
<echo message="Processing nuspec file: ${filename}" />
<xmlpoke file="${filename}" xpath="/n:package/n:metadata/n:dependencies/n:dependency[starts-with(@id, 'Spring.')]/@version" value="${nuget.package.version}">
<namespaces>
<namespace prefix="n" uri="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" />
</namespaces>
</xmlpoke>
</do>
</foreach>
</target>

View File

@@ -151,12 +151,6 @@
</if>
</target>
<!-- Targets for cleaning up -->
<target name="clean-current-bin-dir" depends="check-current-bin-dir"
description="Cleans the current binaries directory">
<echo message="Cleaning the ${current.bin.dir} binaries directory."/>
<delete dir="${current.bin.dir}" if="${directory::exists(current.bin.dir)}"/>
<mkdir dir="${current.bin.dir}"/>
</target>
<target name="clean-current-sdkdoc-dir" depends="check-current-sdkdoc-dir"
description="Cleans the current SDK documentation directory">
<echo message="Cleaning the ${current.sdkdoc.dir} SDK documentation directory."/>
@@ -257,7 +251,6 @@
<import namespace="System.Reflection" />
</imports>
<attributes>
<attribute type="CLSCompliantAttribute" value="${assembly.is-cls-compliant}" />
<attribute type="AssemblyConfigurationAttribute" value="${assembly.configuration}" />
<attribute type="AssemblyProductAttribute" value="${assembly.product}" />
<attribute type="AssemblyCompanyAttribute" value="${assembly.company}" />

View File

@@ -31,6 +31,7 @@ Rebuilding Solutions using Nant and "solutions.build":
<exclude name="examples/**/Spring.EmsQuickStart/*" />
<exclude name="examples/**/Spring.Examples.Pool/*" />
<exclude name="examples/**/SpringAir/*" />
<exclude name="examples/**/Spring.WebQuickStart/*" />
</items>
</in>
<do>

View File

@@ -2,6 +2,20 @@ SPRING.NET FRAMEWORK CHANGELOG
==============================
http://www.springframework.net
*****************************************************************************************
Release Version 3.0.0 XXXX XX, 2018
Release Notes - Spring.NET - Version 3.0.0
Breaking Changes
* .NET 4.5.2 is the lowest full framework supported
New Feature Highlights
* .NET Core support Spring.Aop, Spring.Core, Spring.Data, Spring.Messaging, Spring.Testing.NUnit
*****************************************************************************************
Release Version 2.0.1 April 10, 2015

View File

@@ -36,7 +36,6 @@
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<CLSCompliant>True</CLSCompliant>
<ComVisible>False</ComVisible>
<DebugSymbols>True</DebugSymbols>
@@ -44,6 +43,7 @@
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<LangVersion>latest</LangVersion>
<TargetFullFrameworkVersion>net452</TargetFullFrameworkVersion>
</PropertyGroup>

View File

@@ -41,10 +41,7 @@ namespace Spring.Aop.Framework.Adapter
/// Creates a new instance of the
/// <see cref="Spring.Aop.Framework.Adapter.UnknownAdviceTypeException"/> class.
/// </summary>
/// <param name="advice">The advice that caused the exception.</param>
public UnknownAdviceTypeException(object advice)
: base("No adapter for IAdvice of type ["
+ (advice != null ? advice.GetType().FullName : "null") + "].")
public UnknownAdviceTypeException()
{
}
@@ -52,7 +49,10 @@ namespace Spring.Aop.Framework.Adapter
/// Creates a new instance of the
/// <see cref="Spring.Aop.Framework.Adapter.UnknownAdviceTypeException"/> class.
/// </summary>
public UnknownAdviceTypeException()
/// <param name="advice">The advice that caused the exception.</param>
public UnknownAdviceTypeException(object advice)
: base("No adapter for IAdvice of type ["
+ (advice != null ? advice.GetType().FullName : "null") + "].")
{
}
@@ -84,18 +84,7 @@ namespace Spring.Aop.Framework.Adapter
{
}
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Aop.Framework.Adapter.UnknownAdviceTypeException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected UnknownAdviceTypeException(SerializationInfo info, StreamingContext context)
: base(info, context)
{

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright <20> 2002-2011 the original author or authors.
*
@@ -16,12 +14,11 @@
* limitations under the License.
*/
#endregion
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text;
using AopAlliance.Aop;
@@ -56,8 +53,6 @@ namespace Spring.Aop.Framework
[Serializable]
public class AdvisedSupport : ProxyConfig, IAdvised
{
#region Fields
/// <summary>The list of advice.</summary>
/// <remarks>
/// <p>
@@ -108,7 +103,7 @@ namespace Spring.Aop.Framework
/// <summary>
/// The list of <see cref="Spring.Aop.Framework.AdvisedSupport"/> event listeners.
/// </summary>
private readonly IList<IAdvisedSupportListener> listeners = new List<IAdvisedSupportListener>();
private readonly List<IAdvisedSupportListener> listeners = new List<IAdvisedSupportListener>();
/// <summary>
/// The advisor chain factory.
@@ -121,10 +116,6 @@ namespace Spring.Aop.Framework
/// </summary>
private bool autoDetectInterfaces;
#endregion
#region Constructor(s)
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Aop.Framework.AdvisedSupport"/> class using the
@@ -187,9 +178,46 @@ namespace Spring.Aop.Framework
TargetSource = targetSource;
}
#endregion
/// <inheritdoc />
protected AdvisedSupport(SerializationInfo info, StreamingContext context)
: base(info, context)
{
_advisors = (List<IAdvisor>) info.GetValue("advisors", typeof(List<IAdvisor>));
_advisorsArray = (IAdvisor[]) info.GetValue("advisorsArray", typeof(IAdvisor[]));
_introductions = (List<IIntroductionAdvisor>) info.GetValue("introductions", typeof(List<IIntroductionAdvisor>));
#region IAdvised implementation
var map = (Dictionary<string, IIntroductionAdvisor>) info.GetValue("interfaceMap", typeof(Dictionary<string, IIntroductionAdvisor>));
interfaceMap = new Dictionary<Type, IIntroductionAdvisor>();
foreach (var pair in map)
{
interfaceMap[Type.GetType(pair.Key)] = pair.Value;
}
m_targetSource = (ITargetSource) info.GetValue("targetSource", typeof(ITargetSource));
isActive = info.GetBoolean("isActive");
listeners = (List<IAdvisedSupportListener>) info.GetValue("listeners", typeof(List<IAdvisedSupportListener>));
advisorChainFactory = (IAdvisorChainFactory) info.GetValue("advisorChainFactory", typeof(IAdvisorChainFactory));
autoDetectInterfaces = info.GetBoolean("autoDetectInterfaces");
}
/// <inheritdoc />
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue("advisors", _advisors);
info.AddValue("advisorsArray", _advisorsArray);
info.AddValue("introductions", _introductions);
var map = new Dictionary<string, IIntroductionAdvisor>();
foreach (var pair in interfaceMap)
{
map.Add(pair.Key.AssemblyQualifiedName, pair.Value);
}
info.AddValue("interfaceMap", map);
info.AddValue("targetSource", m_targetSource);
info.AddValue("isActive", isActive);
info.AddValue("listeners", listeners);
info.AddValue("advisorChainFactory", advisorChainFactory);
info.AddValue("autoDetectInterfaces", autoDetectInterfaces);
}
/// <summary>
/// Gets and sets the
@@ -943,10 +971,6 @@ namespace Spring.Aop.Framework
return buffer.ToString();
}
#endregion
#region Properties
/// <summary>
/// Gets the target type behind the implementing object.
/// Ttypically a proxy configuration or an actual proxy.
@@ -992,8 +1016,6 @@ namespace Spring.Aop.Framework
get { return isActive; }
}
#endregion
/// <summary>
/// Specifies the <see cref="System.Type"/> of proxies that are to be
/// created for this instance of proxy config.
@@ -1342,8 +1364,6 @@ namespace Spring.Aop.Framework
this._advisorsArray = advisorsArray;
}
#region IAdvisedSupportListener support
/// <summary>
/// Callback method that is invoked when the list of proxied interfaces
/// has changed.
@@ -1399,8 +1419,6 @@ namespace Spring.Aop.Framework
}
}
#endregion
/// <summary>
/// Creates an AOP proxy using this instance's configuration data.
/// </summary>

View File

@@ -71,18 +71,7 @@ namespace Spring.Aop.Framework
{
}
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Aop.Framework.AopConfigException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected AopConfigException (
SerializationInfo info, StreamingContext context)
: base (info, context)

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright © 2002-2011 the original author or authors.
*
@@ -16,8 +14,6 @@
* limitations under the License.
*/
#endregion
using System;
using System.Collections;
using System.Collections.Generic;
@@ -73,8 +69,6 @@ namespace Spring.Aop.Framework.AutoProxy
/// <seealso cref="Spring.Aop.Framework.AutoProxy.ObjectNameAutoProxyCreator"/>
public abstract class AbstractAutoProxyCreator : ProxyConfig, IInstantiationAwareObjectPostProcessor, IObjectFactoryAware, IOrdered
{
#region Protected Fields
/// <summary>
/// The logger for this class hierarchy.
/// </summary>
@@ -91,10 +85,6 @@ namespace Spring.Aop.Framework.AutoProxy
/// </summary>
protected static readonly IList<object> PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS = new List<object>(0);
#endregion
#region Private Fields
/// <summary>
/// Default value is same as non-ordered
/// </summary>
@@ -137,10 +127,6 @@ namespace Spring.Aop.Framework.AutoProxy
private ISet nonAdvisedObjects = new SynchronizedSet(new HashedSet());
#endregion
#region Properties
/// <summary>
/// Sets the AdvisorAdapterRegistry to use.
/// </summary>
@@ -219,10 +205,6 @@ namespace Spring.Aop.Framework.AutoProxy
set { this.freezeProxy = value; }
}
#endregion
#region Constructor
/// <summary>
/// Create a new instance of this AutoProxyCreator
/// </summary>
@@ -231,10 +213,6 @@ namespace Spring.Aop.Framework.AutoProxy
logger = LogManager.GetLogger(this.GetType());
}
#endregion
#region IObjectPostProcessor Members
/// <summary>
/// Create a proxy with the configured interceptors if the object is
/// identified as one to proxy by the subclass.
@@ -246,7 +224,13 @@ namespace Spring.Aop.Framework.AutoProxy
return obj;
}
Type objectType = RemotingServices.IsTransparentProxy(obj)
#if NETSTANDARD
var isTransparentProxy = false;
#else
var isTransparentProxy = RemotingServices.IsTransparentProxy(obj);
#endif
Type objectType = isTransparentProxy
? ObjectFactory.GetType(objectName)
: obj.GetType();
@@ -258,30 +242,22 @@ namespace Spring.Aop.Framework.AutoProxy
if (IsInfrastructureType(objectType, objectName))
{
#region Instrumentation
if (logger.IsDebugEnabled)
{
logger.Debug(string.Format("Did not attempt to autoproxy infrastructure type [{0}]", objectType));
}
#endregion
nonAdvisedObjects.Add(cacheKey);
return obj;
}
if (ShouldSkip(objectType, objectName))
{
#region Instrumentation
if (logger.IsDebugEnabled)
{
logger.Debug(string.Format("Skipping type [{0}]", objectType));
}
#endregion
nonAdvisedObjects.Add(cacheKey);
return obj;
}
@@ -312,10 +288,6 @@ namespace Spring.Aop.Framework.AutoProxy
return obj;
}
#endregion
#region IObjectFactoryAware Members
/// <summary>
/// Callback that supplies the owning factory to an object instance.
/// </summary>
@@ -341,10 +313,6 @@ namespace Spring.Aop.Framework.AutoProxy
set { owningObjectFactory = value; }
}
#endregion
#region IOrdered Members
/// <summary>
/// Propery Order
/// </summary>
@@ -359,10 +327,6 @@ namespace Spring.Aop.Framework.AutoProxy
set { order = value; }
}
#endregion
#region Protected Methods
/// <summary>
/// Subclasses should override this method to return true if this
/// object should not be considered for autoproxying by this post processor.
@@ -580,10 +544,6 @@ namespace Spring.Aop.Framework.AutoProxy
}
#endregion
#region Private Methods
private IList<IAdvisor> ResolveInterceptorNames()
{
List<IAdvisor> advisors = new List<IAdvisor>();
@@ -602,10 +562,6 @@ namespace Spring.Aop.Framework.AutoProxy
return advisors;
}
#endregion
#region IInstantiationAwareObjectPostProcessor Members
/// <summary>
/// Create the proxy if have a custom TargetSource
/// </summary>
@@ -624,30 +580,22 @@ namespace Spring.Aop.Framework.AutoProxy
if (IsInfrastructureType(objectType, objectName))
{
#region Instrumentation
if (logger.IsDebugEnabled)
{
logger.Debug(string.Format("Did not attempt to autoproxy infrastructure type [{0}]", objectType));
}
#endregion
nonAdvisedObjects.Add(cacheKey);
return null;
}
if (ShouldSkip(objectType, objectName))
{
#region Instrumentation
if (logger.IsDebugEnabled)
{
logger.Debug(string.Format("Skipping type [{0}]", objectType));
}
#endregion
nonAdvisedObjects.Add(cacheKey);
return null;
}
@@ -691,7 +639,5 @@ namespace Spring.Aop.Framework.AutoProxy
{
return pvs;
}
#endregion
}
}

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright <20> 2002-2011 the original author or authors.
*
@@ -16,13 +14,10 @@
* limitations under the License.
*/
#endregion
#region Imports
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using AopAlliance.Aop;
@@ -34,8 +29,6 @@ using Spring.Aop.Framework.Adapter;
using Spring.Aop.Framework.DynamicProxy;
using Spring.Core;
#endregion
namespace Spring.Aop.Framework.AutoProxy
{
/// <summary>
@@ -46,8 +39,6 @@ namespace Spring.Aop.Framework.AutoProxy
/// <author>Bruno Baia</author>
public class InheritanceBasedAopConfigurer : IObjectFactoryPostProcessor, IObjectFactoryAware, IOrdered
{
#region Fields
private IList objectNames;
private string[] interceptorNames = new string[0];
private bool proxyTargetAttributes = true;
@@ -58,10 +49,6 @@ namespace Spring.Aop.Framework.AutoProxy
private int order = int.MaxValue;
private IAdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.Instance;
#endregion
#region Properties
/// <summary>
/// Set the names of the objects in IList fashioned way
/// that should automatically get intercepted.
@@ -134,10 +121,6 @@ namespace Spring.Aop.Framework.AutoProxy
set { proxyInterfaces = value; }
}
#endregion
#region IObjectFactoryAware Members
/// <summary>
/// Callback that supplies the owning factory to an object instance.
/// </summary>
@@ -162,10 +145,6 @@ namespace Spring.Aop.Framework.AutoProxy
set { objectFactory = value; }
}
#endregion
#region IObjectFactoryPostProcessor Members
/// <summary>
/// Allows for custom modification of an application context's object definitions.
/// </summary>
@@ -201,10 +180,6 @@ namespace Spring.Aop.Framework.AutoProxy
}
}
#endregion
#region IOrdered Members
/// <summary>
/// Return the order value of this object, where a higher value means greater in
/// terms of sorting.
@@ -221,10 +196,6 @@ namespace Spring.Aop.Framework.AutoProxy
set { order = value; }
}
#endregion
#region Protected methods
/// <summary>
/// Determines whether the object is an infrastructure type,
/// IAdvisor, IAdvice, IAdvisors, AbstractAutoProxyCreator or InheritanceBasedAopConfigurer.
@@ -302,10 +273,6 @@ namespace Spring.Aop.Framework.AutoProxy
return false;
}
#endregion
#region Private Methods
private IList<IAdvisor> ResolveInterceptorNames()
{
List<IAdvisor> advisors = new List<IAdvisor>();
@@ -324,12 +291,8 @@ namespace Spring.Aop.Framework.AutoProxy
return advisors;
}
#endregion
#region InheritanceBasedAopTargetSource inner class definition
[Serializable]
private class InheritanceBasedAopTargetSource : ITargetSource
private class InheritanceBasedAopTargetSource : ITargetSource, ISerializable
{
private readonly Type _targetType;
@@ -338,7 +301,19 @@ namespace Spring.Aop.Framework.AutoProxy
_targetType = targetType;
}
#region ITargetSource Members
/// <inheritdoc />
private InheritanceBasedAopTargetSource(SerializationInfo info, StreamingContext context)
{
var type = info.GetString("TargetType");
_targetType = type != null ? Type.GetType(type) : null;
}
/// <inheritdoc />
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("TargetType", _targetType?.AssemblyQualifiedName);
}
public object GetTarget()
{
@@ -358,10 +333,6 @@ namespace Spring.Aop.Framework.AutoProxy
{
get { return _targetType; }
}
#endregion
}
#endregion
}
}

View File

@@ -376,7 +376,7 @@ namespace Spring.Aop.Framework.DynamicProxy
returnValue = il.DeclareLocal(method.ReturnType);
}
#if DEBUG
#if DEBUG && !NETSTANDARD
interceptors.SetLocalSymInfo("interceptors");
targetType.SetLocalSymInfo("targetType");
arguments.SetLocalSymInfo("arguments");

View File

@@ -69,17 +69,7 @@ namespace Spring.Aop.Framework.DynamicProxy
#region Protected Methods
/// <summary>
/// Calculates and returns the list of attributes that apply to the
/// specified type.
/// </summary>
/// <remarks>
/// Removes <see cref="System.SerializableAttribute"/> from the list.
/// </remarks>
/// <param name="type">The type to find attributes for.</param>
/// <returns>
/// A list of custom attributes that should be applied to type.
/// </returns>
/// <inheritdoc />
protected override IList GetTypeAttributes(Type type)
{
IList attrs = base.GetTypeAttributes(type);

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright <20> 2002-2011 the original author or authors.
*
@@ -16,8 +14,6 @@
* limitations under the License.
*/
#endregion
using System;
using System.Collections;
using System.Collections.Generic;
@@ -37,10 +33,8 @@ namespace Spring.Aop.Framework.DynamicProxy
/// </summary>
/// <author>Bruno Baia</author>
[Serializable]
public class AdvisedProxy : IAdvised //, ISerializable
public class AdvisedProxy : IAdvised, ISerializable
{
#region Fields
/// <summary>
/// Should we use dynamic reflection for method invocation ?
/// </summary>
@@ -71,10 +65,6 @@ namespace Spring.Aop.Framework.DynamicProxy
/// </summary>
public Type m_targetType;
#endregion
#region Constructor (s) / Destructor
/// <summary>
/// Creates a new instance of the <see cref="AdvisedProxy"/> class.
/// </summary>
@@ -130,7 +120,9 @@ namespace Spring.Aop.Framework.DynamicProxy
m_advised = (IAdvised)info.GetValue("advised", typeof(IAdvised));
m_introductions = (IAdvice[])info.GetValue("introductions", typeof(IAdvice[]));
m_targetSource = (ITargetSource)info.GetValue("targetSource", typeof(ITargetSource));
m_targetType = (Type)info.GetValue("targetType", typeof(Type));
var type = info.GetString("targetType");
m_targetType = type != null ? Type.GetType(type) : null;
}
/// <summary>
@@ -139,18 +131,14 @@ namespace Spring.Aop.Framework.DynamicProxy
/// <param name="info">Serialization data.</param>
/// <param name="context">Serialization context.</param>
[SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)]
protected virtual void GetObjectData(SerializationInfo info, StreamingContext context)
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("advised", m_advised);
info.AddValue("introductions", m_introductions);
info.AddValue("targetSource", m_targetSource);
info.AddValue("targetType", m_targetType);
info.AddValue("targetType", m_targetType?.AssemblyQualifiedName);
}
#endregion
#region Protected Methods
/// <summary>
/// Initialization method.
/// </summary>
@@ -178,10 +166,6 @@ namespace Spring.Aop.Framework.DynamicProxy
}
}
#endregion
#region Public Methods
/// <summary>
/// Invokes intercepted methods using reflection
/// </summary>
@@ -228,10 +212,6 @@ namespace Spring.Aop.Framework.DynamicProxy
}
}
#endregion
#region IAdvised Members
bool IAdvised.ExposeProxy
{
get { return m_advised.ExposeProxy; }
@@ -400,10 +380,6 @@ namespace Spring.Aop.Framework.DynamicProxy
return m_advised.ToProxyConfigString();
}
#endregion
#region ITargetTypeAware implementation
/// <summary>
/// Gets the target type behind the implementing object.
/// Ttypically a proxy configuration or an actual proxy.
@@ -413,7 +389,5 @@ namespace Spring.Aop.Framework.DynamicProxy
{
get { return m_targetType; }
}
#endregion
}
}

View File

@@ -82,7 +82,7 @@ namespace Spring.Aop.Framework.DynamicProxy
base.DeclareLocals(il, method);
target = il.DeclareLocal(typeof(object));
#if DEBUG
#if DEBUG && !NETSTANDARD
target.SetLocalSymInfo("target");
#endif
}

View File

@@ -18,15 +18,10 @@
#endregion
#region Imports
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Collections.Concurrent;
#endregion
using System.Runtime.Serialization;
namespace Spring.Aop.Framework
{
@@ -39,7 +34,14 @@ namespace Spring.Aop.Framework
[Serializable]
public sealed class HashtableCachingAdvisorChainFactory : IAdvisorChainFactory
{
private readonly ConcurrentDictionary<MethodInfo, IList<object>> methodCache = new ConcurrentDictionary<MethodInfo, IList<object>>();
[NonSerialized]
private Dictionary<MethodInfo, IList<object>> methodCache = new Dictionary<MethodInfo, IList<object>>();
[OnDeserializing]
private void OnDeserializing(StreamingContext c)
{
methodCache = new Dictionary<MethodInfo, IList<object>>();
}
/// <summary>
/// Gets the list of <see cref="AopAlliance.Intercept.IInterceptor"/> and
@@ -61,7 +63,18 @@ namespace Spring.Aop.Framework
/// </returns>
public IList<object> GetInterceptors(IAdvised advised, object proxy, MethodInfo method, Type targetType)
{
return methodCache.GetOrAdd(method, m => AdvisorChainFactoryUtils.CalculateInterceptors(advised, proxy, m, targetType));
if (!methodCache.TryGetValue(method, out var interceptors))
{
lock (methodCache)
{
if (!methodCache.TryGetValue(method, out interceptors))
{
interceptors = AdvisorChainFactoryUtils.CalculateInterceptors(advised, proxy, method, targetType);
methodCache[method] = interceptors;
}
}
}
return interceptors;
}
/// <summary>

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright <20> 2002-2011 the original author or authors.
*
@@ -16,18 +14,13 @@
* limitations under the License.
*/
#endregion
#region Imports
using System;
using System.Runtime.Serialization;
using System.Text;
using Spring.Util;
using Spring.Reflection.Dynamic;
#endregion
namespace Spring.Aop.Framework
{
/// <summary>
@@ -48,11 +41,9 @@ namespace Spring.Aop.Framework
/// <author>Rod Johnson</author>
/// <author>Aleksandar Seovic (.NET)</author>
[Serializable]
public class ProxyConfig
public class ProxyConfig : ISerializable
{
#region Fields
private static readonly IDynamicConstructor cachedAopProxyFactoryDynCtor =
private static readonly IDynamicConstructor cachedAopProxyFactoryDynCtor =
new SafeConstructor(typeof(ProxyConfig).Assembly.GetType("Spring.Aop.Framework.DynamicProxy.CachedAopProxyFactory", false, false).GetConstructor(Type.EmptyTypes));
private bool proxyTargetType;
@@ -65,11 +56,34 @@ namespace Spring.Aop.Framework
private bool exposeProxy;
private readonly object syncRoot = new object();
#endregion
/// <inheritdoc />
public ProxyConfig()
{
}
#region Properites
/// <inheritdoc />
protected ProxyConfig(SerializationInfo info, StreamingContext context)
{
proxyTargetType = info.GetBoolean("proxyTargetType");
proxyTargetAttributes = info.GetBoolean("proxyTargetAttributes");
optimize = info.GetBoolean("optimize");
frozen = info.GetBoolean("frozen");
exposeProxy = info.GetBoolean("exposeProxy");
syncRoot = info.GetValue("syncRoot", typeof(object));
}
/// <summary>
/// <inheritdoc />
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("proxyTargetType", proxyTargetType);
info.AddValue("proxyTargetAttributes", proxyTargetAttributes);
info.AddValue("optimize", optimize);
info.AddValue("frozen", frozen);
info.AddValue("exposeProxy", exposeProxy);
info.AddValue("syncRoot", syncRoot);
}
/// <summary>
/// Use to synchronize access to this ProxyConfig instance
/// </summary>
public object SyncRoot
@@ -178,9 +192,7 @@ namespace Spring.Aop.Framework
set { this.frozen = value; }
}
#endregion
/// <summary>
/// <summary>
/// Copies the configuration from the supplied
/// <paramref name="otherConfiguration"/> into this instance.
/// </summary>

View File

@@ -18,12 +18,10 @@
#endregion
#region Imports
using System;
using AopAlliance.Intercept;
using System.Runtime.Serialization;
#endregion
using AopAlliance.Intercept;
namespace Spring.Aop.Framework
{
@@ -106,6 +104,18 @@ namespace Spring.Aop.Framework
TargetSource = targetSource;
}
/// <inheritdoc />
protected ProxyFactory(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
/// <inheritdoc />
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
}
/// <summary>
/// Creates a new proxy according to the settings in this factory.
/// </summary>
@@ -122,9 +132,7 @@ namespace Spring.Aop.Framework
return proxy.GetProxy();
}
#region Convenience Methods (Static) For Proxy Creation
/// <summary>
/// <summary>
/// Creates a new proxy for the supplied <paramref name="proxyInterface"/>
/// and <paramref name="interceptor"/>.
/// </summary>
@@ -151,8 +159,5 @@ namespace Spring.Aop.Framework
proxyFactory.AddAdvice(interceptor);
return proxyFactory.GetProxy();
}
#endregion
}
}

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright <20> 2002-2011 the original author or authors.
*
@@ -16,13 +14,10 @@
* limitations under the License.
*/
#endregion
#region Imports
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using AopAlliance.Aop;
using AopAlliance.Intercept;
@@ -37,8 +32,6 @@ using Spring.Core.TypeResolution;
using Spring.Objects.Factory;
using Spring.Util;
#endregion
namespace Spring.Aop.Framework
{
/// <summary>
@@ -98,12 +91,10 @@ namespace Spring.Aop.Framework
public class ProxyFactoryObject
: AdvisedSupport, IFactoryObject, IObjectFactoryAware
{
#region Fields
/// <summary>
/// The <see cref="Common.Logging.ILog"/> instance for this class.
/// </summary>
private readonly ILog logger;
private static readonly ILog logger = LogManager.GetLogger<ProxyFactoryObject>();
/// <summary>
/// Is the object managed by this factory a singleton or a prototype?
@@ -167,9 +158,35 @@ namespace Spring.Aop.Framework
/// </summary>
private bool freezeProxy;
#endregion
/// <inheritdoc />
protected ProxyFactoryObject(SerializationInfo info, StreamingContext context)
: base(info, context)
{
singleton = info.GetBoolean("singleton");
singletonInstance = info.GetValue("singletonInstance", typeof(object));
objectFactory = (IObjectFactory) info.GetValue("objectFactory", typeof(IObjectFactory));
advisorAdapterRegistry = (IAdvisorAdapterRegistry) info.GetValue("advisorAdapterRegistry", typeof(IAdvisorAdapterRegistry));
interceptorNames = (string[]) info.GetValue("interceptorNames", typeof(string[]));
introductionNames = (string[]) info.GetValue("introductionNames", typeof(string[]));
targetName = info.GetString("targetName");
initialized = info.GetBoolean("initialized");
freezeProxy = info.GetBoolean("freezeProxy");
}
#region Properties
/// <inheritdoc />
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue("singleton", singleton);
info.AddValue("singletonInstance", singletonInstance);
info.AddValue("objectFactory", objectFactory);
info.AddValue("advisorAdapterRegistry", advisorAdapterRegistry);
info.AddValue("interceptorNames", interceptorNames);
info.AddValue("introductionNames", introductionNames);
info.AddValue("targetName", targetName);
info.AddValue("initialized", initialized);
info.AddValue("freezeProxy", freezeProxy);
}
/// <summary>
/// Indicate whether this config shall be frozen upon creation
@@ -292,24 +309,15 @@ namespace Spring.Aop.Framework
set { this.introductionNames = value; }
}
#endregion
#region Construction and Initialization
/// <summary>
/// Creates a new instance of ProxyFactoryObject
/// </summary>
public ProxyFactoryObject()
{
this.logger = LogManager.GetLogger(this.GetType());
this.advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.Instance;
this.singleton = true;
}
#endregion
#region IObjectFactoryAware implementation
/// <summary>
/// Callback that supplies the owning factory to an object instance.
/// </summary>
@@ -331,10 +339,6 @@ namespace Spring.Aop.Framework
}
}
#endregion
#region IFactoryObject implementation
/// <summary>
/// Creates an instance of the AOP proxy to be returned by this factory
@@ -422,10 +426,6 @@ namespace Spring.Aop.Framework
set { this.singleton = value; }
}
#endregion
#region Private Methods
private object SingletonInstance
{
get
@@ -445,15 +445,11 @@ namespace Spring.Aop.Framework
// in the case of a prototype, we need to give the proxy
// an independent instance of the configuration...
#region Instrumentation
if (logger.IsDebugEnabled)
{
logger.Debug("Creating copy of prototype ProxyFactoryObject config: " + this);
}
#endregion
// The copy needs a fresh advisor chain, and a fresh TargetSource.
ITargetSource targetSource = FreshTargetSource();
IList<IAdvisor> advisorChain = FreshAdvisorChain();
@@ -461,12 +457,10 @@ namespace Spring.Aop.Framework
AdvisedSupport copy = new AdvisedSupport();
copy.CopyConfigurationFrom(this, targetSource, advisorChain, introductionChain);
#region Instrumentation
if (logger.IsDebugEnabled)
{
logger.Debug("Using ProxyConfig: " + copy);
}
#endregion
object generatedProxy = copy.CreateAopProxy().GetProxy();
base.IsFrozen = this.freezeProxy; // freeze after creating proxy to allow for interface autodetection
@@ -478,22 +472,18 @@ namespace Spring.Aop.Framework
/// </summary>
private void Initialize()
{
#region Instrumentation
if (logger.IsDebugEnabled)
{
logger.Debug(string.Format("Initialize: begin configure target, interceptors and introductions for {0}[{1}]", this.GetType().Name, this.GetHashCode()));
}
#endregion
InitializeAdvisorChain();
InitializeIntroductionChain();
#region Instrumentation
if (logger.IsDebugEnabled)
{
logger.Debug(string.Format("Initialize: completed configuration for {0}[{1}]: {2}", this.GetType().Name, this.GetHashCode(), this.ToProxyConfigString()));
}
#endregion
}
/// <summary>Create the advisor (interceptor) chain.</summary>
@@ -536,23 +526,19 @@ namespace Spring.Aop.Framework
throw new AopConfigException("Can only use global advisors or interceptors in conjunction with an IListableObjectFactory.");
}
#region Instrumentation
if (logger.IsDebugEnabled)
{
logger.Debug("Adding global advisor '" + name + "'");
}
#endregion
AddGlobalAdvisor(lof, name.Substring(0, (name.Length - GlobalInterceptorSuffix.Length)));
}
else
{
#region Instrumentation
if (logger.IsDebugEnabled)
{
logger.Debug("resolving advisor name " + "'" + name + "'");
}
#endregion
// If we get here, we need to add a named interceptor.
// We must check if it's a singleton or prototype.
@@ -575,34 +561,29 @@ namespace Spring.Aop.Framework
{
if (advice is IAdvisors)
{
#region Instrumentation
if (logger.IsDebugEnabled)
{
logger.Debug(string.Format("Adding advisor list '{0}'", name));
}
#endregion
IAdvisors advisors = (IAdvisors)advice;
foreach (object element in advisors.Advisors)
{
#region Instrumentation
if (logger.IsDebugEnabled)
{
logger.Debug(string.Format("Adding advisor '{0}' of type {1}", name, element.GetType().FullName));
}
#endregion
IAdvisor advisor = NamedObjectToAdvisor(element);
AddAdvisor(advisor);
}
}
else
{
#region Instrumentation
if (logger.IsDebugEnabled)
{
logger.Debug(string.Format("Adding advisor '{0}' of type {1}", name, advice.GetType().FullName));
}
#endregion
IAdvisor advisor = NamedObjectToAdvisor(advice);
AddAdvisor(advisor);
@@ -701,12 +682,10 @@ namespace Spring.Aop.Framework
throw new AopConfigException("Found null interceptor name value in the InterceptorNames list; check your configuration.");
}
#region Instrumentation
if (logger.IsDebugEnabled)
{
logger.Debug("Adding introduction '" + name + "'");
}
#endregion
if (name.EndsWith(GlobalInterceptorSuffix))
{
@@ -820,25 +799,21 @@ namespace Spring.Aop.Framework
{
if (StringUtils.IsNullOrEmpty(this.targetName))
{
#region Instrumentation
if (logger.IsDebugEnabled)
{
logger.Debug("Not Refreshing TargetSource: No target name specified");
}
#endregion
return this.TargetSource;
}
AssertUtils.ArgumentNotNull(this.objectFactory, "ObjectFactory");
#region Instrumentation
if (logger.IsDebugEnabled)
{
logger.Debug("Refreshing TargetSource with name '" + this.targetName + "'");
}
#endregion
object target = this.objectFactory.GetObject(this.targetName);
ITargetSource targetSource = NamedObjectToTargetSource(target);
return targetSource;
@@ -857,12 +832,11 @@ namespace Spring.Aop.Framework
if (advisor is PrototypePlaceholder)
{
PrototypePlaceholder pa = (PrototypePlaceholder)advisor;
#region Instrumentation
if (logger.IsDebugEnabled)
{
logger.Debug(string.Format("Refreshing advisor '{0}'", pa.ObjectName));
}
#endregion
AssertUtils.ArgumentNotNull(this.objectFactory, "ObjectFactory");
object advisorObject = this.objectFactory.GetObject(pa.ObjectName);
@@ -890,12 +864,11 @@ namespace Spring.Aop.Framework
if (introduction is PrototypePlaceholder)
{
PrototypePlaceholder pa = (PrototypePlaceholder)introduction;
#region Instrumentation
if (logger.IsDebugEnabled)
{
logger.Debug(string.Format("Refreshing introduction '{0}'", pa.ObjectName));
}
#endregion
AssertUtils.ArgumentNotNull(this.objectFactory, "ObjectFactory");
object introductionObject = this.objectFactory.GetObject(pa.ObjectName);
@@ -950,8 +923,6 @@ namespace Spring.Aop.Framework
return new DefaultIntroductionAdvisor((IAdvice)introduction);
}
#endregion
/// <summary>
/// Callback method that is invoked when the list of proxied interfaces
/// has changed.
@@ -1027,8 +998,6 @@ namespace Spring.Aop.Framework
this.message = "Placeholder for prototype Advisor/Advice/Introduction with bean name '" + objectName + "'";
}
#region Implementation of IAdvisor
public bool IsPerInstance
{
get { throw new NotSupportedException("Cannot invoke methods: " + this.message); }
@@ -1039,10 +1008,6 @@ namespace Spring.Aop.Framework
get { throw new NotSupportedException("Cannot invoke methods: " + this.message); }
}
#endregion
#region Implementation of IIntroductionAdvisor
public ITypeFilter TypeFilter
{
get { throw new NotSupportedException("Cannot invoke methods: " + this.message); }
@@ -1057,8 +1022,6 @@ namespace Spring.Aop.Framework
{
throw new NotSupportedException("Cannot invoke methods: " + this.message);
}
#endregion
}
}
}

View File

@@ -1,51 +1,51 @@
#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 AopAlliance.Aop;
namespace Spring.Aop.Support
{
/// <summary>
/// Abstract PointcutAdvisor that allows for any Advice to be configured.
/// </summary>
/// <author>Juergen Hoeller</author>
/// <author>Mark Pollack (.NET)</author>
[Serializable]
public abstract class AbstractGenericPointcutAdvisor : AbstractPointcutAdvisor
{
private IAdvice advice;
/// <summary>
/// Return the advice part of this advisor.
/// </summary>
/// <returns>
/// The advice that should apply if the pointcut matches.
/// </returns>
/// <see cref="Spring.Aop.IAdvisor.Advice"/>
public override IAdvice Advice
{
get { return this.advice; }
set { this.advice = value; }
}
#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 AopAlliance.Aop;
namespace Spring.Aop.Support
{
/// <summary>
/// Abstract PointcutAdvisor that allows for any Advice to be configured.
/// </summary>
/// <author>Juergen Hoeller</author>
/// <author>Mark Pollack (.NET)</author>
[Serializable]
public abstract class AbstractGenericPointcutAdvisor : AbstractPointcutAdvisor
{
private IAdvice advice;
/// <summary>
/// Return the advice part of this advisor.
/// </summary>
/// <returns>
/// The advice that should apply if the pointcut matches.
/// </returns>
/// <see cref="Spring.Aop.IAdvisor.Advice"/>
public override IAdvice Advice
{
get { return this.advice; }
set { this.advice = value; }
}
///<summary>
/// 2 <see cref="AbstractGenericPointcutAdvisor"/>s are considered equals, if
/// a) their pointcuts are equal
@@ -62,18 +62,18 @@ namespace Spring.Aop.Support
public override int GetHashCode()
{
return base.GetHashCode();
}
}
/// <summary>
/// Returns a <see cref="System.String"/> that represents the current
/// <see cref="System.Object"/>.
/// </summary>
/// <returns>
/// A <see cref="System.String"/> representation of this advisor.
/// </returns>
public override string ToString()
{
return GetType().Name + ": advice=[" + Advice + "]";
}
}
/// <summary>
/// Returns a <see cref="System.String"/> that represents the current
/// <see cref="System.Object"/>.
/// </summary>
/// <returns>
/// A <see cref="System.String"/> representation of this advisor.
/// </returns>
public override string ToString()
{
return GetType().Name + ": advice=[" + Advice + "]";
}
}
}

View File

@@ -1,131 +1,110 @@
#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 AopAlliance.Aop;
using Spring.Core;
namespace Spring.Aop.Support
{
/// <summary>
/// Abstract base class for <see cref="IPointcutAdvisor"/> implementations.
/// </summary>
/// <remarks>
/// Can be subclassed for returning a specific pointcut/advice or a freely configurable pointcut/advice.
/// </remarks>
/// <author>Rod Johnson</author>
/// <author>Juergen Hoeller</author>
/// <author>Mark Pollack (.NET)</author>
[Serializable]
public abstract class AbstractPointcutAdvisor : IPointcutAdvisor, IOrdered
{
#region Fields
private int _order = Int32.MaxValue;
#endregion
#region IOrdered Members
/// <summary>
/// Returns this <see cref="Spring.Aop.IAdvisor"/>s order in the
/// interception chain.
/// </summary>
/// <returns>
/// This <see cref="Spring.Aop.IAdvisor"/>s order in the
/// interception chain.
/// </returns>
public virtual int Order
{
get { return this._order; }
set { this._order = value; }
}
#endregion
#region IAdvisor Members
/// <summary>
/// Return the advice part of this aspect.
/// </summary>
/// <remarks>
/// <p>
/// An advice may be an interceptor, a throws advice, before advice,
/// introduction etc.
/// </p>
/// </remarks>
/// <returns>
/// The advice that should apply if the pointcut matches.
/// </returns>
public abstract IAdvice Advice { get; set; }
/// <summary>
/// Is this advice associated with a particular instance?
/// </summary>
/// <remarks>
/// <p>
/// Not supported for dynamic advisors.
/// </p>
/// </remarks>
/// <value>
/// <see langword="true"/> if this advice is associated with a
/// particular instance.
/// </value>
/// <exception cref="System.NotSupportedException">Always.</exception>
/// <see cref="Spring.Aop.IAdvisor.IsPerInstance"/>
public virtual bool IsPerInstance
{
get
{
throw new NotSupportedException(
"The 'IsPerInstance' property of the IAdvisor interface " +
"is not yet supported in Spring.NET.");
}
}
#endregion
#region IPointcutAdvisor Members
/// <summary>
/// The <see cref="Spring.Aop.IPointcut"/> that drives this advisor.
/// </summary>
public abstract IPointcut Pointcut { get; set; }
#endregion
#region Methods
/// <summary>
/// Determines whether the specified <see cref="System.Object"/>
/// is equal to the current <see cref="System.Object"/>.
/// </summary>
/// <param name="o">The advisor to compare with.</param>
/// <returns>
/// <see langword="true"/> if this instance is equal to the
/// specified <see cref="System.Object"/>.
/// </returns>
public override bool Equals(object o)
{
if (!(o is AbstractPointcutAdvisor))
{
return false;
/*
* 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.
*/
using System;
using AopAlliance.Aop;
using Spring.Core;
namespace Spring.Aop.Support
{
/// <summary>
/// Abstract base class for <see cref="IPointcutAdvisor"/> implementations.
/// </summary>
/// <remarks>
/// Can be subclassed for returning a specific pointcut/advice or a freely configurable pointcut/advice.
/// </remarks>
/// <author>Rod Johnson</author>
/// <author>Juergen Hoeller</author>
/// <author>Mark Pollack (.NET)</author>
[Serializable]
public abstract class AbstractPointcutAdvisor : IPointcutAdvisor, IOrdered
{
private int _order = Int32.MaxValue;
/// <summary>
/// Returns this <see cref="Spring.Aop.IAdvisor"/>s order in the
/// interception chain.
/// </summary>
/// <returns>
/// This <see cref="Spring.Aop.IAdvisor"/>s order in the
/// interception chain.
/// </returns>
public virtual int Order
{
get { return this._order; }
set { this._order = value; }
}
/// <summary>
/// Return the advice part of this aspect.
/// </summary>
/// <remarks>
/// <p>
/// An advice may be an interceptor, a throws advice, before advice,
/// introduction etc.
/// </p>
/// </remarks>
/// <returns>
/// The advice that should apply if the pointcut matches.
/// </returns>
public abstract IAdvice Advice { get; set; }
/// <summary>
/// Is this advice associated with a particular instance?
/// </summary>
/// <remarks>
/// <p>
/// Not supported for dynamic advisors.
/// </p>
/// </remarks>
/// <value>
/// <see langword="true"/> if this advice is associated with a
/// particular instance.
/// </value>
/// <exception cref="System.NotSupportedException">Always.</exception>
/// <see cref="Spring.Aop.IAdvisor.IsPerInstance"/>
public virtual bool IsPerInstance
{
get
{
throw new NotSupportedException(
"The 'IsPerInstance' property of the IAdvisor interface " +
"is not yet supported in Spring.NET.");
}
}
/// <summary>
/// The <see cref="Spring.Aop.IPointcut"/> that drives this advisor.
/// </summary>
public abstract IPointcut Pointcut { get; set; }
/// <summary>
/// Determines whether the specified <see cref="System.Object"/>
/// is equal to the current <see cref="System.Object"/>.
/// </summary>
/// <param name="o">The advisor to compare with.</param>
/// <returns>
/// <see langword="true"/> if this instance is equal to the
/// specified <see cref="System.Object"/>.
/// </returns>
public override bool Equals(object o)
{
if (!(o is AbstractPointcutAdvisor))
{
return false;
}
if (ReferenceEquals(this, o))
@@ -133,44 +112,42 @@ namespace Spring.Aop.Support
return true;
}
AbstractPointcutAdvisor otherAdvisor = (AbstractPointcutAdvisor)o;
if (this.Order != otherAdvisor.Order)
AbstractPointcutAdvisor otherAdvisor = (AbstractPointcutAdvisor)o;
if (this.Order != otherAdvisor.Order)
{
return false;
}
if (otherAdvisor.Advice == null && otherAdvisor.Pointcut == null)
{
return (this.Advice == null && this.Pointcut == null);
}
else if (otherAdvisor.Advice == null)
{
return (Advice == null && otherAdvisor.Pointcut.Equals(this.Pointcut));
}
else if (otherAdvisor.Pointcut == null)
{
return (this.Pointcut == null && otherAdvisor.Advice.Equals(this.Advice));
}
else
{
return otherAdvisor.Advice.Equals(this.Advice) && otherAdvisor.Pointcut.Equals(this.Pointcut);
}
}
/// <summary>
/// Serves as a hash function for a particular type, suitable for use
/// in hashing algorithms and data structures like a hash table.
/// </summary>
/// <returns>
/// A hash code for the current <see cref="System.Object"/>.
/// </returns>
public override int GetHashCode()
{
return 0 // (SPRNET-847) base.GetHashCode()
+ 13 * (Pointcut == null ? 0 : Pointcut.GetHashCode())
+ 27 * (Advice == null ? 0 : Advice.GetHashCode())
+ 31 * Order.GetHashCode();
}
#endregion
}
}
if (otherAdvisor.Advice == null && otherAdvisor.Pointcut == null)
{
return (this.Advice == null && this.Pointcut == null);
}
else if (otherAdvisor.Advice == null)
{
return (Advice == null && otherAdvisor.Pointcut.Equals(this.Pointcut));
}
else if (otherAdvisor.Pointcut == null)
{
return (this.Pointcut == null && otherAdvisor.Advice.Equals(this.Advice));
}
else
{
return otherAdvisor.Advice.Equals(this.Advice) && otherAdvisor.Pointcut.Equals(this.Pointcut);
}
}
/// <summary>
/// Serves as a hash function for a particular type, suitable for use
/// in hashing algorithms and data structures like a hash table.
/// </summary>
/// <returns>
/// A hash code for the current <see cref="System.Object"/>.
/// </returns>
public override int GetHashCode()
{
return 0 // (SPRNET-847) base.GetHashCode()
+ 13 * (Pointcut == null ? 0 : Pointcut.GetHashCode())
+ 27 * (Advice == null ? 0 : Advice.GetHashCode())
+ 31 * Order.GetHashCode();
}
}
}

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright <20> 2002-2011 the original author or authors.
*
@@ -16,10 +14,6 @@
* limitations under the License.
*/
#endregion
#region Imports
using System;
using System.Reflection;
using System.Runtime.Serialization;
@@ -29,8 +23,6 @@ using AopAlliance.Aop;
using Spring.Util;
#endregion
namespace Spring.Aop.Support
{
/// <summary>
@@ -44,7 +36,7 @@ namespace Spring.Aop.Support
/// </p>
/// <p>
/// This base class is serializable. Subclasses should decorate all
/// fields with the <see cref="System.NonSerializedAttribute"/> - the
/// fields with the NonSerializedAttribute - the
/// <see cref="AbstractRegularExpressionMethodPointcut.InitPatternRepresentation"/>
/// method in this class will be invoked again on the client side on deserialization.
/// </p>
@@ -59,8 +51,6 @@ namespace Spring.Aop.Support
[NonSerialized]
private object[] _patterns = ObjectUtils.EmptyObjects;
#region Constructors
/// <summary>
/// Creates a new instance of the
/// <see cref="AbstractRegularExpressionMethodPointcut"/>
@@ -76,21 +66,7 @@ namespace Spring.Aop.Support
{
}
/// <summary>
/// Creates a new instance of the <see cref="AbstractRegularExpressionMethodPointcut"/>
/// class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <exception cref="AopAlliance.Aop.AspectException">
/// If an error was encountered during the deserialization process.
/// </exception>
/// <inheritdoc />
protected AbstractRegularExpressionMethodPointcut(
SerializationInfo info, StreamingContext context)
{
@@ -118,10 +94,6 @@ namespace Spring.Aop.Support
}
}
#endregion
#region Properties
/// <summary>
/// The <see cref="Spring.Aop.ITypeFilter"/> for this pointcut.
/// </summary>
@@ -167,22 +139,7 @@ namespace Spring.Aop.Support
}
}
#endregion
#region Methods
/// <summary>
/// Populates a <see cref="System.Runtime.Serialization.SerializationInfo"/> with
/// the data needed to serialize the target object.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/> to populate
/// with data.
/// </param>
/// <param name="context">
/// The destination (see <see cref="System.Runtime.Serialization.StreamingContext"/>)
/// for this serialization.
/// </param>
/// <inheritdoc />
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
@@ -292,7 +249,5 @@ namespace Spring.Aop.Support
{
return true;
}
#endregion
}
}

View File

@@ -22,6 +22,8 @@
using System;
using System.Reflection;
using System.Runtime.Serialization;
using Spring.Util;
#endregion
@@ -35,7 +37,7 @@ namespace Spring.Aop.Support
/// <author>Aleksandar Seovic</author>
/// <author>Ronald Wildenberg</author>
[Serializable]
public class AttributeMatchMethodPointcut : StaticMethodMatcherPointcut
public class AttributeMatchMethodPointcut : StaticMethodMatcherPointcut, ISerializable
{
private Type _attribute;
private bool _inherit = true;
@@ -101,6 +103,23 @@ namespace Spring.Aop.Support
CheckInterfaces = checkInterfaces;
}
/// <inheritdoc />
protected AttributeMatchMethodPointcut(SerializationInfo info, StreamingContext context)
{
Inherit = info.GetBoolean("Inherit");
CheckInterfaces = info.GetBoolean("CheckInterfaces");
var type = info.GetString("Attribute");
Attribute = type != null ? Type.GetType(type) : null;
}
/// <inheritdoc />
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("Attribute", Attribute?.AssemblyQualifiedName);
info.AddValue("Inherit", Inherit);
info.AddValue("CheckInterfaces", CheckInterfaces);
}
/// <summary>
/// The <see cref="System.Attribute"/> to match.
/// </summary>

View File

@@ -21,6 +21,8 @@
#region Imports
using System;
using System.Runtime.Serialization;
using AopAlliance.Aop;
using Spring.Core;
@@ -35,7 +37,7 @@ namespace Spring.Aop.Support
/// <author>Bruno Baia</author>
[Serializable]
public class AttributeMatchMethodPointcutAdvisor
: AttributeMatchMethodPointcut, IPointcutAdvisor, IOrdered
: AttributeMatchMethodPointcut, IPointcutAdvisor, IOrdered, ISerializable
{
private int _order = Int32.MaxValue;
private IAdvice _advice;
@@ -78,6 +80,22 @@ namespace Spring.Aop.Support
this._advice = advice;
}
/// <inheritdoc />
private AttributeMatchMethodPointcutAdvisor(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Order = info.GetInt32("Order");
Advice = (IAdvice) info.GetValue("Advice", typeof(IAdvice));
}
/// <inheritdoc />
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue("Order", Order);
info.AddValue("Advice", Advice);
}
/// <summary>
/// Is this advice associated with a particular instance?
/// </summary>

View File

@@ -20,6 +20,8 @@
using System;
using System.Reflection;
using System.Runtime.Serialization;
using Spring.Util;
namespace Spring.Aop.Support
@@ -33,7 +35,7 @@ namespace Spring.Aop.Support
/// <author>Mark Pollack</author>
/// <seealso cref="AttributeMatchingPointcut"/>
[Serializable]
public class AttributeMethodMatcher : StaticMethodMatcher
public class AttributeMethodMatcher : StaticMethodMatcher, ISerializable
{
private readonly Type attributeType;
@@ -49,6 +51,19 @@ namespace Spring.Aop.Support
this.attributeType = attributeType;
}
/// <inheritdoc />
private AttributeMethodMatcher(SerializationInfo info, StreamingContext context)
{
var type = info.GetString("AttributeType");
attributeType = type != null ? Type.GetType(type) : null;
}
/// <inheritdoc />
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("AttributeType", attributeType?.AssemblyQualifiedName);
}
/// <summary>
/// Does the supplied <paramref name="method"/> satisfy this matcher?
/// </summary>

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright <20> 2002-2011 the original author or authors.
*
@@ -16,15 +14,11 @@
* limitations under the License.
*/
#endregion
#region Imports
using System;
using System.Reflection;
using Spring.Core;
using System.Runtime.Serialization;
#endregion
using Spring.Core;
namespace Spring.Aop.Support
{
@@ -42,19 +36,13 @@ namespace Spring.Aop.Support
/// <author>Rod Johnson</author>
/// <author>Simon White (.NET)</author>
[Serializable]
public class ControlFlowPointcut : IPointcut, ITypeFilter, IMethodMatcher
public class ControlFlowPointcut : IPointcut, ITypeFilter, IMethodMatcher, ISerializable
{
#region Fields
private Type _type;
private Type _type;
private string _methodName;
private int _evaluationCount;
#endregion
#region Constructor (s) / Destructor
/// <summary>
/// <summary>
/// Creates a new instance of the <see cref="ControlFlowPointcut"/>
/// class.
/// </summary>
@@ -88,11 +76,24 @@ namespace Spring.Aop.Support
_methodName = methodName;
}
#endregion
/// <inheritdoc />
private ControlFlowPointcut(SerializationInfo info, StreamingContext context)
{
var type = info.GetString("Type");
_type = type != null ? Type.GetType(type) : null;
_methodName = info.GetString("MethodName");
_evaluationCount = info.GetInt32("EvaluationCount");
}
/// <inheritdoc />
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("Type", _type?.AssemblyQualifiedName);
info.AddValue("MethodName", _methodName);
info.AddValue("EvaluationCount", _evaluationCount);
}
#region Properties
/// <summary>
/// <summary>
/// The <see cref="Spring.Aop.ITypeFilter"/> for this pointcut.
/// </summary>
/// <value>
@@ -154,11 +155,7 @@ namespace Spring.Aop.Support
get { return true; }
}
#endregion
#region Methods
/// <summary>
/// <summary>
/// Should the pointcut apply to the supplied <see cref="System.Type"/>?
/// </summary>
/// <remarks>
@@ -237,7 +234,5 @@ namespace Spring.Aop.Support
? cflow.Under(_type, _methodName)
: cflow.Under(_type);
}
#endregion
}
}

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright 2002-2010 the original author or authors.
*
@@ -16,18 +14,12 @@
* limitations under the License.
*/
#endregion
#region Imports
using System;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using Common.Logging;
using Spring.Util;
#endregion
namespace Spring.Aop.Support
{
/// <summary>
@@ -48,13 +40,13 @@ namespace Spring.Aop.Support
[Serializable]
public class SdkRegularExpressionMethodPointcut : AbstractRegularExpressionMethodPointcut
{
private ILog _logger = LogManager.GetLogger(typeof(SdkRegularExpressionMethodPointcut));
[NonSerialized]
private static readonly ILog _logger = LogManager.GetLogger(typeof(SdkRegularExpressionMethodPointcut));
private Regex[] _compiledPatterns = new Regex[0];
private RegexOptions _defaultOptions = RegexOptions.None;
#region Constructors
/// <summary>
/// <summary>
/// Creates a new instance of the
/// <see cref="SdkRegularExpressionMethodPointcut"/> class.
/// </summary>
@@ -75,30 +67,12 @@ namespace Spring.Aop.Support
Patterns = patterns;
}
/// <summary>
/// Creates a new instance of the
/// <see cref="SdkRegularExpressionMethodPointcut"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <exception cref="AopAlliance.Aop.AspectException">
/// If an error was encountered during the deserialization process.
/// </exception>
/// <inheritdoc />
protected SdkRegularExpressionMethodPointcut(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
#endregion
#region Properties
/// <summary>
/// Gets or sets default options that should be used by
/// regular expressions that don't have options explicitly set.
@@ -117,10 +91,6 @@ namespace Spring.Aop.Support
}
}
#endregion
#region Methods
/// <summary>
/// Initializes the regular expression pointcuts.
/// </summary>
@@ -189,19 +159,13 @@ namespace Spring.Aop.Support
Match match = _compiledPatterns[patternIndex].Match(pattern);
bool matched = match.Success;
#region Instrumentation
if (_logger.IsDebugEnabled)
{
_logger.Debug("Candidate is: '" + pattern + "'; pattern is '" +
_compiledPatterns[patternIndex].ToString() + "'; matched=" + matched);
}
#endregion
return matched;
}
#endregion
}
}

View File

@@ -101,8 +101,6 @@ namespace Spring.Aop.Support
public abstract bool Matches(MethodInfo method, Type targetType);
#region Serialization Support
void IDeserializationCallback.OnDeserialization(object sender)
{
OnDeserialization(sender);
@@ -114,7 +112,5 @@ namespace Spring.Aop.Support
protected virtual void OnDeserialization(object sender)
{
}
#endregion
}
}

View File

@@ -128,26 +128,13 @@ namespace Spring.Aop.Target
return "EmptyTargetSource: no target";
}
/// <summary>
/// Populates a <see cref="System.Runtime.Serialization.SerializationInfo"/> with
/// the data needed to serialize the target object.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/> to populate
/// with data.
/// </param>
/// <param name="context">
/// The destination (see <see cref="System.Runtime.Serialization.StreamingContext"/>)
/// for this serialization.
/// </param>
/// <inheritdoc />
[SecurityPermission(SecurityAction.Demand, SerializationFormatter=true)]
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.SetType(typeof (EmptyTargetSourceObjectReference));
}
[Serializable]
private sealed class EmptyTargetSourceObjectReference : IObjectReference
{

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright <20> 2002-2011 the original author or authors.
*
@@ -16,14 +14,10 @@
* limitations under the License.
*/
#endregion
#region Imports
using System;
using Spring.Util;
using System.Runtime.Serialization;
#endregion
using Spring.Util;
namespace Spring.Aop.Target
{
@@ -42,7 +36,7 @@ namespace Spring.Aop.Target
/// <author>Rod Johnson</author>
/// <author>Aleksandar Seovic (.NET)</author>
[Serializable]
public sealed class SingletonTargetSource : ITargetSource
public sealed class SingletonTargetSource : ITargetSource, ISerializable
{
private readonly object target;
private readonly Type targetType;
@@ -80,7 +74,13 @@ namespace Spring.Aop.Target
this.targetType = targetType;
}
#region ITarget Source impl
/// <inheritdoc />
private SingletonTargetSource(SerializationInfo info, StreamingContext context)
{
target = info.GetValue("Target", typeof(object));
var type = info.GetString("TargetTypeName");
targetType = type != null ? Type.GetType(type) : null;
}
/// <summary>
/// The <see cref="System.Type"/> of the target object.
@@ -127,7 +127,12 @@ namespace Spring.Aop.Target
}
#endregion
/// <inheritdoc />
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("TargetTypeName", targetType?.AssemblyQualifiedName);
info.AddValue("Target", target);
}
/// <summary>
/// Returns a stringified representation of this target source.

View File

@@ -124,18 +124,7 @@ namespace Spring.Aop
return "TrueMethodMatcher.True";
}
/// <summary>
/// Populates a <see cref="System.Runtime.Serialization.SerializationInfo"/> with
/// the data needed to serialize the target object.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/> to populate
/// with data.
/// </param>
/// <param name="context">
/// The destination (see <see cref="System.Runtime.Serialization.StreamingContext"/>)
/// for this serialization.
/// </param>
/// <inheritdoc />
[SecurityPermission (SecurityAction.Demand,SerializationFormatter=true)]
public void GetObjectData(SerializationInfo info, StreamingContext context)
{

View File

@@ -91,18 +91,7 @@ namespace Spring.Aop
return "TruePointcut.TRUE";
}
/// <summary>
/// Populates a <see cref="System.Runtime.Serialization.SerializationInfo"/> with
/// the data needed to serialize the target object.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/> to populate
/// with data.
/// </param>
/// <param name="context">
/// The destination (see <see cref="System.Runtime.Serialization.StreamingContext"/>)
/// for this serialization.
/// </param>
/// <inheritdoc />
[SecurityPermission (SecurityAction.Demand,SerializationFormatter=true)]
public void GetObjectData(SerializationInfo info, StreamingContext context)
{

View File

@@ -93,18 +93,7 @@ namespace Spring.Aop
return "TrueTypeFilter.True";
}
/// <summary>
/// Populates a <see cref="System.Runtime.Serialization.SerializationInfo"/> with
/// the data needed to serialize the target object.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/> to populate
/// with data.
/// </param>
/// <param name="context">
/// The destination (see <see cref="System.Runtime.Serialization.StreamingContext"/>)
/// for this serialization.
/// </param>
/// <inheritdoc />
[SecurityPermission(SecurityAction.Demand, SerializationFormatter=true)]
public void GetObjectData(SerializationInfo info, StreamingContext context)
{

View File

@@ -59,18 +59,7 @@ namespace AopAlliance.Aop
{
}
/// <summary>
/// Creates a new instance of the
/// <see cref="AopAlliance.Aop.AspectException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected AspectException(SerializationInfo info, StreamingContext context)
: base(info, context)
{

View File

@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net452</TargetFrameworks>
<TargetFrameworks>netstandard2.0;$(TargetFullFrameworkVersion)</TargetFrameworks>
<Description>Interfaces and classes that provide AOP support in Spring.Net</Description>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Antlr" Version="3.5.0.2" />
<PackageReference Include="Antlr3.Runtime" Version="3.5.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Spring.Core\Spring.Core.2010.csproj" />

View File

@@ -47,7 +47,7 @@ namespace Spring.Context.Attributes
"NUnit",
"Quartz",
"NVelocity",
"Rhino.Mocks",
"FakeItEasy",
"Apache.NMS"
};

View File

@@ -22,7 +22,6 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
using Common.Logging;
using Spring.Util;
@@ -39,7 +38,7 @@ namespace Spring.Context.Attributes
/// </summary>
protected static readonly ILog Logger = LogManager.GetLogger<AssemblyTypeSource>();
private readonly _Assembly _assembly;
private readonly Assembly _assembly;
/// <summary>
/// Initializes a new instance of the <see cref="AssemblyTypeSource"/> class.

View File

@@ -173,7 +173,7 @@ namespace Spring.Context.Attributes
new ConfigurationClassProxyMethodBuilder(typeBuilder, this, false, targetMethods),
BaseType, this.DeclaredMembersOnly);
Type proxyType = typeBuilder.CreateType();
Type proxyType = typeBuilder.CreateTypeInfo();
// set target method references
foreach (DictionaryEntry entry in targetMethods)

View File

@@ -1,90 +0,0 @@
#region License
/*
* Copyright <20> 2010-2011 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.Generic;
using System.Linq;
using System.Reflection;
using System.Security.Permissions;
using System.Security.Policy;
namespace Spring.Context.Attributes
{
/// <summary>
/// Utilities to provide support for manipulating ReflectionOnly types in the <see cref="AppDomain"/>.
/// </summary>
public static class ReflectionOnlyUtils
{
/// <summary>
/// Load the <see cref="Assembly"/> into the ReflectionsOnly context based on its partial name.
/// </summary>
/// <param name="partialName">The partial name.</param>
/// <returns>The matching <see cref="Assembly"/></returns>
public static Assembly ReflectionOnlyLoadWithPartialName(string partialName)
{
return ReflectionOnlyLoadWithPartialName(partialName, null);
}
private static Assembly ReflectionOnlyLoadWithPartialName(string partialName, Evidence securityEvidence)
{
if (securityEvidence != null)
new SecurityPermission(SecurityPermissionFlag.ControlEvidence).Demand();
AssemblyName fileName = new AssemblyName(partialName);
var assembly = nLoad(fileName, null, securityEvidence, null, null, false, true);
if (assembly != null)
return assembly;
var assemblyRef = EnumerateCache(fileName);
if (assemblyRef != null)
return InternalLoad(assemblyRef, securityEvidence, null, true);
return assembly;
}
private static Assembly nLoad(params object[] args)
{
return (Assembly)typeof(Assembly)
.GetMethod("nLoad", BindingFlags.NonPublic | BindingFlags.Static)
.Invoke(null, args);
}
private static AssemblyName EnumerateCache(params object[] args)
{
return (AssemblyName)typeof(Assembly)
.GetMethod("EnumerateCache", BindingFlags.NonPublic | BindingFlags.Static)
.Invoke(null, args);
}
private static Assembly InternalLoad(params object[] args)
{
// Easiest to query because the StackCrawlMark type is internal
IEnumerable<MethodInfo> methods =
typeof(Assembly).GetMethods(BindingFlags.NonPublic | BindingFlags.Static).Where(
m => m.Name == "InternalLoad" &&
m.GetParameters()[0].ParameterType == typeof (AssemblyName));
return methods.Select(methodInfo => (Assembly) methodInfo.Invoke(null, args)).FirstOrDefault();
}
}
}

View File

@@ -2534,16 +2534,10 @@ namespace Spring.Context.Support
private sealed class ObjectPostProcessorChecker : IObjectPostProcessor, IOrdered
{
private readonly ILog log;
private static readonly ILog log = LogManager.GetLogger<ObjectPostProcessorChecker>();
private int _objectPostProcessorTargetCount;
private IConfigurableListableObjectFactory _objectFactory;
public ObjectPostProcessorChecker()
{
log = LogManager.GetLogger(this.GetType());
}
public void Reset(IConfigurableListableObjectFactory objectFactory, int objectPostProcessorTargetCount)
{
_objectFactory = objectFactory;

File diff suppressed because it is too large Load Diff

View File

@@ -66,7 +66,7 @@ namespace Spring.Core.IO
/// <seealso cref="System.ComponentModel.TypeConverter"/>
public class ResourceConverter : TypeConverter
{
private ILog _log = LogManager.GetLogger(typeof (ResourceConverter));
private static readonly ILog _log = LogManager.GetLogger(typeof (ResourceConverter));
private IResourceLoader _resourceLoader;
#region Constructor (s) / Destructor

View File

@@ -21,7 +21,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Security.Permissions;
using Spring.Context.Support;
using Spring.Core.TypeResolution;
@@ -246,14 +245,19 @@ namespace Spring.Core.IO
lock (syncRoot)
{
SecurityCritical.ExecutePrivileged( new SecurityPermission(SecurityPermissionFlag.Infrastructure), delegate
Action callback = () =>
{
// register generic uri parser for this scheme
if (!UriParser.IsKnownScheme(protocolName))
{
UriParser.Register(new TolerantUriParser(), protocolName, 0);
}
});
};
#if NETSTANDARD
callback();
#else
SecurityCritical.ExecutePrivileged(new System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityPermissionFlag.Infrastructure), callback);
#endif
IDynamicConstructor ctor = GetResourceConstructor(handlerType);
resourceHandlers[protocolName] = ctor;
}

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright <20> 2002-2011 the original author or authors.
*
@@ -16,18 +14,12 @@
* limitations under the License.
*/
#endregion
#region Imports
using System;
using System.Globalization;
using System.Runtime.Serialization;
using System.Security.Permissions;
using Spring.Util;
#endregion
namespace Spring.Core
{
/// <summary>
@@ -37,8 +29,6 @@ namespace Spring.Core
[Serializable]
public class InvalidPropertyException : FatalReflectionException
{
#region Constructor (s) / Destructor
/// <summary>
/// Creates a new instance of the
/// <see cref="InvalidPropertyException"/> class.
@@ -151,14 +141,11 @@ namespace Spring.Core
protected InvalidPropertyException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
offendingObjectType = info.GetValue("ObjectType", typeof (Type)) as Type;
var typeName = info.GetString("ObjectTypeName");
offendingObjectType = typeName != null ? Type.GetType(typeName) : null;
offendingPropertyName = info.GetString("OffendingPropertyName");
}
#endregion
#region Properties
/// <summary>
/// The <see cref="System.Type"/> that is (or rather was) the source of the
/// offending property.
@@ -176,10 +163,6 @@ namespace Spring.Core
get { return offendingPropertyName; }
}
#endregion
#region Methods
/// <summary>
/// Populates a <see cref="System.Runtime.Serialization.SerializationInfo"/> with
/// the data needed to serialize the target object.
@@ -197,17 +180,11 @@ namespace Spring.Core
SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue("ObjectType", ObjectType, typeof (Type));
info.AddValue("ObjectTypeName", ObjectType?.AssemblyQualifiedNameWithoutVersion());
info.AddValue("OffendingPropertyName", OffendingPropertyName);
}
#endregion
#region Fields
private Type offendingObjectType;
private string offendingPropertyName;
#endregion
}
}

View File

@@ -92,14 +92,14 @@ namespace Spring.Core.TypeConversion
/// </param>
/// <param name="value">
/// The value that is to be converted, in "R,G,B", "A,R,G,B", or
/// symbolic color name (<see cref="System.Drawing.KnownColor"/>).
/// symbolic color name (System.Drawing.KnownColor if on .NET Full Framework).
/// </param>
/// <returns>
/// A <see cref="System.Drawing.Color"/> representation of the string value.
/// </returns>
/// <exception cref="System.FormatException">
/// If the input string is not in a supported format, or is not one of the
/// predefined system colors (<see cref="System.Drawing.KnownColor"/>).
/// predefined system colors (System.Drawing.KnownColor if on .NET Full Framework).
/// </exception>
public override object ConvertFrom(
ITypeDescriptorContext context, CultureInfo culture, object value)
@@ -141,6 +141,9 @@ namespace Spring.Core.TypeConversion
private static Color FromName(string name)
{
#if NETSTANDARD
throw new NotSupportedException("FromName is not supported under .NET Core");
#else
try
{
KnownColor color = (KnownColor) Enum.Parse(typeof (KnownColor), name);
@@ -151,6 +154,7 @@ namespace Spring.Core.TypeConversion
throw new FormatException(
"Input string is not a known system color : '" + name + "'.", ex);
}
#endif
}
private static Color GetColorFrom(string alpha, string red, string green, string blue)

View File

@@ -153,8 +153,6 @@ namespace Spring.Core.TypeConversion
return Registry.PerformanceData;
case "HKEY_CURRENT_CONFIG":
return Registry.CurrentConfig;
case "HKEY_DYN_DATA":
return Registry.DynData;
default:
throw new ArgumentException("Invalid root hive name [" + name + "].");
}

View File

@@ -74,7 +74,6 @@ namespace Spring.Expressions
/// Gets the right operand.
/// </summary>
/// <value>The right operand.</value>
[CLSCompliant(false)]
public BaseNode Right
{
get { return (BaseNode) this.getFirstChild().getNextSibling(); }

View File

@@ -20,7 +20,8 @@
using System;
using System.Collections.Generic;
using Spring.Collections.Generic;
using System.Runtime.Serialization;
using Spring.Core;
using Spring.Core.TypeConversion;
using Spring.Objects.Factory.Config;
@@ -35,11 +36,10 @@ namespace Spring.Objects.Factory.Attributes
/// Also supports suggested expression values through a <see cref="ValueAttribute"/> attribute.
/// </summary>
[Serializable]
public class QualifierAnnotationAutowireCandidateResolver : IAutowireCandidateResolver, IObjectFactoryAware
public class QualifierAnnotationAutowireCandidateResolver : IAutowireCandidateResolver, IObjectFactoryAware, ISerializable
{
private IObjectFactory _objectFactory;
private Collections.Generic.ISet<Type> _qualifierTypes = new HashedSet<Type>();
private readonly HashSet<Type> _qualifierTypes = new HashSet<Type>();
private Type _valueAttributeType = typeof(ValueAttribute);
@@ -59,8 +59,8 @@ namespace Spring.Objects.Factory.Attributes
/// </summary>
public QualifierAnnotationAutowireCandidateResolver()
{
_qualifierTypes.Add(typeof(QualifierAttribute));
}
_qualifierTypes.Add(typeof(QualifierAttribute));
}
/// <summary>
/// Create a new QualifierAnnotationAutowireCandidateResolver
@@ -70,36 +70,65 @@ namespace Spring.Objects.Factory.Attributes
public QualifierAnnotationAutowireCandidateResolver(Type qualifierType)
{
AssertUtils.ArgumentNotNull(qualifierType, "'qualifierType' must not be null");
_qualifierTypes.Add(qualifierType);
}
_qualifierTypes.Add(qualifierType);
}
/// <summary>
/// Create a new QualifierAnnotationAutowireCandidateResolver
/// for the given qualifier attribute types.
/// </summary>
/// <param name="qualifierTypes">the qualifier annotations to look for</param>
public QualifierAnnotationAutowireCandidateResolver(Collections.Generic.ISet<Type> qualifierTypes) {
/// <summary>
/// Create a new QualifierAnnotationAutowireCandidateResolver
/// for the given qualifier attribute types.
/// </summary>
/// <param name="qualifierTypes">the qualifier annotations to look for</param>
public QualifierAnnotationAutowireCandidateResolver(Collections.Generic.ISet<Type> qualifierTypes)
{
AssertUtils.ArgumentNotNull(qualifierTypes, "'qualifierTypes' must not be null");
foreach(var type in qualifierTypes)
foreach (var type in qualifierTypes)
{
if (!_qualifierTypes.Contains(type))
_qualifierTypes.Add(type);
}
}
}
protected QualifierAnnotationAutowireCandidateResolver(SerializationInfo info, StreamingContext context)
{
_objectFactory = (IObjectFactory) info.GetValue("objectFactory", typeof(IObjectFactory));
var type = info.GetString("valueAttributeType");
_valueAttributeType = type != null ? Type.GetType(type) : null;
/// <summary>
/// Register the given type to be used as a qualifier when autowiring.
/// <p>This identifies qualifier annotations for direct use (on fields,
/// method parameters and constructor parameters) as well as meta
/// annotations that in turn identify actual qualifier annotations.</p>
/// <p>This implementation only supports annotations as qualifier types.
/// The default is Spring's <see cref="QualifierAttribute"/> attribute which serves
/// as a qualifier for direct use and also as a meta attribute.</p>
/// </summary>
/// <param name="qualifierType">the attribute type to register</param>
public void AddQualifierType(Type qualifierType) {
_qualifierTypes.Add(qualifierType);
}
_qualifierTypes = new HashSet<Type>();
var typeNames = (List<string>) info.GetValue("qualifierTypeNames", typeof(List<string>));
foreach (var typeName in typeNames)
{
_qualifierTypes.Add(Type.GetType(typeName));
}
}
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("objectFactory", _objectFactory);
info.AddValue("valueAttributeType", _valueAttributeType?.AssemblyQualifiedName);
var qualifierTypeNames = new List<string>();
foreach (var qualifierType in _qualifierTypes)
{
qualifierTypeNames.Add(qualifierType?.AssemblyQualifiedName);
}
info.AddValue("qualifierTypeNames", qualifierTypeNames);
}
/// <summary>
/// Register the given type to be used as a qualifier when autowiring.
/// <p>This identifies qualifier annotations for direct use (on fields,
/// method parameters and constructor parameters) as well as meta
/// annotations that in turn identify actual qualifier annotations.</p>
/// <p>This implementation only supports annotations as qualifier types.
/// The default is Spring's <see cref="QualifierAttribute"/> attribute which serves
/// as a qualifier for direct use and also as a meta attribute.</p>
/// </summary>
/// <param name="qualifierType">the attribute type to register</param>
public void AddQualifierType(Type qualifierType)
{
_qualifierTypes.Add(qualifierType);
}
/// <summary>
/// Determine whether the provided object definition is an autowire candidate.
@@ -114,28 +143,33 @@ namespace Spring.Objects.Factory.Attributes
/// </summary>
public bool IsAutowireCandidate(ObjectDefinitionHolder odHolder, DependencyDescriptor descriptor)
{
if (!odHolder.ObjectDefinition.IsAutowireCandidate)
if (!odHolder.ObjectDefinition.IsAutowireCandidate)
{
// if explicitly false, do not proceed with qualifier check
return false;
}
if (descriptor == null)
{
// if explicitly false, do not proceed with qualifier check
return false;
}
if (descriptor == null) {
// no qualification necessaryodHolder
return true;
}
bool match = CheckQualifiers(odHolder, descriptor.Attributes);
if (match)
return true;
}
bool match = CheckQualifiers(odHolder, descriptor.Attributes);
if (match)
{
MethodParameter methodParam = descriptor.MethodParameter;
if (methodParam != null)
MethodParameter methodParam = descriptor.MethodParameter;
if (methodParam != null)
{
var method = methodParam.MethodInfo;
if (method == null || method.ReturnType == typeof(void)) {
match = CheckQualifiers(odHolder, methodParam.MethodAttributes);
}
}
}
return match;
var method = methodParam.MethodInfo;
if (method == null || method.ReturnType == typeof(void))
{
match = CheckQualifiers(odHolder, methodParam.MethodAttributes);
}
}
}
return match;
}
/// <summary>
@@ -143,10 +177,12 @@ namespace Spring.Objects.Factory.Attributes
/// </summary>
protected bool CheckQualifiers(ObjectDefinitionHolder odHolder, Attribute[] annotationsToSearch)
{
if (annotationsToSearch == null || annotationsToSearch.Length == 0) {
return true;
}
foreach (var attribute in annotationsToSearch)
if (annotationsToSearch == null || annotationsToSearch.Length == 0)
{
return true;
}
foreach (var attribute in annotationsToSearch)
{
if (IsQualifier(attribute.GetType()))
{
@@ -154,23 +190,25 @@ namespace Spring.Objects.Factory.Attributes
{
return false;
}
}
}
return true;
}
}
}
/// <summary>
/// Checks whether the given attribute type is a recognized qualifier type.
/// </summary>
protected bool IsQualifier(Type attributeType)
return true;
}
/// <summary>
/// Checks whether the given attribute type is a recognized qualifier type.
/// </summary>
protected bool IsQualifier(Type attributeType)
{
foreach (Type qualifierType in _qualifierTypes)
foreach (Type qualifierType in _qualifierTypes)
{
if (IsSubTypeOf(attributeType, qualifierType))
return true;
}
return false;
}
return true;
}
return false;
}
private bool IsSubTypeOf(Type actual, Type requested)
{
@@ -190,78 +228,96 @@ namespace Spring.Objects.Factory.Attributes
/// </summary>
protected bool CheckQualifier(ObjectDefinitionHolder odHolder, Attribute attribute)
{
Type type = attribute.GetType();
RootObjectDefinition od = (RootObjectDefinition) odHolder.ObjectDefinition;
AutowireCandidateQualifier qualifier = od.GetQualifier(type.FullName);
if (qualifier == null) {
qualifier = od.GetQualifier(type.Name);
}
if (qualifier == null) {
Attribute targetAttribute = null;
// TODO: Get the resolved factory method
//if (od.GetResolvedFactoryMethod() != null) {
// targetAttribute = Attribute.GetCustomAttribute(od.GetResolvedFactoryMethod(), type);
//}
if (targetAttribute == null) {
// look for matching attribute on the target class
if (_objectFactory != null) {
Type objectType = od.ObjectType;
if (objectType != null)
{
targetAttribute = Attribute.GetCustomAttribute(objectType, type);
}
}
if (targetAttribute == null && od.ObjectType != null) {
targetAttribute = Attribute.GetCustomAttribute(od.ObjectType, type);
}
}
if (targetAttribute != null && targetAttribute.Equals(attribute)) {
return true;
}
}
IDictionary<string, object> attributes = AttributeUtils.GetAttributeProperties(attribute);
if (attributes.Count == 0 && qualifier == null) {
// if no attributes, the qualifier must be present
return false;
}
foreach(var entry in attributes)
Type type = attribute.GetType();
RootObjectDefinition od = (RootObjectDefinition) odHolder.ObjectDefinition;
AutowireCandidateQualifier qualifier = od.GetQualifier(type.FullName);
if (qualifier == null)
{
string propertyName = entry.Key;
qualifier = od.GetQualifier(type.Name);
}
if (qualifier == null)
{
Attribute targetAttribute = null;
// TODO: Get the resolved factory method
//if (od.GetResolvedFactoryMethod() != null) {
// targetAttribute = Attribute.GetCustomAttribute(od.GetResolvedFactoryMethod(), type);
//}
if (targetAttribute == null)
{
// look for matching attribute on the target class
if (_objectFactory != null)
{
Type objectType = od.ObjectType;
if (objectType != null)
{
targetAttribute = Attribute.GetCustomAttribute(objectType, type);
}
}
if (targetAttribute == null && od.ObjectType != null)
{
targetAttribute = Attribute.GetCustomAttribute(od.ObjectType, type);
}
}
if (targetAttribute != null && targetAttribute.Equals(attribute))
{
return true;
}
}
IDictionary<string, object> attributes = AttributeUtils.GetAttributeProperties(attribute);
if (attributes.Count == 0 && qualifier == null)
{
// if no attributes, the qualifier must be present
return false;
}
foreach (var entry in attributes)
{
string propertyName = entry.Key;
object expectedValue = entry.Value;
object actualValue = null;
// check qualifier first
if (qualifier != null)
object actualValue = null;
// check qualifier first
if (qualifier != null)
{
actualValue = qualifier.GetAttribute(propertyName);
}
if (actualValue == null)
actualValue = qualifier.GetAttribute(propertyName);
}
if (actualValue == null)
{
// fall back on bean definition attribute
actualValue = od.GetAttribute(propertyName);
}
if (actualValue == null && propertyName.Equals(AutowireCandidateQualifier.VALUE_KEY) &&
expectedValue is string && odHolder.MatchesName((string) expectedValue))
// fall back on bean definition attribute
actualValue = od.GetAttribute(propertyName);
}
if (actualValue == null && propertyName.Equals(AutowireCandidateQualifier.VALUE_KEY) &&
expectedValue is string && odHolder.MatchesName((string) expectedValue))
{
// fall back on bean name (or alias) match
continue;
}
if (actualValue == null && qualifier != null)
// fall back on bean name (or alias) match
continue;
}
if (actualValue == null && qualifier != null)
{
// fall back on default, but only if the qualifier is present
// fall back on default, but only if the qualifier is present
actualValue = AttributeUtils.GetDefaultValue(attribute, propertyName);
}
if (actualValue != null)
}
if (actualValue != null)
{
actualValue = TypeConversionUtils.ConvertValueIfNecessary(expectedValue.GetType(), actualValue, null);
}
if (!expectedValue.Equals(actualValue)) {
return false;
}
}
return true;
}
}
if (!expectedValue.Equals(actualValue))
{
return false;
}
}
return true;
}
/// <summary>
/// Determine whether the given dependency carries a value attribute.
/// </summary>
@@ -276,25 +332,30 @@ namespace Spring.Objects.Factory.Attributes
value = FindValue(methodParam.MethodAttributes);
}
}
return value;
}
/// <summary>
/// Determine a suggested value from any of the given candidate annotations.
/// </summary>
protected Object FindValue(Attribute[] annotationsToSearch) {
foreach(var attribute in annotationsToSearch) {
if (_valueAttributeType == attribute.GetType())
{
Object value = ((ValueAttribute)attribute).Expression;
if (value == null)
protected Object FindValue(Attribute[] annotationsToSearch)
{
foreach (var attribute in annotationsToSearch)
{
if (_valueAttributeType == attribute.GetType())
{
Object value = ((ValueAttribute) attribute).Expression;
if (value == null)
{
throw new InvalidOperationException("Value attribute must have a value attribute");
}
return value;
}
}
return null;
}
throw new InvalidOperationException("Value attribute must have a value attribute");
}
return value;
}
}
return null;
}
}
}
}

View File

@@ -353,13 +353,27 @@ namespace Spring.Objects.Factory.Config
if (xmlConfig == null)
{
// none specified, use machine inherited
XmlDocument machineConfig = new XmlDocument();
machineConfig.Load(RuntimeEnvironment.SystemConfigurationFile);
xmlConfig = machineConfig.SelectSingleNode(sectionHandlerPath);
if (xmlConfig == null)
try
{
// TOOD: better throw a sensible exception in case of a missing handler configuration?
handlerType = defaultConfigurationSectionHandlerType;
XmlDocument machineConfig = new XmlDocument();
machineConfig.Load(RuntimeEnvironment.SystemConfigurationFile);
xmlConfig = machineConfig.SelectSingleNode(sectionHandlerPath);
if (xmlConfig == null)
{
// TOOD: better throw a sensible exception in case of a missing handler configuration?
handlerType = defaultConfigurationSectionHandlerType;
}
}
catch (PlatformNotSupportedException)
{
if (configSectionName == "connectionStrings")
{
handlerType = typeof(ConnectionStringsSectionHandler);
}
else
{
handlerType = typeof(NameValueSectionHandler);
}
}
}
@@ -376,6 +390,23 @@ namespace Spring.Objects.Factory.Config
return handlerType;
}
private class ConnectionStringsSectionHandler : IConfigurationSectionHandler
{
public object Create(object parent, object configContext, XmlNode section)
{
var data = new ConnectionStringsSection();
foreach (XmlNode node in section.ChildNodes)
{
var settings = new ConnectionStringSettings(
node.Attributes["name"].Value,
node.Attributes["connectionString"]?.Value,
node.Attributes["providerName"]?.Value);
data.ConnectionStrings.Add(settings);
}
return data;
}
}
private delegate void DeserializeSectionMethod(ConfigurationSection section, XmlReader reader);
private static DeserializeSectionMethod deserialized = (DeserializeSectionMethod)Delegate.CreateDelegate(typeof(DeserializeSectionMethod),

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright <20> 2002-2011 the original author or authors.
*
@@ -16,10 +14,6 @@
* limitations under the License.
*/
#endregion
#region Imports
using System;
using System.Collections;
using System.Collections.Generic;
@@ -27,8 +21,6 @@ using System.Globalization;
using Spring.Collections;
using Spring.Util;
#endregion
namespace Spring.Objects.Factory.Config
{
/// <summary>
@@ -54,9 +46,7 @@ namespace Spring.Objects.Factory.Config
/// </summary>
public const int NoIndex = -1289; // yes, the number really is wholly arbitrary...
#region Constructor (s) / Destructor
/// <summary>
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Objects.Factory.Config.ConstructorArgumentValues"/>
/// class.
@@ -79,20 +69,12 @@ namespace Spring.Objects.Factory.Config
AddAll(other);
}
#endregion
#region Fields
private CultureInfo enUSCultureInfo = new CultureInfo("en-US", false);
private static readonly CultureInfo enUSCultureInfo = new CultureInfo("en-US", false);
private IDictionary<int, ValueHolder> _indexedArgumentValues = new Dictionary<int, ValueHolder>();
private List<ValueHolder> _genericArgumentValues = new List<ValueHolder>();
private IDictionary<string, object> _namedArgumentValues = new Dictionary<string, object>();
#endregion
#region Properties
/// <summary>
/// <summary>
/// Return the map of indexed argument values.
/// </summary>
/// <returns>
@@ -161,11 +143,7 @@ namespace Spring.Objects.Factory.Config
}
}
#endregion
#region Methods
/// <summary>
/// <summary>
/// Copy all given argument values into this object.
/// </summary>
/// <param name="other">
@@ -585,11 +563,7 @@ namespace Spring.Objects.Factory.Config
return argument != null ? argument.ToLower(enUSCultureInfo) : argument;
}
#endregion
#region Inner Class : ValueHolder
/// <summary>
/// <summary>
/// Holder for a constructor argument value, with an optional
/// <see cref="System.Type"/> attribute indicating the target
/// <see cref="System.Type"/> of the actual constructor argument.
@@ -597,9 +571,7 @@ namespace Spring.Objects.Factory.Config
[Serializable]
public class ValueHolder
{
#region Constructor (s) / Destructor
/// <summary>
/// <summary>
/// Creates a new instance of the ValueHolder class.
/// </summary>
/// <param name="value">
@@ -628,11 +600,7 @@ namespace Spring.Objects.Factory.Config
this.typeName = typeName;
}
#endregion
#region Methods
public ValueHolder Copy()
public ValueHolder Copy()
{
ValueHolder copy = new ValueHolder(this._ctorValue, this.typeName);
return copy;
@@ -652,11 +620,7 @@ namespace Spring.Objects.Factory.Config
"'{0}' [{1}]", Value, Type);
}
#endregion
#region Properties
/// <summary>
/// <summary>
/// Gets and sets the value for the constructor argument.
/// </summary>
/// <remarks>
@@ -680,16 +644,8 @@ namespace Spring.Objects.Factory.Config
get { return typeName; }
}
#endregion
#region Fields
private object _ctorValue;
private object _ctorValue;
private string typeName;
#endregion
}
#endregion
}
}

View File

@@ -108,7 +108,7 @@ namespace Spring.Objects.Factory.Config
[Serializable]
public class PropertyOverrideConfigurer : PropertyResourceConfigurer
{
private ILog _logger = LogManager.GetLogger(typeof (PropertyOverrideConfigurer));
private static readonly ILog _logger = LogManager.GetLogger(typeof (PropertyOverrideConfigurer));
/// <summary>
/// Apply the given properties to the supplied

View File

@@ -21,6 +21,8 @@
#region Imports
using System;
using System.Runtime.Serialization;
using Spring.Util;
using Spring.Core.TypeResolution;
@@ -48,13 +50,11 @@ namespace Spring.Objects.Factory.Config
/// <author>Rick Evans (.NET)</author>
/// <author>Bruno Baia (.NET)</author>
[Serializable]
public class TypedStringValue
public class TypedStringValue : ISerializable
{
private string theValue;
private object targetType;
#region Constructor (s) / Destructor
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Objects.Factory.Config.TypedStringValue"/>
@@ -115,7 +115,12 @@ namespace Spring.Objects.Factory.Config
TargetTypeName = targetTypeName;
}
#endregion
protected TypedStringValue(SerializationInfo info, StreamingContext context)
{
var type = info.GetString("TargetTypeName");
targetType = type != null ? Type.GetType(type) : null;
theValue = info.GetString("Value");
}
/// <summary>
/// The value that is to be converted.
@@ -209,5 +214,20 @@ namespace Spring.Objects.Factory.Config
this.targetType = resolvedType;
return resolvedType;
}
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
string targetTypeName = null;
if (targetType is string x)
{
targetTypeName = x;
}
else if (targetType is Type t)
{
targetTypeName = t.AssemblyQualifiedNameWithoutVersion();
}
info.AddValue("TargetTypeName", targetTypeName);
info.AddValue("Value", theValue);
}
}
}

View File

@@ -243,7 +243,6 @@ namespace Spring.Objects.Factory.Config
/// A <see cref="ulong"/> that contains the value of the specified variable
/// or <paramref name="defaultValue"/>, if <see cref="IVariableSource.ResolveVariable"/> returns <c>null</c>.
/// </returns>
[CLSCompliant(false)]
public ulong GetUInt64(string name, ulong defaultValue)
{
return GetUInt64(name, defaultValue, true);
@@ -262,7 +261,6 @@ namespace Spring.Objects.Factory.Config
/// A <see cref="ulong"/> that contains the value of the specified variable
/// or <paramref name="defaultValue"/>, if <see cref="IVariableSource.ResolveVariable"/> cannot be parsed.
/// </returns>
[CLSCompliant(false)]
public ulong GetUInt64(string name, ulong defaultValue, bool throwOnInvalidValue)
{
try
@@ -339,7 +337,6 @@ namespace Spring.Objects.Factory.Config
/// A <see cref="uint"/> that contains the value of the specified variable
/// or <paramref name="defaultValue"/>, if <see cref="IVariableSource.ResolveVariable"/> returns <c>null</c>.
/// </returns>
[CLSCompliant(false)]
public uint GetUInt32(string name, uint defaultValue)
{
return GetUInt32(name, defaultValue, true);
@@ -358,7 +355,6 @@ namespace Spring.Objects.Factory.Config
/// A <see cref="uint"/> that contains the value of the specified variable
/// or <paramref name="defaultValue"/>, if <see cref="IVariableSource.ResolveVariable"/> cannot be parsed.
/// </returns>
[CLSCompliant(false)]
public uint GetUInt32(string name, uint defaultValue, bool throwOnInvalidValue)
{
try
@@ -435,7 +431,6 @@ namespace Spring.Objects.Factory.Config
/// A <see cref="short"/> that contains the value of the specified variable
/// or <paramref name="defaultValue"/>, if <see cref="IVariableSource.ResolveVariable"/> returns <c>null</c>.
/// </returns>
[CLSCompliant(false)]
public ushort GetUInt16(string name, ushort defaultValue)
{
return GetUInt16(name, defaultValue, true);
@@ -454,7 +449,6 @@ namespace Spring.Objects.Factory.Config
/// A <see cref="short"/> that contains the value of the specified variable
/// or <paramref name="defaultValue"/>, if <see cref="IVariableSource.ResolveVariable"/> cannot be parsed.
/// </returns>
[CLSCompliant(false)]
public ushort GetUInt16(string name, ushort defaultValue, bool throwOnInvalidValue)
{
try

View File

@@ -148,7 +148,8 @@ namespace Spring.Objects.Factory
: base(info, context)
{
_objectName = info.GetString("ObjectName");
_objectType = info.GetValue("ObjectType", typeof (Type)) as Type;
var typeName = info.GetString("ObjectTypeName");
_objectType = typeName != null ? Type.GetType(typeName) : null;
}
#endregion
@@ -173,7 +174,7 @@ namespace Spring.Objects.Factory
{
base.GetObjectData(info, context);
info.AddValue("ObjectName", ObjectName);
info.AddValue("ObjectType", ObjectType);
info.AddValue("ObjectTypeName", ObjectType?.AssemblyQualifiedNameWithoutVersion());
}
#endregion

View File

@@ -24,7 +24,7 @@ namespace Spring.Objects.Factory.Parsing
{
public class FailFastProblemReporter : IProblemReporter
{
private ILog _logger = LogManager.GetLogger(typeof(FailFastProblemReporter));
private static readonly ILog _logger = LogManager.GetLogger(typeof(FailFastProblemReporter));
public ILog Logger
{

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright <20> 2002-2011 the original author or authors.
*
@@ -16,15 +14,12 @@
* limitations under the License.
*/
#endregion
#region Imports
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using System.Runtime.Serialization;
using Common.Logging;
@@ -33,8 +28,6 @@ using Spring.Core.TypeResolution;
using Spring.Objects.Factory.Config;
using Spring.Util;
#endregion
namespace Spring.Objects.Factory.Support
{
/// <summary>
@@ -62,8 +55,6 @@ namespace Spring.Objects.Factory.Support
[Serializable]
public abstract class AbstractAutowireCapableObjectFactory : AbstractObjectFactory, IAutowireCapableObjectFactory
{
#region Constants
/// <summary>
/// The <see cref="System.Reflection.BindingFlags"/> used during the invocation and
/// searching for of methods.
@@ -71,15 +62,6 @@ namespace Spring.Objects.Factory.Support
protected const BindingFlags MethodResolutionFlags =
BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Instance | BindingFlags.IgnoreCase;
#endregion
/// <summary>
/// The <see cref="Common.Logging.ILog"/> instance for this class.
/// </summary>
private readonly ILog log;
#region Constructor (s) / Destructor
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory"/>
@@ -110,16 +92,10 @@ namespace Spring.Objects.Factory.Support
protected AbstractAutowireCapableObjectFactory(bool caseSensitive, IObjectFactory parentFactory)
: base(caseSensitive, parentFactory)
{
log = LogManager.GetLogger(this.GetType());
this.IgnoreDependencyInterface(typeof(IObjectFactoryAware));
this.IgnoreDependencyInterface(typeof(IObjectNameAware));
}
#endregion
#region Properties
/// <summary>
/// The <see cref="Spring.Objects.Factory.Support.IInstantiationStrategy"/>
/// implementation to be used to instantiate managed objects.
@@ -130,10 +106,6 @@ namespace Spring.Objects.Factory.Support
set { instantiationStrategy = value; }
}
#endregion
#region Methods
/// <summary>
/// Predict the eventual object type (of the processed object instance) for the
/// specified object.
@@ -302,15 +274,11 @@ namespace Spring.Objects.Factory.Support
/// </exception>
protected object ApplyObjectPostProcessorsBeforeInstantiation(Type objectType, string objectName)
{
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(string.Format("Invoking IInstantiationAwareObjectPostProcessors before " + "the instantiation of '{0}'.", objectName));
}
#endregion
foreach (IObjectPostProcessor processor in ObjectPostProcessors)
{
IInstantiationAwareObjectPostProcessor inProc = processor as IInstantiationAwareObjectPostProcessor;
@@ -675,8 +643,6 @@ namespace Spring.Objects.Factory.Support
object o = GetObject(propertyName);
properties.Add(propertyName, o);
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(
@@ -684,21 +650,15 @@ namespace Spring.Objects.Factory.Support
"Added autowiring by name from object name '{0}' via " + "property '{1}' to object named '{1}'.", name,
propertyName));
}
#endregion
}
else
{
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(
string.Format(CultureInfo.InvariantCulture,
"Not autowiring property '{0}' of object '{1}' by name: " + "no matching object found.", propertyName, name));
}
#endregion
}
}
}
@@ -739,8 +699,6 @@ namespace Spring.Objects.Factory.Support
{
properties.Add(propertyName, ObjectUtils.EnumerateFirstElement(matchingObjects.Values));
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(
@@ -748,8 +706,6 @@ namespace Spring.Objects.Factory.Support
"Autowiring by type from object name '{0}' via property " + "'{1}' to object named '{2}'.", name,
propertyName, ObjectUtils.EnumerateFirstElement(matchingObjects.Keys)));
}
#endregion
}
else if (matchingObjects != null && matchingObjects.Count > 1)
{
@@ -762,16 +718,12 @@ namespace Spring.Objects.Factory.Support
}
else
{
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(
string.Format(CultureInfo.InvariantCulture, "Not autowiring property '{0}' of object '{1}': no matching object found.",
propertyName, name));
}
#endregion
}
}
}
@@ -878,15 +830,11 @@ namespace Spring.Objects.Factory.Support
}
}
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(string.Format(CultureInfo.InvariantCulture, "Creating instance of Object '{0}' with merged definition [{1}].", name, definition));
}
#endregion
// Make sure object type is actually resolved at this point.
ResolveObjectType(definition, name);
@@ -1307,21 +1255,15 @@ namespace Spring.Objects.Factory.Support
{
if (ObjectUtils.IsAssignableAndNotTransparentProxy(typeof(IInitializingObject), target))
{
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(string.Format(CultureInfo.InvariantCulture, "Calling AfterPropertiesSet() on object with name '{0}'.", name));
}
#endregion
((IInitializingObject)target).AfterPropertiesSet();
}
if (StringUtils.HasText(definition.InitMethodName))
{
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(
@@ -1329,8 +1271,6 @@ namespace Spring.Objects.Factory.Support
definition.InitMethodName, name));
}
#endregion
try
{
MethodInfo targetMethod = target.GetType().GetMethod(definition.InitMethodName, MethodResolutionFlags, null, Type.EmptyTypes, null);
@@ -1386,11 +1326,7 @@ namespace Spring.Objects.Factory.Support
}
if (targetMethod == null)
{
#region Instrumentation
log.Error("Couldn't find a method named '" + destroyMethodName + "' on object with name '" + name + "'");
#endregion
}
else
{
@@ -1401,11 +1337,7 @@ namespace Spring.Objects.Factory.Support
}
catch (TargetInvocationException ex)
{
#region Instrumentation
log.Error("Couldn't invoke destroy method '" + destroyMethodName + "' of object with name '" + name + "'", ex.GetBaseException());
#endregion
}
catch (Exception ex)
{
@@ -1695,8 +1627,6 @@ namespace Spring.Objects.Factory.Support
/// <returns>A reference to another object in the factory.</returns>
protected object ResolveReference(IConfigurableObjectDefinition definition, string name, string argumentName, RuntimeObjectReference reference)
{
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(
@@ -1704,8 +1634,6 @@ namespace Spring.Objects.Factory.Support
argumentName, name, reference.ObjectName));
}
#endregion
try
{
if (reference.IsToParent)
@@ -1826,36 +1754,26 @@ namespace Spring.Objects.Factory.Support
{
object instance = wrapper.WrappedInstance;
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(string.Format("Configuring object using definition '{1}'", instance, name));
}
#endregion
PopulateObject(name, definition, wrapper);
WireEvents(name, definition, wrapper);
if (ObjectUtils.IsAssignableAndNotTransparentProxy(typeof(IObjectNameAware), instance))
{
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(string.Format(CultureInfo.InvariantCulture, "Setting the name property on the IObjectNameAware object '{0}'.", name));
}
#endregion
((IObjectNameAware)instance).ObjectName = name;
}
if (ObjectUtils.IsAssignableAndNotTransparentProxy(typeof(IObjectFactoryAware), instance))
{
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(
@@ -1863,8 +1781,6 @@ namespace Spring.Objects.Factory.Support
name));
}
#endregion
((IObjectFactoryAware)instance).ObjectFactory = this;
}
@@ -1889,10 +1805,6 @@ namespace Spring.Objects.Factory.Support
return ApplyObjectPostProcessorsAfterInitialization(instance, objectName);
}
#endregion
#region IAutowireCapableObjectFactory Members
/// <summary>
/// Create a new object instance of the given class with the specified
/// autowire strategy.
@@ -1980,15 +1892,11 @@ namespace Spring.Objects.Factory.Support
/// <seealso cref="Spring.Objects.Factory.Config.IObjectPostProcessor.PostProcessBeforeInitialization"/>
public virtual object ApplyObjectPostProcessorsBeforeInitialization(object instance, string name)
{
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug("Invoking IObjectPostProcessors before initialization of object '" + name + "'");
}
#endregion
object result = instance;
foreach (IObjectPostProcessor objectProcessor in ObjectPostProcessors)
{
@@ -2025,15 +1933,11 @@ namespace Spring.Objects.Factory.Support
/// <seealso cref="Spring.Objects.Factory.Config.IObjectPostProcessor.PostProcessAfterInitialization"/>
public virtual object ApplyObjectPostProcessorsAfterInitialization(object instance, string name)
{
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug("Invoking IObjectPostProcessors after initialization of object '" + name + "'");
}
#endregion
object result = instance;
foreach (IObjectPostProcessor objectProcessor in ObjectPostProcessors)
{
@@ -2063,10 +1967,6 @@ namespace Spring.Objects.Factory.Support
public abstract object ResolveDependency(DependencyDescriptor descriptor, string objectName,
IList autowiredObjectNames);
#endregion
#region Fields
private IInstantiationStrategy instantiationStrategy = new MethodInjectingInstantiationStrategy();
/// <summary>
@@ -2080,8 +1980,6 @@ namespace Spring.Objects.Factory.Support
/// interfaces are ignored.
/// </summary>
private ISet ignoredDependencyInterfaces = new HybridSet();
#endregion
}
internal class UnsatisfiedDependencyExceptionData

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright <20> 2002-2011 the original author or authors.
*
@@ -16,23 +14,18 @@
* limitations under the License.
*/
#endregion
#region Imports
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text;
using Spring.Core.TypeResolution;
using Spring.Objects.Factory.Config;
using Spring.Util;
using Spring.Collections.Generic;
#endregion
namespace Spring.Objects.Factory.Support
{
/// <summary>
@@ -45,13 +38,11 @@ namespace Spring.Objects.Factory.Support
/// <author>Juergen Hoeller</author>
/// <author>Rick Evans (.NET)</author>
[Serializable]
public abstract class AbstractObjectDefinition : ObjectMetadataAttributeAccessor, IConfigurableObjectDefinition
public abstract class AbstractObjectDefinition : ObjectMetadataAttributeAccessor, IConfigurableObjectDefinition, ISerializable
{
private static readonly string SCOPE_SINGLETON = "singleton";
private static readonly string SCOPE_PROTOTYPE = "prototype";
#region Constructor (s) / Destructor
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Objects.Factory.Support.AbstractObjectDefinition"/>
@@ -145,10 +136,6 @@ namespace Spring.Objects.Factory.Support
ResourceDescription = other.ResourceDescription;
}
#endregion
#region Properties
/// <summary>
/// The name of the parent definition of this object definition, if any.
/// </summary>
@@ -679,10 +666,6 @@ namespace Spring.Objects.Factory.Support
}
}
#endregion
#region Methods
/// <summary>
/// Resolves the type of the object, resolving it from a specified
/// object type name if necessary.
@@ -860,10 +843,6 @@ namespace Spring.Objects.Factory.Support
return buffer.ToString();
}
#endregion
#region Fields
private ConstructorArgumentValues constructorArgumentValues = new ConstructorArgumentValues();
private MutablePropertyValues propertyValues = new MutablePropertyValues();
private EventValues eventHandlerValues = new EventValues();
@@ -880,17 +859,76 @@ namespace Spring.Objects.Factory.Support
private DependencyCheckingMode dependencyCheck = DependencyCheckingMode.None;
private IList<string> dependsOn;
private bool autowireCandidate = true;
private bool primary;
private readonly IDictionary<string, AutowireCandidateQualifier> qualifiers =
new Dictionary<string, AutowireCandidateQualifier>();
private readonly IDictionary<string, AutowireCandidateQualifier> qualifiers = new Dictionary<string, AutowireCandidateQualifier>();
private string initMethodName = null;
private string destroyMethodName = null;
private string factoryMethodName = null;
private string factoryObjectName = null;
#endregion
protected AbstractObjectDefinition(SerializationInfo info, StreamingContext context)
{
constructorArgumentValues = (ConstructorArgumentValues) info.GetValue("constructorArgumentValues", typeof(ConstructorArgumentValues));
propertyValues = (MutablePropertyValues) info.GetValue("propertyValues", typeof(MutablePropertyValues));
eventHandlerValues= (EventValues) info.GetValue("eventHandlerValues", typeof(EventValues));
methodOverrides= (MethodOverrides) info.GetValue("methodOverrides", typeof(MethodOverrides));
resourceDescription = info.GetString("resourceDescription");
isSingleton = info.GetBoolean("isSingleton");
isPrototype = info.GetBoolean("isPrototype");
isLazyInit = info.GetBoolean("isLazyInit");
isAbstract = info.GetBoolean("isAbstract");
scope= info.GetString("scope");
role = (ObjectRole) info.GetValue("role", typeof(ObjectRole));
var objectTypeName = info.GetString("objectTypeName");
objectType = objectTypeName != null ? Type.GetType(objectTypeName) : null;
autowireMode = (AutoWiringMode) info.GetValue("autowireMode", typeof(AutoWiringMode));
dependencyCheck= (DependencyCheckingMode) info.GetValue("dependencyCheck", typeof(DependencyCheckingMode));
dependsOn = (IList<string>) info.GetValue("dependsOn", typeof(IList<string>));
autowireCandidate = info.GetBoolean("autowireCandidate");
primary = info.GetBoolean("primary");
qualifiers = (IDictionary<string, AutowireCandidateQualifier>) info.GetValue("qualifiers", typeof(IDictionary<string, AutowireCandidateQualifier>));
initMethodName = info.GetString("initMethodName");
destroyMethodName = info.GetString("destroyMethodName");
factoryMethodName = info.GetString("factoryMethodName" );
factoryObjectName= info.GetString("factoryObjectName");
}
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("constructorArgumentValues", constructorArgumentValues);
info.AddValue("propertyValues", propertyValues);
info.AddValue("eventHandlerValues", eventHandlerValues);
info.AddValue("methodOverrides", methodOverrides);
info.AddValue("resourceDescription", resourceDescription);
info.AddValue("isSingleton", isSingleton);
info.AddValue("isPrototype", isPrototype);
info.AddValue("isLazyInit", isLazyInit);
info.AddValue("isAbstract", isAbstract);
info.AddValue("scope", scope);
info.AddValue("role", role);
string objectTypeName = null;
if (objectType is string s)
{
objectTypeName = s;
}
else if (objectType is Type t)
{
objectTypeName = t.AssemblyQualifiedName;
}
info.AddValue("objectTypeName", objectTypeName);
info.AddValue("autowireMode", autowireMode);
info.AddValue("dependencyCheck", dependencyCheck);
info.AddValue("dependsOn", dependsOn);
info.AddValue("autowireCandidate", autowireCandidate);
info.AddValue("primary", primary);
info.AddValue("qualifiers", qualifiers);
info.AddValue("initMethodName", initMethodName);
info.AddValue("destroyMethodName", destroyMethodName);
info.AddValue("factoryMethodName", factoryMethodName);
info.AddValue("factoryObjectName", factoryObjectName);
}
}
}

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright <20> 2002-2011 the original author or authors.
*
@@ -16,10 +14,6 @@
* limitations under the License.
*/
#endregion
#region Imports
using System;
using System.Collections;
using System.Collections.Generic;
@@ -37,8 +31,7 @@ using Spring.Threading;
using Spring.Util;
using System.Threading;
using System.Linq;
#endregion
using System.Runtime.Serialization;
namespace Spring.Objects.Factory.Support
{
@@ -78,15 +71,11 @@ namespace Spring.Objects.Factory.Support
}
}
#region Implementation of IDisposable
public void Dispose()
{
LogicalThreadContext.FreeNamedDataSlot(this.name);
}
#endregion
private ISet CreateSet()
{
return new HashedSet();
@@ -138,7 +127,7 @@ namespace Spring.Objects.Factory.Support
/// <summary>
/// The <see cref="Common.Logging.ILog"/> instance for this class.
/// </summary>
private readonly ILog log;
[NonSerialized] protected ILog log;
/// <summary>
/// Cache of singleton objects created by <see cref="IFactoryObject"/>s: FactoryObject name -> product
@@ -166,8 +155,6 @@ namespace Spring.Objects.Factory.Support
/// </summary>
private Spring.Collections.Generic.ISet<string> alreadyCreated = new SynchronizedSet<string>(new HashedSet<string>());
#region Constructor (s) / Destructor
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Objects.Factory.Support.AbstractObjectFactory"/> class.
@@ -211,6 +198,12 @@ namespace Spring.Objects.Factory.Support
this.singletonsInCreation = new OrderedDictionary(comparer);
this.prototypesInCreation = new LogicalThreadContextSetVariable();
}
[OnDeserializing]
private void OnDeserializing(StreamingContext c)
{
log = LogManager.GetLogger(GetType());
}
/// <summary>
/// Creates a new instance of the
@@ -234,10 +227,6 @@ namespace Spring.Objects.Factory.Support
ParentObjectFactory = parentFactory;
}
#endregion
#region Properties
/// <summary>
/// Returns, whether this factory treats object names case sensitive or not.
/// </summary>
@@ -286,10 +275,6 @@ namespace Spring.Objects.Factory.Support
get { return hasDestructionAwareBeanPostProcessors; }
}
#endregion
#region Methods
/// <summary>
/// Return an instance (possibly shared or independent) of the given object name.
/// </summary>
@@ -943,23 +928,17 @@ namespace Spring.Objects.Factory.Support
// it's a normal object ?
if (!ObjectUtils.IsAssignable(typeof(IFactoryObject), instance))
{
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(string.Format("Calling code asked for normal instance for name '{0}'.", canonicalName));
}
#endregion
return instance;
}
// the user wants the factory itself ?
if (!ObjectUtils.IsAssignable(typeof(IFactoryObject), instance) || IsFactoryDereference(name))
{
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(
@@ -967,20 +946,14 @@ namespace Spring.Objects.Factory.Support
TransformedObjectName(name)));
}
#endregion
return instance;
}
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(string.Format("Object with name '{0}' is a factory object.", canonicalName));
}
#endregion
object resultInstance = null;
if (rod == null)
@@ -990,12 +963,10 @@ namespace Spring.Objects.Factory.Support
if (resultInstance == null)
{
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(string.Format("Dereferencing Object with name '{0}'", canonicalName));
}
#endregion
// return object instance from factory...
IFactoryObject factory = (IFactoryObject)instance;
@@ -1034,12 +1005,10 @@ namespace Spring.Objects.Factory.Support
}
else
{
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(string.Format("Returning factory product from cache for Object with name '{0}'", canonicalName));
}
#endregion
}
return resultInstance;
}
@@ -1083,15 +1052,11 @@ namespace Spring.Objects.Factory.Support
{
IConfigurableFactoryObject configurableFactory = (IConfigurableFactoryObject)factory;
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(string.Format("Factory object with name '{0}' is configurable.", TransformedObjectName(objectName)));
}
#endregion
if (configurableFactory.ProductTemplate != null)
{
ApplyObjectPropertyValues(instance, objectName, configurableFactory.ProductTemplate);
@@ -1661,10 +1626,6 @@ namespace Spring.Objects.Factory.Support
get { return CURRENTLY_IN_CREATION; }
}
#endregion
#region Fields
/// <summary>
/// Parent object factory, for object inheritance support
/// </summary>
@@ -1717,8 +1678,6 @@ namespace Spring.Objects.Factory.Support
/// </summary>
private ISet disposableInnerObjects = new SynchronizedSet(new HybridSet());
#endregion
/// <summary>
/// Set that holds all inner objects created by this factory that implement the IDisposable
/// interface, to be destroyed on call to Dispose.
@@ -1728,8 +1687,6 @@ namespace Spring.Objects.Factory.Support
get { return disposableInnerObjects; }
}
#region IHierarchicalObjectFactory Members
/// <summary>
/// The parent object factory, or <see langword="null"/> if there is none.
/// </summary>
@@ -1759,12 +1716,6 @@ namespace Spring.Objects.Factory.Support
(!ObjectFactoryUtils.IsFactoryDereference(name) || IsFactoryObject(objectName)));
}
#endregion
#region IObjectFactory Members
#region New region
/// <summary>
/// Is this object a singleton?
/// </summary>
@@ -2180,12 +2131,10 @@ namespace Spring.Objects.Factory.Support
string objectName = TransformedObjectName(name);
Interlocked.Increment(ref nestingCount);
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(string.Format("{2}GetObjectInternal: obtaining instance for name {0} => canonical name {1}", name, objectName, new String(' ', nestingCount * INDENT)));
}
#endregion
object instance = null;
@@ -2196,7 +2145,6 @@ namespace Spring.Objects.Factory.Support
object sharedInstance = GetSingleton(objectName);
if (sharedInstance != null)
{
#region Instrumentation
if (log.IsDebugEnabled)
{
if (IsSingletonCurrentlyInCreation(objectName))
@@ -2209,7 +2157,6 @@ namespace Spring.Objects.Factory.Support
log.Debug(string.Format("Returning cached instance of singleton object '{0}'.", objectName));
}
}
#endregion
instance = GetObjectForInstance(sharedInstance, name, objectName, null);
return EnsureObjectIsOfRequiredType(name, instance, requiredType);
@@ -2296,12 +2243,11 @@ namespace Spring.Objects.Factory.Support
}
hasErrors = true;
#region Instrumentation
if (log.IsErrorEnabled)
{
log.Error(string.Format("{1}GetObjectInternal: error obtaining object {0}", name, new String(' ', nestingCount * INDENT)));
}
#endregion
throw;
}
finally
@@ -2315,12 +2261,11 @@ namespace Spring.Objects.Factory.Support
nestingCount--;
}
}
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(string.Format("{1}GetObjectInternal: returning instance for objectname {0}", name, new String(' ', nestingCount * INDENT)));
}
#endregion
}
}
}
@@ -2399,12 +2344,10 @@ namespace Spring.Objects.Factory.Support
object sharedInstance = singletonCache[objectName];
if (sharedInstance == null)
{
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(string.Format("Creating shared instance of singleton object '{0}'", objectName));
}
#endregion
BeforeSingletonCreation(objectName);
try
@@ -2417,12 +2360,10 @@ namespace Spring.Objects.Factory.Support
}
AddSingleton(objectName, sharedInstance);
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(string.Format("Cached shared instance of singleton object '{0}'", objectName));
}
#endregion
}
return sharedInstance;
}
@@ -2442,24 +2383,16 @@ namespace Spring.Objects.Factory.Support
/// <seealso cref="Spring.Objects.Factory.IObjectFactory.ConfigureObject(object, string)"/>
public abstract object ConfigureObject(object target, string name, IObjectDefinition definition);
#endregion
#endregion
/// <summary>
/// Destroy all cached singletons in this factory.
/// </summary>
public virtual void Dispose()
{
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(string.Format("Destroying singletons in factory [{0}].", this));
}
#endregion
this.prototypesInCreation.Dispose();
lock (singletonCache)
@@ -2615,36 +2548,24 @@ namespace Spring.Objects.Factory.Support
/// <seealso cref="Spring.Objects.Factory.Config.IConfigurableObjectFactory.RegisterAlias"/>.
public void RegisterAlias(string name, string alias)
{
#region Sanity Checks
AssertUtils.ArgumentHasText(name, "The object name must not be empty.");
AssertUtils.ArgumentHasText(alias, "The alias must not be empty.");
#endregion
if (name == alias)
{
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(string.Format("Ignoring attempt to Register alias '{0}' for object with name '{1}' because name and alias would be the same value.", alias, name));
}
#endregion
return;
}
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(string.Format("Registering alias '{0}' for object with name '{1}'.", alias, name));
}
#endregion
lock (aliasMap)
{
object registeredName = aliasMap[alias];
@@ -2670,8 +2591,6 @@ namespace Spring.Objects.Factory.Support
TypeConverterRegistry.RegisterConverter(requiredType, converter);
}
#region ISingletonObjectRegistry Members
/// <summary>
/// Register the given existing object as singleton in the object factory,
/// under the given object name.
@@ -2781,8 +2700,6 @@ namespace Spring.Objects.Factory.Support
}
}
#endregion
/// <summary>
/// Registers the disposable object.

View File

@@ -1,6 +1,4 @@
#region License
/*
/*
/// Copyright 2002-2010 the original author or authors.
*
/// Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,8 +14,6 @@
/// limitations under the License.
*/
#endregion
using System;
using System.Diagnostics;

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright <20> 2002-2011 the original author or authors.
*
@@ -16,10 +14,6 @@
* limitations under the License.
*/
#endregion
#region Imports
using System;
using System.Collections;
using System.Collections.Generic;
@@ -31,8 +25,6 @@ using Spring.Objects.Factory.Attributes;
using Spring.Objects.Factory.Config;
using Spring.Util;
#endregion
namespace Spring.Objects.Factory.Support
{
/// <summary>
@@ -43,9 +35,7 @@ namespace Spring.Objects.Factory.Support
/// <author>Rick Evans (.NET)</author>
public sealed class AutowireUtils
{
#region Constructor (s) / Destructor
// CLOVER:OFF
// CLOVER:OFF
/// <summary>
/// Creates a new instance of the AutowireUtils class.
@@ -62,9 +52,7 @@ namespace Spring.Objects.Factory.Support
// CLOVER:ON
#endregion
/// <summary>
/// <summary>
/// Gets those <see cref="System.Reflection.ConstructorInfo"/>s
/// that are applicable for autowiring the supplied <paramref name="definition"/>.
/// </summary>
@@ -264,9 +252,7 @@ namespace Spring.Objects.Factory.Support
}
}
#region Inner Class : ConstructorComparer
private sealed class ConstructorComparer : IComparer
private sealed class ConstructorComparer : IComparer
{
public int Compare(object lhs, object rhs)
{
@@ -294,11 +280,7 @@ namespace Spring.Objects.Factory.Support
}
}
#endregion
#region Inner Class : MinimumArgumentCountCriteria
private sealed class MinimumArgumentCountCriteria : ICriteria
private sealed class MinimumArgumentCountCriteria : ICriteria
{
public MinimumArgumentCountCriteria(int minimumArgumentCount)
{
@@ -315,9 +297,7 @@ namespace Spring.Objects.Factory.Support
private int _minimumArgumentCount;
}
#endregion
/// <summary>
/// <summary>
/// Determines whether the setter property is defined in any of the given interfaces.
/// </summary>
/// <param name="propertyInfo">The PropertyInfo of the object property</param>

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright <20> 2002-2011 the original author or authors.
*
@@ -16,17 +14,11 @@
* limitations under the License.
*/
#endregion
#region Imports
using System;
using System.Text;
using Spring.Objects.Factory.Config;
using Spring.Util;
#endregion
namespace Spring.Objects.Factory.Support
{
/// <summary>
@@ -71,8 +63,6 @@ namespace Spring.Objects.Factory.Support
[Serializable]
public class ChildObjectDefinition : AbstractObjectDefinition
{
#region Constructor (s) / Destructor
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Objects.Factory.Support.ChildObjectDefinition"/>
@@ -178,10 +168,6 @@ namespace Spring.Objects.Factory.Support
ObjectTypeName = typeName;
}
#endregion
#region Properties
/// <summary>
/// The name of the parent object definition.
/// </summary>
@@ -197,10 +183,6 @@ namespace Spring.Objects.Factory.Support
set { parentName = value; }
}
#endregion
#region Methods
/// <summary>
/// Validate this object definition.
/// </summary>
@@ -243,12 +225,6 @@ namespace Spring.Objects.Factory.Support
return buffer.ToString();
}
#endregion
#region Fields
private string parentName;
#endregion
}
}

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright 2002-2010 the original author or authors.
*
@@ -16,8 +14,6 @@
* limitations under the License.
*/
#endregion
using System;
using System.Collections;
using System.Collections.Generic;
@@ -101,15 +97,11 @@ namespace Spring.Objects.Factory.Support
wrapper.WrappedInstance = instantiationStrategy.Instantiate(rod, objectName, this.objectFactory,
constructorInstantiationInfo.ConstructorInfo, constructorInstantiationInfo.ArgInstances);
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(string.Format(CultureInfo.InvariantCulture, "Object '{0}' instantiated via constructor [{1}].", objectName, constructorInstantiationInfo.ConstructorInfo));
}
#endregion
return wrapper;
}
@@ -360,15 +352,11 @@ namespace Spring.Objects.Factory.Support
object objectInstance = instantiationStrategy.Instantiate(definition, name, objectFactory, factoryMethodCandidate, arguments);
wrapper.WrappedInstance = objectInstance;
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(string.Format(CultureInfo.InvariantCulture, "Object '{0}' instantiated via factory method [{1}].", name, factoryMethodCandidate));
}
#endregion
return wrapper;
}

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright © 2002-2011 the original author or authors.
*
@@ -16,10 +14,6 @@
* limitations under the License.
*/
#endregion
#region Imports
using System;
using System.Collections;
using System.Collections.Generic;
@@ -34,8 +28,6 @@ using Spring.Objects.Factory.Config;
using Spring.Util;
using Spring.Expressions;
#endregion
namespace Spring.Objects.Factory.Support
{
/// <summary>
@@ -73,8 +65,6 @@ namespace Spring.Objects.Factory.Support
IConfigurableListableObjectFactory,
IObjectDefinitionRegistry
{
#region Constructor (s) / Destructor
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Objects.Factory.Support.DefaultListableObjectFactory"/> class.
@@ -124,10 +114,6 @@ namespace Spring.Objects.Factory.Support
}
}
#endregion
#region Properties
/// <summary>
/// Should object definitions registered under the same name as an
/// existing object definition be allowed?
@@ -169,10 +155,6 @@ namespace Spring.Objects.Factory.Support
}
}
#endregion
#region Methods
/// <summary>
/// Find object instances that match the <paramref name="requiredType"/>.
/// </summary>
@@ -286,24 +268,15 @@ namespace Spring.Objects.Factory.Support
return (rod.HasObjectType && checkedType.IsAssignableFrom(rod.ObjectType));
}
#endregion
#region Fields
/// <summary>
/// The mapping of object depending object names, keyed by object name.
/// </summary>
private IDictionary<string, List<string>> dependingObjectNamesCache;
/// <summary>
/// The <see cref="Common.Logging.ILog"/> instance for this class.
/// </summary>
private readonly ILog log = LogManager.GetLogger(typeof(DefaultListableObjectFactory));
private Dictionary<string, List<string>> dependingObjectNamesCache;
/// <summary>
/// The mapping of object definition objects, keyed by object name.
/// </summary>
private readonly IDictionary<string, IObjectDefinition> objectDefinitionMap;
private readonly Dictionary<string, IObjectDefinition> objectDefinitionMap;
/// <summary>
/// List of object definition names, in registration order.
@@ -320,10 +293,6 @@ namespace Spring.Objects.Factory.Support
/// </summary>
private readonly IDictionary<Type, object> resolvableDependencies = new Dictionary<Type, object>();
#endregion
#region IObjectDefinitionRegistry Members
/// <summary>
/// Return the number of objects defined in this registry.
/// </summary>
@@ -396,8 +365,6 @@ namespace Spring.Objects.Factory.Support
}
else
{
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug(
@@ -405,8 +372,6 @@ namespace Spring.Objects.Factory.Support
"Overriding object definition for object '{0}': replacing [{1}] with [{2}].",
name, oldObjectDefinition, objectDefinition));
}
#endregion
}
}
else
@@ -416,10 +381,6 @@ namespace Spring.Objects.Factory.Support
objectDefinitionMap[name] = objectDefinition;
}
#endregion
#region IConfigurableListableObjectFactory Members
/// <summary>
/// Ensure that all non-lazy-init singletons are instantiated, also
/// considering <see cref="Spring.Objects.Factory.IFactoryObject"/>s.
@@ -430,15 +391,11 @@ namespace Spring.Objects.Factory.Support
/// <seealso cref="Spring.Objects.Factory.Config.IConfigurableListableObjectFactory.PreInstantiateSingletons"/>
public void PreInstantiateSingletons()
{
#region Instrumentation
if (log.IsDebugEnabled)
{
log.Debug("Pre-instantiating singletons in factory [" + this + "]");
}
#endregion
try
{
int definitionCount = objectDefinitionNames.Count;
@@ -585,10 +542,6 @@ namespace Spring.Objects.Factory.Support
return definition;
}
#endregion
#region IListableObjectFactory Members
/// <summary>
/// Return the names of all objects defined in this factory.
@@ -1130,8 +1083,6 @@ namespace Spring.Objects.Factory.Support
return (objectType != null && typeof(IFactoryObject).IsAssignableFrom(objectType));
}
#endregion
/// <summary>
/// Resolve the specified dependency against the objects defined in this factory.
/// </summary>

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright <20> 2002-2011 the original author or authors.
*
@@ -16,17 +14,11 @@
* limitations under the License.
*/
#endregion
#region Imports
using System;
using Spring.Core.TypeResolution;
using Spring.Util;
#endregion
namespace Spring.Objects.Factory.Support
{
/// <summary>
@@ -44,9 +36,7 @@ namespace Spring.Objects.Factory.Support
[Serializable]
public class DefaultObjectDefinitionFactory : IObjectDefinitionFactory
{
#region IObjectDefinitionFactory Members
/// <summary>
/// <summary>
/// Factory style method for getting concrete
/// <see cref="IConfigurableObjectDefinition"/>
/// instances.
@@ -104,9 +94,5 @@ namespace Spring.Objects.Factory.Support
}
}
}
#endregion
}
}

View File

@@ -21,6 +21,7 @@
#region Imports
using System;
using System.Runtime.Serialization;
using Spring.Objects.Factory.Config;
@@ -61,8 +62,6 @@ namespace Spring.Objects.Factory.Support
[Serializable]
public class RootObjectDefinition : AbstractObjectDefinition
{
#region Constructor (s) / Destructor
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Objects.Factory.Support.RootObjectDefinition"/> class.
@@ -251,9 +250,13 @@ namespace Spring.Objects.Factory.Support
/// The definition that is to be copied.
/// </param>
public RootObjectDefinition(IObjectDefinition other) : base(other)
{}
{
}
#endregion
protected RootObjectDefinition(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
/// <summary>
/// Is always <c>null</c> for a <see cref="RootObjectDefinition"/>.

View File

@@ -1,4 +1,3 @@
#region License
/*
* Copyright <20> 2002-2011 the original author or authors.
*
@@ -14,9 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#endregion
#region Imports
using System;
using System.Collections;
@@ -25,8 +21,6 @@ using System.Collections.Generic;
using Spring.Objects.Factory.Config;
using Spring.Util;
#endregion
namespace Spring.Objects.Factory.Support
{
/// <summary>

View File

@@ -1,5 +1,3 @@
#region License
/*
* Copyright <20> 2002-2011 the original author or authors.
*
@@ -16,16 +14,10 @@
* limitations under the License.
*/
#endregion
#region Imports
using System;
using Spring.Core.IO;
using Spring.Objects.Factory.Support;
#endregion
namespace Spring.Objects.Factory.Xml
{
/// <summary>
@@ -61,9 +53,7 @@ namespace Spring.Objects.Factory.Xml
[Serializable]
public class XmlObjectFactory : DefaultListableObjectFactory
{
#region Constructor (s) / Destructor
/// <summary>
/// <summary>
/// Creates a new instance of the <see cref="XmlObjectFactory"/> class,
/// with the given resource, which must be parsable using DOM.
/// </summary>
@@ -129,11 +119,7 @@ namespace Spring.Objects.Factory.Xml
ObjectDefinitionReader.LoadObjectDefinitions(resource);
}
#endregion
#region Properties
/// <summary>
/// <summary>
/// Gets object definition reader to use.
/// </summary>
protected virtual IObjectDefinitionReader ObjectDefinitionReader
@@ -143,7 +129,5 @@ namespace Spring.Objects.Factory.Xml
return new XmlObjectDefinitionReader(this);
}
}
#endregion
}
}

View File

@@ -56,7 +56,7 @@ namespace Spring.Objects
[Serializable]
public class ObjectWrapper : IObjectWrapper
{
private ILog Log = LogManager.GetLogger(typeof(ObjectWrapper));
private static readonly ILog Log = LogManager.GetLogger(typeof(ObjectWrapper));
#region Fields

View File

@@ -22,13 +22,10 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using Spring.Util;
using NetDynamicMethod = System.Reflection.Emit.DynamicMethod;
@@ -82,209 +79,12 @@ namespace Spring.Reflection.Dynamic
/// <returns>the new object instance</returns>
public delegate object ConstructorDelegate(params object[] args);
/// <summary>
/// Represents a callback method used to create an <see cref="IDynamicProperty"/> from a <see cref="PropertyInfo"/> instance.
/// </summary>
internal delegate IDynamicProperty CreatePropertyCallback(PropertyInfo property);
/// <summary>
/// Represents a callback method used to create an <see cref="IDynamicField"/> from a <see cref="FieldInfo"/> instance.
/// </summary>
internal delegate IDynamicField CreateFieldCallback(FieldInfo property);
/// <summary>
/// Represents a callback method used to create an <see cref="IDynamicMethod"/> from a <see cref="MethodInfo"/> instance.
/// </summary>
internal delegate IDynamicMethod CreateMethodCallback(MethodInfo method);
/// <summary>
/// Represents a callback method used to create an <see cref="IDynamicConstructor"/> from a <see cref="ConstructorInfo"/> instance.
/// </summary>
internal delegate IDynamicConstructor CreateConstructorCallback(ConstructorInfo constructor);
/// <summary>
/// Represents a callback method used to create an <see cref="IDynamicIndexer"/> from a <see cref="PropertyInfo"/> instance.
/// </summary>
internal delegate IDynamicIndexer CreateIndexerCallback(PropertyInfo indexer);
/// <summary>
/// Allows easy access to existing and creation of new dynamic relection members.
/// </summary>
/// <author>Aleksandar Seovic</author>
public sealed class DynamicReflectionManager
{
#region Obsolete Code
#region Fields
/// <summary>
/// The name of the assembly that defines reflection types created.
/// </summary>
public const string ASSEMBLY_NAME = "Spring.DynamicReflection";
/// <summary>
/// The attributes of the reflection type to generate.
/// </summary>
private const TypeAttributes TYPE_ATTRIBUTES = TypeAttributes.BeforeFieldInit | TypeAttributes.Public;
/// <summary>
/// Cache for dynamic property types.
/// </summary>
private readonly static IDictionary<PropertyInfo, IDynamicProperty> propertyCache = new Dictionary<PropertyInfo, IDynamicProperty>();
private readonly static object propertyCacheLock = new object();
/// <summary>
/// Cache for dynamic field types.
/// </summary>
private readonly static IDictionary<FieldInfo, IDynamicField> fieldCache = new Dictionary<FieldInfo, IDynamicField>();
private readonly static object fieldCacheLock = new object();
/// <summary>
/// Cache for dynamic indexer types.
/// </summary>
private readonly static IDictionary<PropertyInfo, IDynamicIndexer> indexerCache = new Dictionary<PropertyInfo, IDynamicIndexer>();
private readonly static object indexerCacheLock = new object();
/// <summary>
/// Cache for dynamic method types.
/// </summary>
private readonly static IDictionary<MethodInfo, IDynamicMethod> methodCache = new Dictionary<MethodInfo, IDynamicMethod>();
private readonly static object methodCacheLock = new object();
/// <summary>
/// Cache for dynamic constructor types.
/// </summary>
private readonly static IDictionary<ConstructorInfo, IDynamicConstructor> constructorCache = new Dictionary<ConstructorInfo, IDynamicConstructor>();
private readonly static object constructorCacheLock = new object();
#endregion
/// <summary>
/// Creates an appropriate type builder.
/// </summary>
/// <param name="name">
/// The base name to use for the reflection type name.
/// </param>
/// <returns>The type builder to use.</returns>
internal static TypeBuilder CreateTypeBuilder(string name)
{
// Generates type name
string typeName = String.Format("{0}.{1}_{2}",
ASSEMBLY_NAME, name, Guid.NewGuid().ToString("N"));
ModuleBuilder module = DynamicCodeManager.GetModuleBuilder(ASSEMBLY_NAME);
return module.DefineType(typeName, TYPE_ATTRIBUTES);
}
/// <summary>
/// Returns dynamic property if one exists.
/// </summary>
/// <param name="property">Property to look up.</param>
/// <param name="createCallback">callback function that will be called to create the dynamic property</param>
/// <returns>An <see cref="IDynamicProperty"/> for the given property info.</returns>
internal static IDynamicProperty GetDynamicProperty(PropertyInfo property, CreatePropertyCallback createCallback)
{
lock (propertyCacheLock)
{
IDynamicProperty dynamicProperty;
if (!propertyCache.TryGetValue(property, out dynamicProperty))
{
dynamicProperty = createCallback(property);
propertyCache[property] = dynamicProperty;
}
return dynamicProperty;
}
}
/// <summary>
/// Returns dynamic field if one exists.
/// </summary>
/// <param name="field">Field to look up.</param>
/// <param name="createCallback">callback function that will be called to create the dynamic field</param>
/// <returns>An <see cref="IDynamicField"/> for the given field info.</returns>
internal static IDynamicField GetDynamicField(FieldInfo field, CreateFieldCallback createCallback)
{
lock (fieldCacheLock)
{
IDynamicField dynamicField;
if (!fieldCache.TryGetValue(field, out dynamicField))
{
dynamicField = createCallback(field);
fieldCache[field] = dynamicField;
}
return dynamicField;
}
}
/// <summary>
/// Returns dynamic indexer if one exists.
/// </summary>
/// <param name="indexer">Indexer to look up.</param>
/// <param name="createCallback">callback function that will be called to create the dynamic indexer</param>
/// <returns>An <see cref="IDynamicIndexer"/> for the given indexer.</returns>
internal static IDynamicIndexer GetDynamicIndexer(PropertyInfo indexer, CreateIndexerCallback createCallback)
{
lock (indexerCacheLock)
{
IDynamicIndexer dynamicIndexer;
if (!indexerCache.TryGetValue(indexer, out dynamicIndexer))
{
dynamicIndexer = createCallback(indexer);
indexerCache[indexer] = dynamicIndexer;
}
return dynamicIndexer;
}
}
/// <summary>
/// Returns dynamic method if one exists.
/// </summary>
/// <param name="method">Method to look up.</param>
/// <param name="createCallback">callback function that will be called to create the dynamic method</param>
/// <returns>An <see cref="IDynamicMethod"/> for the given method.</returns>
internal static IDynamicMethod GetDynamicMethod(MethodInfo method, CreateMethodCallback createCallback)
{
lock (methodCacheLock)
{
IDynamicMethod dynamicMethod;
if (!methodCache.TryGetValue(method, out dynamicMethod))
{
dynamicMethod = createCallback(method);
methodCache[method] = dynamicMethod;
}
return dynamicMethod;
}
}
/// <summary>
/// Returns dynamic constructor if one exists.
/// </summary>
/// <param name="constructor">Constructor to look up.</param>
/// <param name="createCallback">callback function that will be called to create the dynamic constructor</param>
/// <returns>An <see cref="IDynamicConstructor"/> for the given constructor.</returns>
internal static IDynamicConstructor GetDynamicConstructor(ConstructorInfo constructor, CreateConstructorCallback createCallback)
{
lock (constructorCacheLock)
{
IDynamicConstructor dynamicConstructor;
if (!constructorCache.TryGetValue(constructor, out dynamicConstructor))
{
dynamicConstructor = createCallback(constructor);
constructorCache[constructor] = dynamicConstructor;
}
return dynamicConstructor;
}
}
/// <summary>
/// Saves dynamically generated assembly to disk.
/// Can only be called in DEBUG mode, per ConditionalAttribute rules.
/// </summary>
[Conditional("DEBUG_DYNAMIC")]
public static void SaveAssembly()
{
DynamicCodeManager.SaveAssembly(ASSEMBLY_NAME);
}
#endregion
/// <summary>
/// Create a new Get method delegate for the specified field using <see cref="System.Reflection.Emit.DynamicMethod"/>
/// </summary>
@@ -414,7 +214,9 @@ namespace Spring.Reflection.Dynamic
methodName = "_dynamic_" + member.DeclaringType.FullName + "." + methodName;
try
{
new PermissionSet(PermissionState.Unrestricted).Demand();
#if !NETSTANDARD
new PermissionSet(System.Security.Permissions.PermissionState.Unrestricted).Demand();
#endif
dmGetter = CreateDynamicMethodInternal(methodName, returnType, argumentTypes, member, skipVisibility);
}
catch(SecurityException)

View File

@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net452</TargetFramework>
<TargetFrameworks>netstandard2.0;$(TargetFullFrameworkVersion)</TargetFrameworks>
<Description>Core functionality for Spring.Net IoC container</Description>
<NoWarn>219, 162, 618, 1591</NoWarn>
</PropertyGroup>
@@ -8,10 +8,23 @@
<PreBuildEvent>rem $(ProjectDir)..\..\..\build-support\tools\antlr-2.7.6\antlr-2.7.6.exe -o $(ProjectDir)Expressions\Parser $(ProjectDir)Expressions\Expression.g
</PreBuildEvent>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == '$(TargetFullFrameworkVersion)' ">
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="System.Configuration" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0" />
<PackageReference Include="System.CodeDom" Version="4.5.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
<PackageReference Include="System.Reflection" Version="4.3.0" />
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.3.0" />
<PackageReference Include="System.Reflection.Primitives" Version="4.3.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<Compile Remove="Threading\CallContextStorage.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Common.Logging" Version="$(CommonLoggingVersion)" />
</ItemGroup>

View File

@@ -37,4 +37,4 @@ namespace Spring.Threading
CallContext.FreeNamedDataSlot(name);
}
}
}
}

View File

@@ -21,7 +21,6 @@
#region Imports
using System;
using System.Runtime.Remoting.Messaging;
using Spring.Util;
#endregion
@@ -32,7 +31,6 @@ namespace Spring.Threading
/// An abstraction to safely store "ThreadStatic" data.
/// </summary>
/// <remarks>
/// By default, <see cref="CallContext"/> is used to store thread-specific data.
/// You may switch the storage strategy by calling <see cref="SetStorage(IThreadStorage)"/>.<p/>
/// <b>NOTE:</b> Access to the underlying storage is not synchronized for performance reasons.
/// You should call <see cref="SetStorage(IThreadStorage)"/> only once at application startup!
@@ -48,7 +46,12 @@ namespace Spring.Threading
/// Setting a different <see cref="IThreadStorage"/> strategy should happen only once
/// at application startup.
/// </remarks>
private static IThreadStorage threadStorage = new CallContextStorage();
private static IThreadStorage threadStorage =
#if NETSTANDARD
new ThreadStaticStorage();
#else
new CallContextStorage();
#endif
/// <summary>
/// Set the new <see cref="IThreadStorage"/> strategy.

View File

@@ -25,7 +25,6 @@ using System.Collections;
using System.Globalization;
using System.Reflection;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Proxies;
#endregion
@@ -95,10 +94,11 @@ namespace Spring.Util
throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, "Target '{0}' is null.", targetName));
}
Type targetType;
Type targetType = null;
if (RemotingServices.IsTransparentProxy(target))
{
RealProxy rp = RemotingServices.GetRealProxy(target);
#if !NETSTANDARD
System.Runtime.Remoting.Proxies.RealProxy rp = RemotingServices.GetRealProxy(target);
IRemotingTypeInfo rti = rp as IRemotingTypeInfo;
if (rti != null)
{
@@ -109,10 +109,11 @@ namespace Spring.Util
throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, "Target '{0}' is a transparent proxy that does not support methods of '{1}'.", targetName, requiredType.FullName));
}
targetType = rp.GetProxiedType();
#endif
}
else
{
targetType = target.GetType();
targetType = target.GetType();
}
if (!requiredType.IsAssignableFrom(targetType))

View File

@@ -61,7 +61,9 @@ namespace Spring.Util
{
try
{
return ConfigurationManager.GetSection(sectionName.TrimEnd('/'));
var name = sectionName.TrimEnd('/');
var section = ConfigurationManager.GetSection(name);
return section;
}
catch (ConfigurationException)
{

View File

@@ -94,26 +94,39 @@ namespace Spring.Util
{
AssemblyName an = new AssemblyName();
an.Name = assemblyName;
AssemblyBuilder assembly;
#if DEBUG_DYNAMIC
assembly = AppDomain.CurrentDomain.DefineDynamicAssembly(an, AssemblyBuilderAccess.RunAndSave, null, null, null, null,null, true );
module = assembly.DefineDynamicModule(an.Name, an.Name + ".dll", true);
#else
an.SetPublicKey(Assembly.GetExecutingAssembly().GetName().GetPublicKey());
assembly = AppDomain.CurrentDomain.DefineDynamicAssembly(an, AssemblyBuilderAccess.Run, null, null, null, null,null, true );
#if DEBUG
module = assembly.DefineDynamicModule(an.Name, true);
#else
module = assembly.DefineDynamicModule(an.Name, false);
#endif
#endif
module = BuildModule(an);
s_moduleCache[assemblyName] = module;
}
return module;
}
}
#if !NETSTANDARD
private static ModuleBuilder BuildModule(AssemblyName an)
{
#if DEBUG_DYNAMIC
AssemblyBuilder assembly = AppDomain.CurrentDomain.DefineDynamicAssembly(an, AssemblyBuilderAccess.RunAndSave, null, null, null, null,null, true );
var module = assembly.DefineDynamicModule(an.Name, an.Name + ".dll", true);
#else
an.SetPublicKey(Assembly.GetExecutingAssembly().GetName().GetPublicKey());
var assembly = AppDomain.CurrentDomain.DefineDynamicAssembly(an, AssemblyBuilderAccess.Run, null, null, null, null,null, true );
#if DEBUG
module = assembly.DefineDynamicModule(an.Name, true);
#else
var module = assembly.DefineDynamicModule(an.Name, false);
#endif
#endif
return module;
}
#else
private static ModuleBuilder BuildModule(AssemblyName an)
{
var assembly = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName(Guid.NewGuid().ToString()), AssemblyBuilderAccess.Run);
var module = assembly.DefineDynamicModule(an.Name);
return module;
}
#endif
/// <summary>
/// Persists the specified dynamic assembly to the file-system
/// </summary>
@@ -121,7 +134,7 @@ namespace Spring.Util
/// <remarks>
/// Can only be called in DEBUG_DYNAMIC mode, per ConditionalAttribute rules.
/// </remarks>
[Conditional("DEBUG_DYNAMIC")]
[Conditional("DEBUG_DYNAMIC")]
public static void SaveAssembly( string assemblyName )
{
AssertUtils.ArgumentHasText(assemblyName, "assemblyName");
@@ -138,7 +151,10 @@ namespace Spring.Util
}
AssemblyBuilder assembly = (AssemblyBuilder) module.Assembly;
assembly.Save(assembly.GetName().Name + ".dll");
#if !NETSTANDARD
assembly.Save(assembly.GetName().Name + ".dll");
#endif
}
/// <summary>

View File

@@ -25,7 +25,9 @@ using System.Collections;
using System.Globalization;
using System.Reflection;
using System.Runtime.Remoting;
#if !NETSTANDARD
using System.Runtime.Remoting.Proxies;
#endif
using Common.Logging;
using Spring.Reflection.Dynamic;
@@ -314,6 +316,7 @@ namespace Spring.Util
return true;
}
#if !NETSTANDARD
if (RemotingServices.IsTransparentProxy(obj))
{
RealProxy rp = RemotingServices.GetRealProxy(obj);
@@ -332,6 +335,7 @@ namespace Spring.Util
return false;
}
}
#endif
return (type.IsInstanceOfType(obj) ||
(type.Equals(typeof(bool)) && obj is Boolean) ||

View File

@@ -26,7 +26,6 @@ using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using System.Reflection.Emit;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Runtime.CompilerServices;
@@ -1239,29 +1238,20 @@ namespace Spring.Util
}
else if (attrsData.Count > 0)
{
if (SystemUtils.Clr4Runtime)
bool hasSecurityAttribute = false;
foreach (CustomAttributeData cad in attrsData)
{
bool hasSecurityAttribute = false;
foreach (CustomAttributeData cad in attrsData)
if (typeof(SecurityAttribute).IsAssignableFrom(cad.Constructor.DeclaringType))
{
if (typeof(SecurityAttribute).IsAssignableFrom(cad.Constructor.DeclaringType))
{
hasSecurityAttribute = true;
break;
}
}
if (hasSecurityAttribute)
{
attributes.AddRange(attrs);
}
else
{
foreach (CustomAttributeData cad in attrsData)
{
attributes.Add(cad);
}
hasSecurityAttribute = true;
break;
}
}
if (hasSecurityAttribute)
{
attributes.AddRange(attrs);
}
else
{
foreach (CustomAttributeData cad in attrsData)
@@ -1609,9 +1599,9 @@ namespace Spring.Util
}
FieldInfo[] fields = GetFields(type);
SecurityCritical.ExecutePrivileged(new PermissionSet(PermissionState.Unrestricted), delegate
Action callback = () =>
{
DynamicMethod dm = new DynamicMethod(type.FullName + ".ShallowCopy", null, new Type[] { typeof(object), typeof(object) }, type.Module, true);
DynamicMethod dm = new DynamicMethod(type.FullName + ".ShallowCopy", null, new Type[] {typeof(object), typeof(object)}, type.Module, true);
ILGenerator ilGen = dm.GetILGenerator();
ilGen.DeclareLocal(type);
ilGen.DeclareLocal(type);
@@ -1629,16 +1619,24 @@ namespace Spring.Util
ilGen.Emit(OpCodes.Ldfld, field);
ilGen.Emit(OpCodes.Stfld, field);
}
ilGen.Emit(OpCodes.Ret);
handler = (MemberwiseCopyHandler)dm.CreateDelegate(typeof(MemberwiseCopyHandler));
});
handler = (MemberwiseCopyHandler) dm.CreateDelegate(typeof(MemberwiseCopyHandler));
};
#if NETSTANDARD
callback();
#else
SecurityCritical.ExecutePrivileged(new System.Security.PermissionSet(PermissionState.Unrestricted), callback);
#endif
s_handlerCache[type] = handler;
}
return handler;
}
#region Field Cache Management for "MemberwiseCopy"
private const BindingFlags FIELDBINDINGS =

View File

@@ -18,6 +18,8 @@
#endregion
#if !NETSTANDARD
using System;
using System.Runtime.CompilerServices;
using System.Security;
@@ -30,11 +32,9 @@ namespace Spring.Util
/// <author>Erich Eichinger</author>
internal class SecurityCritical
{
internal delegate void PrivilegedCallback();
[SecurityCritical, SecurityTreatAsSafe]
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void ExecutePrivileged(IStackWalk permission, PrivilegedCallback callback)
internal static void ExecutePrivileged(IStackWalk permission, Action callback)
{
permission.Assert();
try
@@ -48,3 +48,4 @@ namespace Spring.Util
}
}
}
#endif

View File

@@ -0,0 +1,10 @@
#if NETSTANDARD
// ReSharper disable once CheckNamespace
namespace System.Runtime.Remoting
{
internal class RemotingServices
{
public static bool IsTransparentProxy(object o) => false;
}
}
#endif

View File

@@ -38,12 +38,10 @@ namespace Spring.Util
private static readonly object assemblyResolverLock;
private static readonly bool isMono;
private static readonly bool isClr4;
static SystemUtils()
{
isMono = Type.GetType("Mono.Runtime") == null ? false : true;
isClr4 = Environment.Version.Major == 4 ? true : false;
isMono = Type.GetType("Mono.Runtime") != null;
assemblyResolverLock = new object();
}
@@ -93,14 +91,6 @@ namespace Spring.Util
get { return isMono; }
}
/// <summary>
/// Returns true if running on CLR 4.0 under InProc SxS mode
/// </summary>
public static bool Clr4Runtime
{
get { return isClr4; }
}
/// <summary>
/// Gets the thread id for the current thread. Use thread name is available,
/// otherwise use CurrentThread.GetHashCode() for .NET 1.0/1.1 and

View File

@@ -0,0 +1,11 @@
using System;
using System.Reflection;
namespace Spring.Util
{
internal static class TypeExtensions
{
internal static string AssemblyQualifiedNameWithoutVersion(this Type type)
=> type.FullName + ", " + type.GetTypeInfo().Assembly.GetName().Name;
}
}

View File

@@ -27,7 +27,7 @@ namespace Spring.Validation.Actions
{
public class ExceptionAction : BaseValidationAction
{
private ILog log = LogManager.GetLogger(typeof(ExceptionAction));
private static readonly ILog log = LogManager.GetLogger(typeof(ExceptionAction));
private IExpression throwsExpression;
/// <summary>
@@ -38,11 +38,11 @@ namespace Spring.Validation.Actions
}
/// <summary>
/// Initializes a new instance of the <see cref="ExceptionAction"/> class.
/// Initializes a new instance of the <see cref="ExceptionAction"/> class.
/// </summary>
/// <param name="exceptionExpression">Expression that defines the exception to throw when the validator is not valid.</param>
public ExceptionAction(string exceptionExpression)
: this((exceptionExpression != null ? Expression.Parse(exceptionExpression) : null))
: this((exceptionExpression != null ? Expression.Parse(exceptionExpression) : null))
{}
/// <summary>

View File

@@ -70,18 +70,7 @@ namespace Spring.Dao
public CannotAcquireLockException( string message, Exception rootCause)
: base( message , rootCause ) {}
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Dao.CannotAcquireLockException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected CannotAcquireLockException(
SerializationInfo info, StreamingContext context ) : base( info, context ) {}
}

View File

@@ -70,18 +70,7 @@ namespace Spring.Dao
public CannotSerializeTransactionException( string message, Exception rootCause)
: base( message , rootCause ) {}
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Dao.CannotSerializeTransactionException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected CannotSerializeTransactionException(
SerializationInfo info, StreamingContext context ) : base( info, context ) {}
}

View File

@@ -44,7 +44,7 @@ namespace Spring.Dao
/// </remarks>
/// <author>Rod Johnson</author>
/// <author>Griffin Caprio (.NET)</author>
[Serializable]
[Serializable]
public class CleanupFailureDataAccessException : NonTransientDataAccessException
{
/// <summary>
@@ -75,18 +75,7 @@ namespace Spring.Dao
public CleanupFailureDataAccessException( string message, Exception rootCause)
: base( message , rootCause ) {}
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Dao.CleanupFailureDataAccessException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected CleanupFailureDataAccessException(
SerializationInfo info, StreamingContext context ) : base( info, context ) {}
}

View File

@@ -26,19 +26,19 @@ using System.Runtime.Serialization;
#endregion
namespace Spring.Dao
{
/// <summary>
/// Exception thrown on concurrency failure. This exception should be
/// sublassed to indicate the type of failure - optimistic locking,
/// failure to acquire lock, etc.
/// </summary>
/// <remarks>
/// <p>
/// This exception will be thrown either by O/R mapping tools or by custom DAO
/// implementations.
/// </p>
/// </remarks>
/// <author>Thomas Risberg</author>
{
/// <summary>
/// Exception thrown on concurrency failure. This exception should be
/// sublassed to indicate the type of failure - optimistic locking,
/// failure to acquire lock, etc.
/// </summary>
/// <remarks>
/// <p>
/// This exception will be thrown either by O/R mapping tools or by custom DAO
/// implementations.
/// </p>
/// </remarks>
/// <author>Thomas Risberg</author>
/// <author>Griffin Caprio (.NET)</author>
[Serializable]
public class ConcurrencyFailureException : TransientDataAccessException
@@ -71,18 +71,7 @@ namespace Spring.Dao
public ConcurrencyFailureException( string message, Exception rootCause)
: base( message , rootCause ) {}
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Dao.ConcurrencyFailureException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected ConcurrencyFailureException(
SerializationInfo info, StreamingContext context ) : base( info, context ) {}
}

View File

@@ -63,18 +63,7 @@ namespace Spring.Dao
protected DataAccessException( string message, Exception rootCause)
: base( message , rootCause ) {}
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Dao.DataAccessException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected DataAccessException(
SerializationInfo info, StreamingContext context ) : base( info, context ) {}
}

View File

@@ -64,18 +64,7 @@ namespace Spring.Dao
public DataAccessResourceFailureException( string message, Exception rootCause)
: base( message , rootCause ) {}
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Dao.DataAccessResourceFailureException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected DataAccessResourceFailureException(
SerializationInfo info, StreamingContext context ) : base( info, context ) {}
}

View File

@@ -39,7 +39,7 @@ namespace Spring.Dao
/// </remarks>
/// <author>Rod Johnson</author>
/// <author>Griffin Caprio (.NET)</author>
[Serializable]
[Serializable]
public class DataIntegrityViolationException : NonTransientDataAccessException
{
/// <summary>
@@ -70,18 +70,7 @@ namespace Spring.Dao
public DataIntegrityViolationException( string message, Exception rootCause)
: base( message , rootCause ) {}
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Dao.DataIntegrityViolationException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected DataIntegrityViolationException(
SerializationInfo info, StreamingContext context ) : base( info, context ) {}
}

View File

@@ -39,7 +39,7 @@ namespace Spring.Dao
/// </remarks>
/// <author>Juergen Hoeller</author>
/// <author>Griffin Caprio (.NET)</author>
[Serializable]
[Serializable]
public class DataRetrievalFailureException : NonTransientDataAccessException
{
/// <summary>
@@ -70,18 +70,7 @@ namespace Spring.Dao
public DataRetrievalFailureException( string message, Exception rootCause)
: base( message , rootCause ) {}
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Dao.DataRetrievalFailureException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected DataRetrievalFailureException(
SerializationInfo info, StreamingContext context ) : base( info, context ) {}
}

View File

@@ -64,18 +64,7 @@ namespace Spring.Dao
public DeadlockLoserDataAccessException( string message, Exception rootCause)
: base( message , rootCause ) {}
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Dao.DeadlockLoserDataAccessException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected DeadlockLoserDataAccessException(
SerializationInfo info, StreamingContext context ) : base( info, context ) {}
}

View File

@@ -130,43 +130,19 @@ namespace Spring.Dao
this._actualSize = -1;
}
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Dao.CleanupFailureDataAccessException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected IncorrectResultSizeDataAccessException( SerializationInfo info, StreamingContext context ) : base( info, context )
{
_expectedSize = info.GetInt32( "expectedSize" );
_actualSize = info.GetInt32( "actualSize" );
}
#region ISerializable Members
/// <summary>
/// Override of <see cref="System.Exception.GetObjectData(SerializationInfo, StreamingContext)"/>
/// to allow for private serialization.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue( "expectedSize", _expectedSize );
info.AddValue( "actualSize", _actualSize );
base.GetObjectData( info, context );
}
#endregion
}
}

View File

@@ -78,18 +78,7 @@ namespace Spring.Dao
protected IncorrectUpdateSemanticsDataAccessException( string message, Exception rootCause)
: base( message , rootCause ) {}
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Dao.IncorrectUpdateSemanticsDataAccessException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected IncorrectUpdateSemanticsDataAccessException(
SerializationInfo info, StreamingContext context ) : base( info, context ) {}
}

View File

@@ -39,7 +39,7 @@ namespace Spring.Dao
/// </remarks>
/// <author>Rod Johnson</author>
/// <author>Griffin Caprio (.NET)</author>
[Serializable]
[Serializable]
public class InvalidDataAccessApiUsageException : NonTransientDataAccessException
{
/// <summary>
@@ -70,18 +70,7 @@ namespace Spring.Dao
public InvalidDataAccessApiUsageException( string message, Exception rootCause)
: base( message , rootCause ) {}
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Dao.InvalidDataAccessApiUsageException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected InvalidDataAccessApiUsageException(
SerializationInfo info, StreamingContext context ) : base( info, context ) {}
}

View File

@@ -69,18 +69,7 @@ namespace Spring.Dao
public InvalidDataAccessResourceUsageException( string message, Exception rootCause)
: base( message , rootCause ) {}
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Dao.InvalidDataAccessResourceUsageException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected InvalidDataAccessResourceUsageException(
SerializationInfo info, StreamingContext context ) : base( info, context ) {}
}

View File

@@ -65,18 +65,7 @@ namespace Spring.Dao
public NonTransientDataAccessException( string message, Exception rootCause)
: base( message , rootCause ) {}
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Dao.NonTransientDataAccessException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected NonTransientDataAccessException(
SerializationInfo info, StreamingContext context ) : base( info, context ) {}
}

View File

@@ -63,18 +63,7 @@ namespace Spring.Dao
public NonTransientDataAccessResourceException( string message, Exception rootCause)
: base( message , rootCause ) {}
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Dao.NonTransientDataAccessResourceException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected NonTransientDataAccessResourceException(
SerializationInfo info, StreamingContext context ) : base( info, context ) {}
}

View File

@@ -102,18 +102,7 @@ namespace Spring.Dao
this.identifier = identifier;
}
/// <summary>
/// Creates a new instance of the
/// <see cref="ObjectOptimisticLockingFailureException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected ObjectOptimisticLockingFailureException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}

View File

@@ -97,18 +97,7 @@ namespace Spring.Dao
this.identifier = identifier;
}
/// <summary>
/// Creates a new instance of the
/// <see cref="ObjectRetrievalFailureException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected ObjectRetrievalFailureException(
SerializationInfo info, StreamingContext context ) : base( info, context ) {}

View File

@@ -69,18 +69,7 @@ namespace Spring.Dao
public OptimisticLockingFailureException( string message, Exception rootCause)
: base( message , rootCause ) {}
/// <summary>
/// Creates a new instance of the
/// <see cref="Spring.Dao.OptimisticLockingFailureException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
/// <inheritdoc />
protected OptimisticLockingFailureException(
SerializationInfo info, StreamingContext context ) : base( info, context ) {}
}

Some files were not shown because too many files have changed in this diff Show More