當前位置: 首頁>>代碼示例>>C#>>正文


C# ProxyFactory.CopyFrom方法代碼示例

本文整理匯總了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();
        }
開發者ID:adamlepkowski,項目名稱:spring-net,代碼行數:54,代碼來源:TransactionProxyFactoryObject.cs

示例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;
            }
        }
開發者ID:spring-projects,項目名稱:spring-net,代碼行數:49,代碼來源:PersistenceExceptionTranslationPostProcessor.cs


注:本文中的Spring.Aop.Framework.ProxyFactory.CopyFrom方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。