Skip to content

Commit

Permalink
More overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
ENikS committed Mar 17, 2019
1 parent 33a399d commit 65a2340
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 16 deletions.
49 changes: 33 additions & 16 deletions src/Extensions/Injection/Override.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,41 @@ public static partial class Override
#if !NET40
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static ResolverOverride Parameter<TType>(object value)
=> new ParameterOverride(typeof(TType), value);
public static ResolverOverride Parameter(object value)
=> new ParameterOverride(value?.GetType() ?? throw new ArgumentNullException(nameof(value)), value);


#if !NET40
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static ResolverOverride Parameter<TType>(string name, object value)
=> Parameter(typeof(TType), name, value);
public static ResolverOverride Parameter(string name, object value)
=> new ParameterOverride(name, value);

#if !NET40
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static ResolverOverride Parameter(Type type, object value)
public static ResolverOverride Parameter(Type type, object value)
=> new ParameterOverride(type, value);


#if !NET40
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static ResolverOverride Parameter(Type type, string name, object value)
public static ResolverOverride Parameter(Type type, string name, object value)
=> new ParameterOverride(type, name, value);


#if !NET40
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static ResolverOverride Parameter(string name, object value)
=> new ParameterOverride(name, value);
public static ResolverOverride Parameter<TType>(object value)
=> new ParameterOverride(typeof(TType), value);

#if !NET40
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static ResolverOverride Parameter<TType>(string name, object value)
=> Parameter(typeof(TType), name, value);

#endregion

Expand All @@ -62,21 +71,16 @@ public static ResolverOverride Parameter(string name, object value)
#if !NET40
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static ResolverOverride Dependency<TType>(object value)
=> new DependencyOverride(typeof(TType), value);

#if !NET40
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static ResolverOverride Dependency<TType>(string name, object value)
=> new DependencyOverride(typeof(TType), name, value);
public static ResolverOverride Dependency(object value)
=> Dependency(value?.GetType() ?? throw new ArgumentNullException(nameof(value)), null, value);

#if !NET40
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static ResolverOverride Dependency(string name, object value)
=> Dependency(value?.GetType() ?? throw new ArgumentNullException(nameof(value)), name, value);


#if !NET40
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
Expand All @@ -93,6 +97,19 @@ public static ResolverOverride Dependency(Type type, string name, object value)
return new DependencyOverride(type, name, value);
}


#if !NET40
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static ResolverOverride Dependency<TType>(object value)
=> new DependencyOverride(typeof(TType), value);

#if !NET40
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static ResolverOverride Dependency<TType>(string name, object value)
=> new DependencyOverride(typeof(TType), name, value);

#endregion
}
}
5 changes: 5 additions & 0 deletions src/Extensions/Injection/Resolve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ public static partial class Resolve
{
#region Dependency

#if !NET40
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
public static ParameterBase Dependency<TTarget>() => new ResolvedParameter(typeof(TTarget), null);

#if !NET40
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
Expand Down

0 comments on commit 65a2340

Please sign in to comment.