Example #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 MemberClassifier(
     ITypeMappingSource typeMappingSource,
     IParameterBindingFactories parameterBindingFactories)
 {
     _typeMappingSource         = typeMappingSource;
     _parameterBindingFactories = parameterBindingFactories;
 }
        /// <summary>
        ///     <para>
        ///         Creates the service dependencies parameter object for a <see cref="CoreConventionSetBuilder" />.
        ///     </para>
        ///     <para>
        ///         Do not call this constructor directly from either provider or application code as it may change
        ///         as new dependencies are added. Instead, use this type in your constructor so that an instance
        ///         will be created and injected automatically by the dependency injection container. To create
        ///         an instance with some dependent services replaced, first resolve the object from the dependency
        ///         injection container, then replace selected services using the 'With...' methods. Do not call
        ///         the constructor at any point in this process.
        ///     </para>
        ///     <para>
        ///         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.
        ///     </para>
        /// </summary>
        public CoreConventionSetBuilderDependencies(
            [NotNull] ICoreTypeMapper typeMapper,
            [CanBeNull] IConstructorBindingFactory constructorBindingFactory,
            [CanBeNull] IParameterBindingFactories parameterBindingFactories,
            [CanBeNull] IDiagnosticsLogger <DbLoggerCategory.Model> logger,
            [CanBeNull] ITypeMapper _ = null) // Only needed for D.I. to resolve this constructor
        {
            Check.NotNull(typeMapper, nameof(typeMapper));

            TypeMapper = typeMapper;

            if (parameterBindingFactories == null)
            {
                parameterBindingFactories = new ParameterBindingFactories(
                    null,
                    new RegisteredServices(Enumerable.Empty <Type>()));
            }

            ParameterBindingFactories = parameterBindingFactories;

            ConstructorBindingFactory = constructorBindingFactory
                                        ?? new ConstructorBindingFactory(
                new PropertyParameterBindingFactory(),
                parameterBindingFactories);

            Logger = logger
                     ?? new DiagnosticsLogger <DbLoggerCategory.Model>(new LoggerFactory(), new LoggingOptions(), new DiagnosticListener(""));
        }
        public ProviderConventionSetBuilderDependencies(
            [NotNull] ITypeMappingSource typeMappingSource,
            [NotNull] IConstructorBindingFactory constructorBindingFactory,
            [NotNull] IParameterBindingFactories parameterBindingFactories,
            [NotNull] IMemberClassifier memberClassifier,
            [NotNull] IDiagnosticsLogger <DbLoggerCategory.Model> logger,
            [NotNull] IDiagnosticsLogger <DbLoggerCategory.Model.Validation> validationLogger,
            [NotNull] IDbSetFinder setFinder,
            [NotNull] ICurrentDbContext currentContext,
            [NotNull] IModelValidator validator)
        {
            Check.NotNull(typeMappingSource, nameof(typeMappingSource));
            Check.NotNull(constructorBindingFactory, nameof(constructorBindingFactory));
            Check.NotNull(parameterBindingFactories, nameof(parameterBindingFactories));
            Check.NotNull(memberClassifier, nameof(memberClassifier));
            Check.NotNull(logger, nameof(logger));
            Check.NotNull(validationLogger, nameof(validationLogger));
            Check.NotNull(setFinder, nameof(setFinder));
            Check.NotNull(validator, nameof(validator));

            TypeMappingSource         = typeMappingSource;
            ParameterBindingFactories = parameterBindingFactories;
            MemberClassifier          = memberClassifier;
            ConstructorBindingFactory = constructorBindingFactory;
            Logger           = logger;
            ValidationLogger = validationLogger;
            SetFinder        = setFinder;
            _currentContext  = currentContext;
            ModelValidator   = validator;
        }
        public static Type FindCandidateNavigationPropertyType(
            this PropertyInfo propertyInfo,
            ITypeMappingSource typeMappingSource,
            IParameterBindingFactories parameterBindingFactories)
        {
            var targetType         = propertyInfo.PropertyType;
            var targetSequenceType = targetType.TryGetSequenceType();

            if (!propertyInfo.IsCandidateProperty(targetSequenceType == null))
            {
                return(null);
            }

            targetType = targetSequenceType ?? targetType;
            targetType = targetType.UnwrapNullableType();

            if (targetType.GetTypeInfo().IsInterface ||
                targetType.GetTypeInfo().IsValueType ||
                targetType == typeof(object) ||
                parameterBindingFactories.FindFactory(propertyInfo.PropertyType, propertyInfo.Name) != null ||
                typeMappingSource.FindMapping(targetType) != null)
            {
                return(null);
            }

            return(targetType);
        }
 /// <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 ConstructorBindingFactory(
     IPropertyParameterBindingFactory propertyFactory,
     IParameterBindingFactories factories)
 {
     _propertyFactory = propertyFactory;
     _factories       = factories;
 }
