Esempio n. 1
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public virtual Type CreateProxyType(
     ProxiesOptionsExtension options,
     IEntityType entityType)
 => _generator.ProxyBuilder.CreateClassProxyType(
     entityType.ClrType,
     GetInterfacesToProxy(options, entityType),
     ProxyGenerationOptions.Default);
Esempio n. 2
0
        private IInterceptor[] GetNotifyChangeInterceptors(
            ProxiesOptionsExtension options,
            IEntityType entityType,
            LazyLoadingInterceptor lazyLoadingInterceptor = null)
        {
            var interceptors = new List <IInterceptor>();

            if (lazyLoadingInterceptor != null)
            {
                interceptors.Add(lazyLoadingInterceptor);
            }

            if (options.UseChangeTrackingProxies)
            {
                if (!_notifyPropertyChangedInterface.IsAssignableFrom(entityType.ClrType))
                {
                    interceptors.Add(new PropertyChangedInterceptor(entityType, options.CheckEquality));
                }

                if (!_notifyPropertyChangingInterface.IsAssignableFrom(entityType.ClrType))
                {
                    interceptors.Add(new PropertyChangingInterceptor(entityType, options.CheckEquality));
                }
            }

            return(interceptors.ToArray());
        }
Esempio n. 3
0
        private Type[] GetInterfacesToProxy(
            ProxiesOptionsExtension options,
            IEntityType entityType)
        {
            var interfacesToProxy = new List <Type>();

            if (options.UseLazyLoadingProxies)
            {
                interfacesToProxy.Add(_proxyLazyLoaderInterface);
            }

            if (options.UseChangeTrackingProxies)
            {
                if (!_notifyPropertyChangedInterface.IsAssignableFrom(entityType.ClrType))
                {
                    interfacesToProxy.Add(_notifyPropertyChangedInterface);
                }

                if (!_notifyPropertyChangingInterface.IsAssignableFrom(entityType.ClrType))
                {
                    interfacesToProxy.Add(_notifyPropertyChangingInterface);
                }
            }

            return(interfacesToProxy.ToArray());
        }
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public ProxyBindingRewriter(
     [NotNull] IProxyFactory proxyFactory,
     [NotNull] IConstructorBindingFactory bindingFactory,
     [CanBeNull] ProxiesOptionsExtension options)
 {
     _directBindingConvention = new ConstructorBindingConvention(bindingFactory);
     _proxyFactory            = proxyFactory;
     _options = options;
 }
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public ProxyBindingRewriter(
     [NotNull] IProxyFactory proxyFactory,
     [NotNull] IConstructorBindingFactory bindingFactory,
     [NotNull] IDiagnosticsLogger <DbLoggerCategory.Model> logger,
     [CanBeNull] ProxiesOptionsExtension options)
 {
     _directBindingConvention = new ConstructorBindingConvention(bindingFactory, logger);
     _proxyFactory            = proxyFactory;
     _options = options;
 }
Esempio n. 6
0
 private object CreateProxy(
     ProxiesOptionsExtension options,
     IEntityType entityType,
     object[] constructorArguments)
 => _generator.CreateClassProxy(
     entityType.ClrType,
     GetInterfacesToProxy(options, entityType),
     ProxyGenerationOptions.Default,
     constructorArguments,
     GetNotifyChangeInterceptors(options, entityType));
Esempio n. 7
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public ProxyBindingRewriter(
     [NotNull] IProxyFactory proxyFactory,
     [CanBeNull] ProxiesOptionsExtension options,
     [NotNull] LazyLoaderParameterBindingFactoryDependencies lazyLoaderParameterBindingFactoryDependencies,
     [NotNull] ProviderConventionSetBuilderDependencies conventionSetBuilderDependencies)
 {
     _proxyFactory = proxyFactory;
     _options      = options;
     _lazyLoaderParameterBindingFactoryDependencies = lazyLoaderParameterBindingFactoryDependencies;
     _directBindingConvention = new ConstructorBindingConvention(conventionSetBuilderDependencies);
 }
