Exemple #1
0
        protected void SetupProxy(Guid id, IEnumerable <string> fieldNames, IProxyTargetAccessor target)
        {
            var searchInterceptor = target.GetInterceptors().FirstOrDefault(x => x is SearchInterceptor) as SearchInterceptor;

            if (searchInterceptor == null)
            {
                return;
            }

            searchInterceptor.Id = new ID(id);
            searchInterceptor.TypeConfiguration = _sitecoreContext.GlassContext.GetTypeConfiguration <SitecoreTypeConfiguration>(target);
            searchInterceptor.IndexFields       = fieldNames;
        }
Exemple #2
0
        protected void SetupProxy(ID id, IDictionary <string, object> fieldValues, IProxyTargetAccessor target)
        {
            if (target == null)
            {
                return;
            }
            var searchInterceptor = target.GetInterceptors().FirstOrDefault(x => x is SearchInterceptor) as SearchInterceptor;

            if (searchInterceptor == null)
            {
                return;
            }

            searchInterceptor.Id = id;
            searchInterceptor.TypeConfiguration = new SitecoreContext().GlassContext.GetTypeConfiguration <SitecoreTypeConfiguration>(target);
        }
Exemple #3
0
        public Object PostProcessBean(IBeanContextFactory beanContextFactory, IServiceContext beanContext, IBeanConfiguration beanConfiguration, Type beanType, Object targetBean, ISet <Type> requestedTypes)
        {
            IProxyTargetAccessor factory             = null;
            ICascadedInterceptor cascadedInterceptor = null;
            Object proxiedTargetBean = targetBean;

            if (targetBean is IProxyTargetAccessor)
            {
                factory = (IProxyTargetAccessor)targetBean;
                IInterceptor[] interceptors = factory.GetInterceptors();
                IInterceptor   callback     = (interceptors != null && interceptors.Length > 0 ? interceptors[0] : null);
                if (callback is ICascadedInterceptor)
                {
                    cascadedInterceptor = (ICascadedInterceptor)callback;
                    proxiedTargetBean   = cascadedInterceptor.Target;
                }
            }
            ICascadedInterceptor interceptor = HandleServiceIntern(beanContextFactory, beanContext, beanConfiguration, proxiedTargetBean.GetType(), requestedTypes);

            if (interceptor == null)
            {
                return(targetBean);
            }
            if (log.DebugEnabled)
            {
                log.Debug("Proxying bean with name '" + beanConfiguration.GetName() + "' by " + GetType().FullName);
            }
            Object target;

            if (cascadedInterceptor != null)
            {
                target = cascadedInterceptor;
            }
            else
            {
                target = proxiedTargetBean;
            }
            interceptor.Target = target;
            Object proxy = ProxyFactory.CreateProxy(requestedTypes.ToArray(), interceptor);

            postHandleServiceIntern(beanContextFactory, beanContext, beanConfiguration, proxiedTargetBean.GetType(), requestedTypes, proxy);
            return(proxy);
        }
Exemple #4
0
        /// <summary>
        /// 判断一个对象是不是动态实现类
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static bool IsDynamicImplemented(this object value)
        {
            if (!(value is IProxyTargetAccessor))
            {
                return(false);
            }
            IProxyTargetAccessor proxyTargetAccessor = value as IProxyTargetAccessor;

            IInterceptor[] interceptors = proxyTargetAccessor.GetInterceptors();
            if (interceptors == null)
            {
                return(false);
            }
            IEnumerable <ImplementorAttributeExecuteInterceptor> myInterceptor
                = interceptors.OfType <ImplementorAttributeExecuteInterceptor>();

            if (!myInterceptor.Any())
            {
                return(false);
            }
            return(true);
        }
Exemple #5
0
 public static IEnumerable <T> GetInterceptors <T>(IProxyTargetAccessor item)
     where T : IInterceptor
 {
     return(item.GetInterceptors().Where(x => x is T).Cast <T>());
 }
        public static CommonData GetCommonData(this IProxyTargetAccessor accessor)
        {
            var interceptor = accessor.GetInterceptors().SingleOrDefault(x => x is GeneralGetInterceptor) as GeneralGetInterceptor;

            return(interceptor?.GetCommonData());
        }