Example #6
0
 /// <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 InversePropertyAttributeConvention(
     [NotNull] ITypeMappingSource typeMappingSource,
     [NotNull] IParameterBindingFactories parameterBindingFactories,
     [NotNull] IDiagnosticsLogger <DbLoggerCategory.Model> logger)
     : base(typeMappingSource, parameterBindingFactories)
 {
     _logger = logger;
 }
        /// <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>
        protected NavigationAttributeEntityTypeConvention(
            [NotNull] ITypeMappingSource typeMappingSource,
            [NotNull] IParameterBindingFactories parameterBindingFactories)
        {
            Check.NotNull(typeMappingSource, nameof(typeMappingSource));
            Check.NotNull(parameterBindingFactories, nameof(parameterBindingFactories));

            _typeMappingSource         = typeMappingSource;
            _parameterBindingFactories = parameterBindingFactories;
        }
        /// <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 PropertyMappingValidationConvention(
            [NotNull] ITypeMappingSource typeMappingSource,
            [NotNull] IParameterBindingFactories parameterBindingFactories)
        {
            Check.NotNull(typeMappingSource, nameof(typeMappingSource));
            Check.NotNull(parameterBindingFactories, nameof(parameterBindingFactories));

            _typeMappingSource         = typeMappingSource;
            _parameterBindingFactories = parameterBindingFactories;
        }
        /// <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 ServicePropertyDiscoveryConvention(
            [NotNull] ICoreTypeMapper typeMapper,
            [NotNull] IParameterBindingFactories parameterBindingFactories)
        {
            Check.NotNull(typeMapper, nameof(typeMapper));
            Check.NotNull(parameterBindingFactories, nameof(parameterBindingFactories));

            _typeMapper = typeMapper;
            _parameterBindingFactories = parameterBindingFactories;
        }
Example #10
0
        /// <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 PropertyMappingValidationConvention(
            [NotNull] ICoreTypeMapper typeMapper,
            [NotNull] IParameterBindingFactories parameterBindingFactories)
        {
            Check.NotNull(typeMapper, nameof(typeMapper));
            Check.NotNull(parameterBindingFactories, nameof(parameterBindingFactories));

            _typeMapper = typeMapper;
            _parameterBindingFactories = parameterBindingFactories;
        }
Example #11
0
        /// <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>
        protected NavigationAttributeEntityTypeConvention(
            [NotNull] ICoreTypeMapper typeMapper,
            [NotNull] IParameterBindingFactories parameterBindingFactories)
        {
            Check.NotNull(typeMapper, nameof(typeMapper));
            Check.NotNull(parameterBindingFactories, nameof(parameterBindingFactories));

            _typeMapper = typeMapper;
            _parameterBindingFactories = parameterBindingFactories;
        }
        /// <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 ServicePropertyDiscoveryConvention(
            [NotNull] ITypeMappingSource typeMappingSource,
            [NotNull] IParameterBindingFactories parameterBindingFactories)
        {
            Check.NotNull(typeMappingSource, nameof(typeMappingSource));
            Check.NotNull(parameterBindingFactories, nameof(parameterBindingFactories));

            _typeMappingSource         = typeMappingSource;
            _parameterBindingFactories = parameterBindingFactories;
        }
        /// <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 MemberClassifier(
            [NotNull] ITypeMappingSource typeMappingSource,
            [NotNull] IParameterBindingFactories parameterBindingFactories)
        {
            Check.NotNull(typeMappingSource, nameof(typeMappingSource));
            Check.NotNull(parameterBindingFactories, nameof(parameterBindingFactories));

            _typeMappingSource         = typeMappingSource;
            _parameterBindingFactories = parameterBindingFactories;
        }
