private ProxyGenerationOptions CreateProxyGenerationOptions(Type type, MockCreationSettings settings, MockMixin mockMixinImpl = null)
		{
			var options = new ProxyGenerationOptions();
			if (mockMixinImpl != null)
				options.AddMixinInstance(mockMixinImpl);
			foreach (var mixin in settings.Mixins)
				options.AddMixinInstance(mixin);

			if (settings.AdditionalProxyTypeAttributes != null)
			{
				foreach (var attr in settings.AdditionalProxyTypeAttributes)
				{
					options.AdditionalAttributes.Add(attr);
				}
			}

			return options;
		}
Esempio n. 2
0
        private ProxyGenerationOptions CreateProxyGenerationOptions(Type type, MockCreationSettings settings, MockMixin mockMixinImpl = null)
        {
            var options = new ProxyGenerationOptions();

            if (mockMixinImpl != null)
            {
                options.AddMixinInstance(mockMixinImpl);
            }
            foreach (var mixin in settings.Mixins)
            {
                options.AddMixinInstance(mixin);
            }

            if (settings.AdditionalProxyTypeAttributes != null)
            {
                foreach (var attr in settings.AdditionalProxyTypeAttributes)
                {
                    options.AdditionalAttributes.Add(attr);
                }
            }

            return(options);
        }
		public ProxyTypeInfo CreateClassProxyType(Type classToProxy, MocksRepository repository, MockCreationSettings settings, MockMixin mockMixinImpl)
		{
			var pgo = CreateProxyGenerationOptions(classToProxy, settings, mockMixinImpl);
			var typeInfo = new ProxyTypeInfo
			{
				ProxyType = generator.ProxyBuilder.CreateClassProxyType(classToProxy, Type.EmptyTypes, pgo)
			};
			typeInfo.Mixins.Add(typeof(IInterceptor), repository.Interceptor);
			foreach (var mixin in pgo.MixinData.MixinInterfaces)
			{
				typeInfo.Mixins.Add(mixin, pgo.MixinData.GetMixinInstance(mixin));
			}
			return typeInfo;
		}
Esempio n. 4
0
        public ProxyTypeInfo CreateClassProxyType(Type classToProxy, MocksRepository repository, MockCreationSettings settings, MockMixin mockMixinImpl)
        {
            var pgo      = CreateProxyGenerationOptions(classToProxy, settings, mockMixinImpl);
            var typeInfo = new ProxyTypeInfo
            {
                ProxyType = generator.ProxyBuilder.CreateClassProxyType(classToProxy, Type.EmptyTypes, pgo)
            };

            typeInfo.Mixins.Add(typeof(IInterceptor), new DynamicProxyInterceptor(repository));
            foreach (var mixin in pgo.MixinData.MixinInterfaces)
            {
                typeInfo.Mixins.Add(mixin, pgo.MixinData.GetMixinInstance(mixin));
            }
            return(typeInfo);
        }