Exemple #1
0
        protected virtual IEnumerable <Type> GetTypeImplementerMapping(out IEnumerable <ITypeContributor> contributors,
                                                                       INamingScope namingScope)
        {
            var methodsToSkip = new List <MethodInfo>();
            var proxyInstance = new ClassProxyInstanceContributor(targetType, methodsToSkip, Type.EmptyTypes,
                                                                  ProxyTypeConstants.ClassWithTarget);
            var proxyTarget = new DelegateProxyTargetContributor(targetType, namingScope)
            {
                Logger = Logger
            };
            IDictionary <Type, ITypeContributor> typeImplementerMapping = new Dictionary <Type, ITypeContributor>();

            // Order of interface precedence:
            // 1. first target, target is not an interface so we do nothing
            // 2. then mixins - we support none so we do nothing
            // 3. then additional interfaces - we support none so we do nothing
#if !SILVERLIGHT
            // 4. plus special interfaces
            if (targetType.IsSerializable)
            {
                AddMappingForISerializable(typeImplementerMapping, proxyInstance);
            }
#endif
            AddMappingNoCheck(typeof(IProxyTargetAccessor), proxyInstance, typeImplementerMapping);

            contributors = new List <ITypeContributor>
            {
                proxyTarget,
                proxyInstance
            };
            return(typeImplementerMapping.Keys);
        }
		protected virtual IEnumerable<Type> GetTypeImplementerMapping(out IEnumerable<ITypeContributor> contributors,
		                                                              INamingScope namingScope)
		{
			var methodsToSkip = new List<MethodInfo>();
			var proxyInstance = new ClassProxyInstanceContributor(targetType, methodsToSkip, Type.EmptyTypes,
			                                                      ProxyTypeConstants.ClassWithTarget);
			var proxyTarget = new DelegateProxyTargetContributor(targetType, namingScope) { Logger = Logger };
			IDictionary<Type, ITypeContributor> typeImplementerMapping = new Dictionary<Type, ITypeContributor>();

			// Order of interface precedence:
			// 1. first target, target is not an interface so we do nothing
			// 2. then mixins - we support none so we do nothing
			// 3. then additional interfaces - we support none so we do nothing
#if !SILVERLIGHT
			// 4. plus special interfaces
			if (targetType.IsSerializable)
			{
				AddMappingForISerializable(typeImplementerMapping, proxyInstance);
			}
#endif
			AddMappingNoCheck(typeof(IProxyTargetAccessor), proxyInstance, typeImplementerMapping);

			contributors = new List<ITypeContributor>
			{
				proxyTarget,
				proxyInstance
			};
			return typeImplementerMapping.Keys;
		}