Example #14
0
        /// <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 ServicePropertyDiscoveryConvention(
            [NotNull] ITypeMappingSource typeMappingSource,
            [NotNull] IParameterBindingFactories parameterBindingFactories,
            [NotNull] IDiagnosticsLogger <DbLoggerCategory.Model> logger)
        {
            Check.NotNull(typeMappingSource, nameof(typeMappingSource));
            Check.NotNull(parameterBindingFactories, nameof(parameterBindingFactories));

            _typeMappingSource         = typeMappingSource;
            _parameterBindingFactories = parameterBindingFactories;
            Logger = logger;
        }
        /// <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 RelationshipDiscoveryConvention(
            [NotNull] ICoreTypeMapper typeMapper,
            [NotNull] IParameterBindingFactories parameterBindingFactories,
            [NotNull] IDiagnosticsLogger <DbLoggerCategory.Model> logger)
        {
            Check.NotNull(typeMapper, nameof(typeMapper));
            Check.NotNull(parameterBindingFactories, nameof(parameterBindingFactories));

            _typeMapper = typeMapper;
            _parameterBindingFactories = parameterBindingFactories;
            _logger = logger;
        }
        /// <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 ForeignKeyAttributeConvention(
            [NotNull] ITypeMappingSource typeMappingSource,
            [NotNull] IParameterBindingFactories parameterBindingFactories,
            [NotNull] IDiagnosticsLogger <DbLoggerCategory.Model> logger)
        {
            Check.NotNull(typeMappingSource, nameof(typeMappingSource));
            Check.NotNull(parameterBindingFactories, nameof(parameterBindingFactories));

            _typeMappingSource         = typeMappingSource;
            _parameterBindingFactories = parameterBindingFactories;
            _logger = logger;
        }
        /// <summary>
        ///     <para>
        ///         Creates the service dependencies parameter object for a <see cref="ProviderConventionSetBuilder" />.
        ///     </para>
        ///     <para>
        ///         Do not call this constructor directly from either provider or application code as it may change
        ///         as new dependencies are added. Instead, use this type in your constructor so that an instance
        ///         will be created and injected automatically by the dependency injection container. To create
        ///         an instance with some dependent services replaced, first resolve the object from the dependency
        ///         injection container, then replace selected services using the 'With...' methods. Do not call
        ///         the constructor at any point in this process.
        ///     </para>
        ///     <para>
        ///         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.
        ///     </para>
        /// </summary>
        /// <param name="typeMappingSource"> The type mapping source. </param>
        /// <param name="constructorBindingFactory"> The constructor binding factory. </param>
        /// <param name="parameterBindingFactories"> The parameter binding factories. </param>
        /// <param name="memberClassifier"> The member classifier. </param>
        /// <param name="logger"> The model logger. </param>
        /// <param name="setFinder"> The set finder. </param>
        /// <param name="context"> The current context instance. </param>
        public ProviderConventionSetBuilderDependencies(
            [NotNull] ITypeMappingSource typeMappingSource,
            [CanBeNull] IConstructorBindingFactory constructorBindingFactory,
            [CanBeNull] IParameterBindingFactories parameterBindingFactories,
            [CanBeNull] IMemberClassifier memberClassifier,
            [CanBeNull] IDiagnosticsLogger <DbLoggerCategory.Model> logger,
            [CanBeNull] IDbSetFinder setFinder,
            [CanBeNull] ICurrentDbContext context)
        {
            Check.NotNull(typeMappingSource, nameof(typeMappingSource));

            TypeMappingSource = typeMappingSource;

            if (parameterBindingFactories == null)
            {
                parameterBindingFactories = new ParameterBindingFactories(
                    null,
                    new RegisteredServices(Enumerable.Empty <Type>()));
            }

            ParameterBindingFactories = parameterBindingFactories;

            if (memberClassifier == null)
            {
                memberClassifier = new MemberClassifier(
                    typeMappingSource,
                    parameterBindingFactories);
            }

            MemberClassifier = memberClassifier;

            if (constructorBindingFactory == null)
            {
                ConstructorBindingFactory = new ConstructorBindingFactory(
                    new PropertyParameterBindingFactory(),
                    parameterBindingFactories);
            }

            ConstructorBindingFactory = constructorBindingFactory;

            Logger = logger
                     ?? new DiagnosticsLogger <DbLoggerCategory.Model>(
                new ScopedLoggerFactory(new LoggerFactory(), dispose: true),
                new LoggingOptions(),
                new DiagnosticListener(""),
                new LoggingDefinitions());

            SetFinder = setFinder;
            Context   = context;
        }
Example #18
0
        /// <summary>
        ///     <para>
        ///         Creates the service dependencies parameter object for a <see cref="CoreConventionSetBuilder" />.
        ///     </para>
        ///     <para>
        ///         Do not call this constructor directly from either provider or application code as it may change
        ///         as new dependencies are added. Instead, use this type in your constructor so that an instance
        ///         will be created and injected automatically by the dependency injection container. To create
        ///         an instance with some dependent services replaced, first resolve the object from the dependency
        ///         injection container, then replace selected services using the 'With...' methods. Do not call
        ///         the constructor at any point in this process.
        ///     </para>
        ///     <para>
        ///         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.
        ///     </para>
        /// </summary>
        public CoreConventionSetBuilderDependencies(
            [NotNull] ITypeMappingSource typeMappingSource,
            [CanBeNull] IConstructorBindingFactory constructorBindingFactory,
            [CanBeNull] IParameterBindingFactories parameterBindingFactories,
            [CanBeNull] IMemberClassifier memberClassifier,
            [CanBeNull] IDiagnosticsLogger <DbLoggerCategory.Model> logger,
#pragma warning disable 618
            [CanBeNull] ITypeMapper _ = null) // Only needed for D.I. to resolve this constructor
