Default implementation of IProxyBuilder interface producing in-memory proxy assemblies.
Inheritance: IProxyBuilder
示例#1
0
        private void RegisterServices()
        {
            Container.RegisterType<IRegionNavigationContentLoader, SecureRegionNavigationContentLoader> ();
            Container.RegisterType<IDtoFactory, DtoFactory> ();
            Container.RegisterType<IUserDialogService, UserDialogService> ();
            Container.RegisterType<IPopupService, PopupService> ( new ContainerControlledLifetimeManager () );
            Container.RegisterType<IRedirectService, RedirectService> ();
            Container.RegisterType<INotificationService, NotificationService> ();
            Container.RegisterType<INavigationService, NavigationService> ();
            Container.RegisterType<ShellLoader, ShellLoader> ();

            var proxyBuilder = new DefaultProxyBuilder(new ModuleScope(false, true));
            Container.RegisterInstance ( typeof( ProxyGenerator ), new ProxyGenerator ( proxyBuilder ), new ContainerControlledLifetimeManager () );

            ConfigureAgatha ();
            ConfigureSercurity ();

            var metadataService = Container.Resolve<MetadataService> ();
            Container.RegisterInstance<IMetadataService> ( metadataService );
            Container.RegisterType<IMetadataItemApplicatorService, MetadataItemApplicatorService> ();
        }
 public EventsRegistrationSource()
 {
     _proxyBuilder = new DefaultProxyBuilder();
 }
        private Type GetProxyType(CompositeType compositeType)
        {
            if (!cachedProxyTypes.ContainsKey(compositeType))
            {
                var proxyBuilder = new DefaultProxyBuilder();
                Type[] additionalInterfaceTypes =
                    BuildAdditionalTypeArrayForProxyType(compositeType.AdditionalInterfaceTypes);
                Type proxyType;

                if (compositeType.PrimaryType.IsClass)
                {
                    if (compositeType.PrimaryType.IsSealed)
                    {
                        throw new ArgumentException("Cannot mock sealed classes.");
                    }

                    proxyType = proxyBuilder.CreateClassProxy(
                        compositeType.PrimaryType,
                        additionalInterfaceTypes,
                        ProxyGenerationOptions.Default);
                }
                else
                {
                    proxyType = proxyBuilder.CreateInterfaceProxyTypeWithoutTarget(
                        compositeType.PrimaryType,
                        additionalInterfaceTypes,
                        new ProxyGenerationOptions { BaseTypeForInterfaceProxy = typeof(InterfaceMockBase) });
                }

                cachedProxyTypes[compositeType] = proxyType;
            }

            return cachedProxyTypes[compositeType];
        }