/// <summary> /// Register the services. /// </summary> /// <param name="registration">The <see cref="IServiceRegistration"/> provider.</param> public void RegisterDefaultServices(IServiceRegistration registration) { registration.RegisterSingleton <IClientHttpConfiguration>(new ClientHttpConfiguration()); registration.RegisterSingleton <IRemoteQueryResolver>(new HttpRemoteQueryResolver()); registration.RegisterSingleton <Func <JsonSerializerOptions> >( () => new JsonSerializerOptions { IgnoreNullValues = true, IgnoreReadOnlyProperties = true, }); }
/// <summary> /// Register defaults for project. /// </summary> /// <param name="registration">The <see cref="IServiceRegistration"/>.</param> public void RegisterDefaultServices(IServiceRegistration registration) { registration.RegisterSingleton <IDbContextAdapter>( new DbContextAdapter()); registration.RegisterSingleton <IRouteProcessor>( new RouteProcessor()); registration.RegisterSingleton <IQueryDeserializer>( new QueryDeserializer()); registration.RegisterSingleton <IQueryResultSerializer>( new QueryResultSerializer()); }
/// <summary> /// Registers the services used by serialization. /// </summary> /// <param name="registration">The <see cref="IServiceRegistration"/> to register with.</param> public void RegisterDefaultServices(IServiceRegistration registration) { registration.RegisterSingleton <IReflectionHelper>( new ReflectionHelper()); registration.Register <IConfigurationBuilder, ConfigurationBuilder>(); registration.RegisterSingleton <IDefaultConfiguration>(new DefaultConfiguration()); var rules = new RulesEngine(); registration.RegisterSingleton <IRulesEngine>(rules); registration.RegisterSingleton <IRulesConfiguration>(rules); registration.RegisterSingleton <IAnonymousTypeAdapter>(new AnonymousTypeAdapter()); }
public void Register(IServiceRegistration services, IDictionary <string, object> data) { services.RegisterSingleton(r => r .Types(t => t.AssignableTo <IValidator>()) .As(s => s.Self().ImplementedInterfaces()) ); }
/// <summary> /// Register defaults for project. /// </summary> /// <param name="registration">The <see cref="IServiceRegistration"/>.</param> public void RegisterDefaultServices(IServiceRegistration registration) { registration.RegisterSingleton <IDbContextAdapter>( new DbContextAdapter()); registration.RegisterSingleton <IRouteProcessor>( new RouteProcessor()); registration.RegisterSingleton <IQueryDeserializer>( new QueryDeserializer()); registration.RegisterSingleton <IQueryResultSerializer>( new QueryResultSerializer()); registration.RegisterSingleton <Func <JsonSerializerOptions> >( () => new JsonSerializerOptions { IgnoreNullValues = true, IgnoreReadOnlyProperties = true, }); }
/// <summary> /// Registers a singleton service of the type specified in <typeparamref name="TService"/> to the /// specified <see cref="IServiceRegistration"/>. /// </summary> /// <typeparam name="TService">The type of the service to add.</typeparam> /// <param name="services">The <see cref="IServiceRegistration"/> to add the service to.</param> /// <returns>A reference to this instance after the operation has completed.</returns> /// <seealso cref="ServiceLifetime.Singleton"/> public static IServiceRegistration RegisterSingleton <TService>(this IServiceRegistration services) where TService : class { if (services == null) { throw new ArgumentNullException(nameof(services)); } return(services.RegisterSingleton(typeof(TService))); }
public void Register(IServiceRegistration services, IDictionary <string, object> data) { services.RegisterSingleton <IConnection, SampleConnection>(); services.RegisterTransient <IUserService, UserService>(c => new UserService(c.GetService <IConnection>())); services.RegisterSingleton(r => r .Types(t => t.AssignableTo(typeof(IReadOnlyRepository <>))) .As(s => s.Self().ImplementedInterfaces()) ); services.RegisterSingleton(r => r .Types(t => t.AssignableTo <IService>()) .As(s => s.Self().ImplementedInterfaces()) ); services.RegisterSingleton(r => r .Types(t => t.AssignableTo <IVehicle>()) .As(s => s.Self().ImplementedInterfaces()) ); }
/// <summary> /// Registers the default instances. /// </summary> private static void RegisterDefaults(IServiceRegistration register) { var evaluator = new ExpressionEvaluator(); register.RegisterSingleton(Services) .RegisterSingleton(DefaultRules) .RegisterSingleton <IExpressionEvaluator>(evaluator) .RegisterSingleton <IMemberAdapter>(new MemberAdapter()) .Register <IExpressionEnumerator, ExpressionEnumerator>() .RegisterGeneric(typeof(IQuerySnapshotHost <>), typeof(QuerySnapshotHost <>)) .RegisterGeneric(typeof(IQueryHost <,>), typeof(QueryHost <,>)) .RegisterGeneric(typeof(IQueryInterceptingProvider <>), typeof(QueryInterceptingProvider <>)) .RegisterGeneric(typeof(IQuerySnapshotProvider <>), typeof(QuerySnapshotProvider <>)); }
/// <summary> /// Registers a singleton service of the type specified in <paramref name="serviceType"/> to the /// specified <see cref="IServiceRegistration"/>. /// </summary> /// <param name="services">The <see cref="IServiceRegistration"/> to add the service to.</param> /// <param name="serviceType">The type of the service to register and the implementation to use.</param> /// <returns>A reference to this instance after the operation has completed.</returns> /// <seealso cref="ServiceLifetime.Singleton"/> public static IServiceRegistration RegisterSingleton(this IServiceRegistration services, Type serviceType) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (serviceType == null) { throw new ArgumentNullException(nameof(serviceType)); } return(services.RegisterSingleton(serviceType, serviceType)); }
/// <summary> /// Registers a singleton service of the type specified in <typeparamref name="TService"/> with a /// factory specified in <paramref name="implementationFactory"/> to the /// specified <see cref="IServiceRegistration"/>. /// </summary> /// <typeparam name="TService">The type of the service to add.</typeparam> /// <param name="services">The <see cref="IServiceRegistration"/> to add the service to.</param> /// <param name="implementationFactory">The factory that creates the service.</param> /// <returns>A reference to this instance after the operation has completed.</returns> /// <seealso cref="ServiceLifetime.Singleton"/> public static IServiceRegistration RegisterSingleton <TService>(this IServiceRegistration services, Func <IServiceProvider, TService> implementationFactory) where TService : class { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (implementationFactory == null) { throw new ArgumentNullException(nameof(implementationFactory)); } return(services.RegisterSingleton(typeof(TService), implementationFactory)); }
/// <summary> /// Registers the services used by serialization. /// </summary> /// <param name="registration">The <see cref="IServiceRegistration"/> to register with.</param> public void RegisterDefaultServices(IServiceRegistration registration) { registration.RegisterSingleton <IReflectionHelper>( new ReflectionHelper()); registration.Register <IConfigurationBuilder, ConfigurationBuilder>(); registration.RegisterSingleton <IDefaultConfiguration>(new DefaultConfiguration()); var rules = new RulesEngine { LoadingDefaults = true, }; registration.RegisterSingleton <IRulesEngine>(rules); registration.RegisterSingleton <IRulesConfiguration>(rules); registration.RegisterSingleton <IAnonymousTypeAdapter>( new AnonymousTypeAdapter()); registration.RegisterSingleton <ITypesCompressor>( new TypesCompressor()); registration.RegisterSingleton <ISerializationWrapper <string, JsonSerializerOptions, JsonSerializerOptions> >( new JsonWrapper()); }
/// <summary> /// Register the services. /// </summary> /// <param name="registration">The <see cref="IServiceRegistration"/> provider.</param> public void RegisterDefaultServices(IServiceRegistration registration) { registration.RegisterSingleton <IClientHttpConfiguration>(new ClientHttpConfiguration()); registration.RegisterSingleton <IRemoteQueryResolver>(new HttpRemoteQueryResolver()); }
public void RegisterDefaultServices(IServiceRegistration registration) { registration.RegisterSingleton <IGenericService>(new GenericService()); }
public void Register(IServiceRegistration services, IDictionary <string, object> data) { services.RegisterSingleton <IConnection, SampleConnection>(); services.RegisterTransient <IUserService, UserService>(); }