#pragma warning restore 618
        {
            Check.NotNull(typeMappingSource, nameof(typeMappingSource));

            TypeMappingSource = typeMappingSource;

            if (parameterBindingFactories == null)
            {
                parameterBindingFactories = new ParameterBindingFactories(
                    null,
                    new RegisteredServices(Enumerable.Empty <Type>()));
            }

            ParameterBindingFactories = parameterBindingFactories;

            if (memberClassifier == null)
            {
                memberClassifier = new MemberClassifier(
                    typeMappingSource,
                    parameterBindingFactories);
            }

            MemberClassifier = memberClassifier;

            if (constructorBindingFactory == null)
            {
                ConstructorBindingFactory = new ConstructorBindingFactory(
                    new PropertyParameterBindingFactory(),
                    parameterBindingFactories);
            }

            ConstructorBindingFactory = constructorBindingFactory;

            Logger = logger
                     ?? new DiagnosticsLogger <DbLoggerCategory.Model>(new LoggerFactory(), new LoggingOptions(), new DiagnosticListener(""));
        }
Example #19
0
        /// <summary>
        ///     <para>
        ///         Creates the service dependencies parameter object for a <see cref="CoreConventionSetBuilder" />.
        ///     </para>
        ///     <para>
        ///         Do not call this constructor directly from either provider or application code as it may change
        ///         as new dependencies are added. Instead, use this type in your constructor so that an instance
        ///         will be created and injected automatically by the dependency injection container. To create
        ///         an instance with some dependent services replaced, first resolve the object from the dependency
        ///         injection container, then replace selected services using the 'With...' methods. Do not call
        ///         the constructor at any point in this process.
        ///     </para>
        ///     <para>
        ///         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.
        ///     </para>
        /// </summary>
        public CoreConventionSetBuilderDependencies(
            [NotNull] ITypeMappingSource typeMappingSource,
            [CanBeNull] IConstructorBindingFactory constructorBindingFactory,
            [CanBeNull] IParameterBindingFactories parameterBindingFactories,
            [CanBeNull] IMemberClassifier memberClassifier)
        {
            Check.NotNull(typeMappingSource, nameof(typeMappingSource));

            TypeMappingSource = typeMappingSource;

            if (parameterBindingFactories == null)
            {
                parameterBindingFactories = new ParameterBindingFactories(
                    null,
                    new RegisteredServices(Enumerable.Empty <Type>()));
            }

            ParameterBindingFactories = parameterBindingFactories;

            if (memberClassifier == null)
            {
                memberClassifier = new MemberClassifier(
                    typeMappingSource,
                    parameterBindingFactories);
            }

            MemberClassifier = memberClassifier;

            if (constructorBindingFactory == null)
            {
                ConstructorBindingFactory = new ConstructorBindingFactory(
                    new PropertyParameterBindingFactory(),
                    parameterBindingFactories);
            }

            ConstructorBindingFactory = constructorBindingFactory;
        }
 /// <summary>
 ///     Clones this dependency parameter object with one service replaced.
 /// </summary>
 /// <param name="parameterBindingFactories"> A replacement for the current dependency of this type. </param>
 /// <returns> A new parameter object with the given service replaced. </returns>
 public CoreConventionSetBuilderDependencies With([NotNull] IParameterBindingFactories parameterBindingFactories)
 => new CoreConventionSetBuilderDependencies(TypeMapper, ConstructorBindingFactory, parameterBindingFactories, Logger);
 /// <summary>
 ///     Clones this dependency parameter object with one service replaced.
 /// </summary>
 /// <param name="parameterBindingFactories"> A replacement for the current dependency of this type. </param>
 /// <returns> A new parameter object with the given service replaced. </returns>
 public ProviderConventionSetBuilderDependencies With([NotNull] IParameterBindingFactories parameterBindingFactories)
 => new ProviderConventionSetBuilderDependencies(
     TypeMappingSource, ConstructorBindingFactory, parameterBindingFactories, MemberClassifier, Logger, ValidationLogger,
     SetFinder, _currentContext, ModelValidator);
Example #22
0
 /// <summary>
 ///     Clones this dependency parameter object with one service replaced.
 /// </summary>
 /// <param name="parameterBindingFactories"> A replacement for the current dependency of this type. </param>
 /// <returns> A new parameter object with the given service replaced. </returns>
 public CoreConventionSetBuilderDependencies With([NotNull] IParameterBindingFactories parameterBindingFactories)
 => new CoreConventionSetBuilderDependencies(
     TypeMappingSource, ConstructorBindingFactory, parameterBindingFactories, MemberClassifier, Logger);