Skip to content

Commit

Permalink
Merge remote-tracking branch 'adarapata/fix_fieldinjection_withparame…
Browse files Browse the repository at this point in the history
…ter' into SourceGeneratorAddParametersSupport
  • Loading branch information
AlonTalmi committed Nov 16, 2023
2 parents c6f9c51 + 8cddb21 commit b68f936
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public static ReflectionInjector Build(Type type)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Inject(object instance, IObjectResolver resolver, IReadOnlyList<IInjectParameter> parameters)
{
InjectFields(instance, resolver);
InjectProperties(instance, resolver);
InjectFields(instance, resolver, parameters);
InjectProperties(instance, resolver, parameters);
InjectMethods(instance, resolver, parameters);
}

Expand Down Expand Up @@ -56,26 +56,26 @@ public object CreateInstance(IObjectResolver resolver, IReadOnlyList<IInjectPara
}
}

void InjectFields(object obj, IObjectResolver resolver)
void InjectFields(object obj, IObjectResolver resolver, IReadOnlyList<IInjectParameter> parameters)
{
if (injectTypeInfo.InjectFields == null)
return;

foreach (var x in injectTypeInfo.InjectFields)
{
var fieldValue = resolver.Resolve(x.FieldType);
var fieldValue = resolver.ResolveOrParameter(x.FieldType, x.Name, parameters);
x.SetValue(obj, fieldValue);
}
}

void InjectProperties(object obj, IObjectResolver resolver)
void InjectProperties(object obj, IObjectResolver resolver, IReadOnlyList<IInjectParameter> parameters)
{
if (injectTypeInfo.InjectProperties == null)
return;

foreach (var x in injectTypeInfo.InjectProperties)
{
var propValue = resolver.Resolve(x.PropertyType);
var propValue = resolver.ResolveOrParameter(x.PropertyType, x.Name, parameters);
x.SetValue(obj, propValue);
}
}
Expand Down

0 comments on commit b68f936

Please sign in to comment.