Skip to content

Commit

Permalink
Update config
Browse files Browse the repository at this point in the history
  • Loading branch information
usausa committed Apr 26, 2019
1 parent e901ae3 commit 428bbe8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Smart.Resolver/Resolver/ResolverConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public ResolverConfig()
{
Components.Add<DisposableStorage>();
Components.Add<IDelegateFactory>(DelegateFactory.Default);
if (ReflectionHelper.IsCodegenAllowed)
if (DelegateFactory.Default.IsCodegenRequired)
{
Components.Add<IFactoryBuilder, EmitFactoryBuilder>();
}
Expand Down
26 changes: 24 additions & 2 deletions Smart.Resolver/Resolver/ResolverConfigExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ public static ResolverConfig UseDelegateFactory<T>(this ResolverConfig config)
return config;
}

public static ResolverConfig UseDelegateFactory(this ResolverConfig config, IDelegateFactory factory)
{
if (config is null)
{
throw new ArgumentNullException(nameof(config));
}

config.Components.Add(typeof(IDelegateFactory), factory);
return config;
}

public static ResolverConfig UseFactoryBuilder<T>(this ResolverConfig config)
where T : IFactoryBuilder
{
Expand All @@ -40,6 +51,17 @@ public static ResolverConfig UseFactoryBuilder<T>(this ResolverConfig config)
return config;
}

public static ResolverConfig UseFactoryBuilder(this ResolverConfig config, IFactoryBuilder builder)
{
if (config is null)
{
throw new ArgumentNullException(nameof(config));
}

config.Components.Add(typeof(IFactoryBuilder), builder);
return config;
}

public static ResolverConfig UseMetadataFactory(this ResolverConfig config, IDelegateFactory delegateFactory)
{
if (config is null)
Expand All @@ -63,14 +85,14 @@ public static ResolverConfig UseProcessor<T>(this ResolverConfig config)
return config;
}

public static ResolverConfig UseProcessor(this ResolverConfig config, IProcessor activator)
public static ResolverConfig UseProcessor(this ResolverConfig config, IProcessor processor)
{
if (config is null)
{
throw new ArgumentNullException(nameof(config));
}

config.Components.Add(typeof(IProcessor), activator);
config.Components.Add(typeof(IProcessor), processor);
return config;
}

Expand Down

0 comments on commit 428bbe8

Please sign in to comment.