/// <summary> /// Enables code-based conventions for an API. /// </summary> /// <param name="services"> /// The <see cref="IServiceCollection"/> containing API service registrations. /// </param> /// <param name="targetType"> /// The type of a class on which code-based conventions are used. /// </param> /// <remarks> /// This method adds hook points to the API configuration that /// inspect a target type for a variety of code-based conventions /// such as usage of specific attributes or members that follow /// certain naming conventions. /// </remarks> private static void EnableConventions( IServiceCollection services, Type targetType) { Ensure.NotNull(services, "services"); Ensure.NotNull(targetType, "targetType"); ConventionBasedChangeSetAuthorizer.ApplyTo(services, targetType); ConventionBasedChangeSetEntryFilter.ApplyTo(services, targetType); services.CutoffPrevious <IChangeSetEntryValidator, ConventionBasedChangeSetEntryValidator>(); ConventionBasedApiModelBuilder.ApplyTo(services, targetType); ConventionBasedOperationProvider.ApplyTo(services, targetType); ConventionBasedEntitySetFilter.ApplyTo(services, targetType); }
/// <summary> /// Enables code-based conventions for an API. /// </summary> /// <param name="configuration"> /// An API configuration. /// </param> /// <param name="targetType"> /// The type of a class on which code-based conventions are used. /// </param> /// <remarks> /// This method adds hook points to the API configuration that /// inspect a target type for a variety of code-based conventions /// such as usage of specific attributes or members that follow /// certain naming conventions. /// </remarks> private static void EnableConventions( ApiConfiguration configuration, Type targetType) { Ensure.NotNull(configuration, "configuration"); Ensure.NotNull(targetType, "targetType"); ConventionBasedChangeSetAuthorizer.ApplyTo(configuration, targetType); ConventionBasedChangeSetEntryFilter.ApplyTo(configuration, targetType); configuration.AddHookHandler <IChangeSetEntryValidator>(ConventionBasedChangeSetEntryValidator.Instance); ConventionBasedApiModelBuilder.ApplyTo(configuration, targetType); ConventionBasedOperationProvider.ApplyTo(configuration, targetType); ConventionBasedEntitySetFilter.ApplyTo(configuration, targetType); }