/// <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);
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()); }
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; }
private object CreateProxy( ProxiesOptionsExtension options, IEntityType entityType, object[] constructorArguments) => _generator.CreateClassProxy( entityType.ClrType, GetInterfacesToProxy(options, entityType), ProxyGenerationOptions.Default, constructorArguments, GetNotifyChangeInterceptors(options, entityType));
/// <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); }
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()); }
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()); }
/// <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; }
/// <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; }
/// <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; }
/// <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; }