本文整理汇总了C#中Spring.Aop.Framework.ProxyFactory.CopyFrom方法的典型用法代码示例。如果您正苦于以下问题:C# ProxyFactory.CopyFrom方法的具体用法?C# ProxyFactory.CopyFrom怎么用?C# ProxyFactory.CopyFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spring.Aop.Framework.ProxyFactory
的用法示例。
在下文中一共展示了ProxyFactory.CopyFrom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AfterPropertiesSet
/// <summary>
/// Method run after all the properties have been set for this object.
/// Responsible for actual proxy creation.
/// </summary>
public void AfterPropertiesSet()
{
_transactionInterceptor.AfterPropertiesSet();
if ( _target == null )
{
throw new ArgumentException("'target' is required.");
}
ProxyFactory proxyFactory = new ProxyFactory();
if ( _preInterceptors != null )
{
for ( int i = 0; i < _preInterceptors.Length; i++ )
{
proxyFactory.AddAdvisor(_advisorAdapterRegistry.Wrap(_preInterceptors[i]));
}
}
if ( _pointcut != null )
{
IAdvisor advice = new DefaultPointcutAdvisor(_pointcut, _transactionInterceptor);
proxyFactory.AddAdvisor(advice);
}
else
{
proxyFactory.AddAdvisor( new TransactionAttributeSourceAdvisor( _transactionInterceptor ) );
}
if ( _postInterceptors != null )
{
for ( int i = 0; i < _postInterceptors.Length; i++ )
{
proxyFactory.AddAdvisor(_advisorAdapterRegistry.Wrap(_postInterceptors[i]));
}
}
proxyFactory.CopyFrom(this);
proxyFactory.TargetSource = createTargetSource(_target);
if ( _proxyInterfaces != null )
{
proxyFactory.Interfaces = _proxyInterfaces;
}
else if ( !ProxyTargetType )
{
if ( _target is ITargetSource )
{
throw new AopConfigException("Either 'ProxyInterfaces' or 'ProxyTargetType' is required " +
"when using an ITargetSource as 'target'");
}
proxyFactory.Interfaces = AopUtils.GetAllInterfaces(_target);
}
_proxy = proxyFactory.GetProxy();
}
示例2: PostProcessAfterInitialization
/// <summary>
/// Add PersistenceExceptionTranslationAdvice to candidate object if it is a match.
/// Create AOP proxy if necessary or add advice to existing advice chain.
/// </summary>
/// <param name="instance">The new object instance.</param>
/// <param name="objectName">The name of the object.</param>
/// <returns>
/// The object instance to use, wrapped with either the original or a wrapped one.
/// </returns>
/// <exception cref="Spring.Objects.ObjectsException">
/// In case of errors.
/// </exception>
public object PostProcessAfterInitialization(object instance, string objectName)
{
IAdvised advised = instance as IAdvised;
Type targetType;
if (advised != null)
{
targetType = advised.TargetSource.TargetType;
} else
{
targetType = instance.GetType();
}
if (targetType == null)
{
// Can't do much here
return instance;
}
if (AopUtils.CanApply(this.persistenceExceptionTranslationAdvisor, targetType, ReflectionUtils.GetInterfaces(targetType)))
{
if (advised != null)
{
advised.AddAdvisor(this.persistenceExceptionTranslationAdvisor);
return instance;
}
else
{
ProxyFactory proxyFactory = new ProxyFactory(instance);
// copy our properties inherited from ProxyConfig
proxyFactory.CopyFrom(this);
proxyFactory.AddAdvisor(this.persistenceExceptionTranslationAdvisor);
return proxyFactory.GetProxy();
}
} else
{
return instance;
}
}