Esempio n. 8
0
        private Castle.DynamicProxy.IInterceptor[] GetNotifyChangeInterceptors(
            ProxiesOptionsExtension options,
            IEntityType entityType,
            LazyLoadingInterceptor lazyLoadingInterceptor = null)
        {
            var interceptors = new List <Castle.DynamicProxy.IInterceptor>();

            if (lazyLoadingInterceptor != null)
            {
                interceptors.Add(lazyLoadingInterceptor);
            }

            if (options.UseChangeDetectionProxies)
            {
                var changeTrackingStrategy = entityType.GetChangeTrackingStrategy();
                switch (changeTrackingStrategy)
                {
                case ChangeTrackingStrategy.ChangedNotifications:

                    if (!_notifyPropertyChangedInterface.IsAssignableFrom(entityType.ClrType))
                    {
                        interceptors.Add(new PropertyChangedInterceptor(entityType, options.CheckEquality));
                    }

                    break;

                case ChangeTrackingStrategy.ChangingAndChangedNotifications:
                case ChangeTrackingStrategy.ChangingAndChangedNotificationsWithOriginalValues:

                    if (!_notifyPropertyChangedInterface.IsAssignableFrom(entityType.ClrType))
                    {
                        interceptors.Add(new PropertyChangedInterceptor(entityType, options.CheckEquality));
                    }

                    if (!_notifyPropertyChangingInterface.IsAssignableFrom(entityType.ClrType))
                    {
                        interceptors.Add(new PropertyChangingInterceptor(entityType, options.CheckEquality));
                    }

                    break;

                default:
                    break;
                }
            }

            return(interceptors.ToArray());
        }
Esempio n. 9
0
        private Type[] GetInterfacesToProxy(
            ProxiesOptionsExtension options,
            IEntityType entityType)
        {
            var interfacesToProxy = new List <Type>();

            if (options.UseLazyLoadingProxies)
            {
                interfacesToProxy.Add(_proxyLazyLoaderInterface);
            }

            if (options.UseChangeDetectionProxies)
            {
                var changeTrackingStrategy = entityType.GetChangeTrackingStrategy();
                switch (changeTrackingStrategy)
                {
                case ChangeTrackingStrategy.ChangedNotifications:

                    if (!_notifyPropertyChangedInterface.IsAssignableFrom(entityType.ClrType))
                    {
                        interfacesToProxy.Add(_notifyPropertyChangedInterface);
                    }

                    break;

                case ChangeTrackingStrategy.ChangingAndChangedNotifications:
                case ChangeTrackingStrategy.ChangingAndChangedNotificationsWithOriginalValues:

                    if (!_notifyPropertyChangedInterface.IsAssignableFrom(entityType.ClrType))
                    {
                        interfacesToProxy.Add(_notifyPropertyChangedInterface);
                    }

                    if (!_notifyPropertyChangingInterface.IsAssignableFrom(entityType.ClrType))
                    {
                        interfacesToProxy.Add(_notifyPropertyChangingInterface);
                    }

                    break;

                default:
                    break;
                }
            }

            return(interfacesToProxy.ToArray());
        }
Esempio n. 10
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 protected ProxiesOptionsExtension(ProxiesOptionsExtension copyFrom)
 {
     _useLazyLoadingProxies    = copyFrom._useLazyLoadingProxies;
     _useChangeTrackingProxies = copyFrom._useChangeTrackingProxies;
     _checkEquality            = copyFrom._checkEquality;
 }
Esempio n. 11
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 protected ProxiesOptionsExtension([NotNull] ProxiesOptionsExtension copyFrom)
 {
     _useLazyLoadingProxies = copyFrom._useLazyLoadingProxies;
 }
Esempio n. 12
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public ProxyChangeTrackingConvention(
     [CanBeNull] ProxiesOptionsExtension options)
 {
     _options = options;
 }
Esempio n. 13
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 protected ProxiesOptionsExtension([NotNull] ProxiesOptionsExtension copyFrom)
 {
     _useLazyLoadingProxies     = copyFrom._useLazyLoadingProxies;
     _useChangeDetectionProxies = copyFrom._useChangeDetectionProxies;
     _checkEquality             = copyFrom._checkEquality;
 }