Skip to content

Commit e244b33

Browse files
committed
simplify PropertiesAndFields.All
1 parent bab420a commit e244b33

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/DryIoc/Container.cs

+7-9
Original file line numberDiff line numberDiff line change
@@ -11286,25 +11286,23 @@ public static PropertiesAndFieldsSelector All(
1128611286
serviceInfo = (GetServiceInfo)((m, r) => PropertyOrFieldServiceInfo.Of(m).WithDetails(details));
1128711287
}
1128811288

11289-
Func<Request, PropertyInfo, bool> isInjectable =
11290-
withNonPublic && withPrimitive ? ((r, p) => p.IsInjectable(true, true)) :
11291-
withNonPublic ? ((r, p) => p.IsInjectable(true, false)) :
11292-
withPrimitive ? ((r, p) => p.IsInjectable(false, true)) :
11293-
((r, p) => p.IsInjectable(false, false));
11294-
1129511289
return req =>
1129611290
{
1129711291
var implType = req.ImplementationType;
11292+
if (implType == null)
11293+
return null;
11294+
11295+
// todo: @perf optimize allocations and maybe combine with fields below
1129811296
var properties = implType
1129911297
.GetMembers(x => x.DeclaredProperties, includeBase: withBase).ToArrayOrSelf()
11300-
.Match(req, isInjectable, (r, p) => serviceInfo(p, r));
11298+
.Match(serviceInfo, req, (si, r, p) => p.IsInjectable(withNonPublic, withPrimitive), (si, r, p) => si(p, r));
1130111299

1130211300
if (!withFields)
1130311301
return properties;
1130411302

11305-
var fields = implType // todo: @perf optimize allocations and maybe combine with properties
11303+
var fields = implType
1130611304
.GetMembers(x => x.DeclaredFields, includeBase: withBase).ToArrayOrSelf()
11307-
.Match(req, (r, f) => f.IsInjectable(withNonPublic, withPrimitive), (r, f) => serviceInfo(f, r));
11305+
.Match(serviceInfo, req, (si, r, f) => f.IsInjectable(withNonPublic, withPrimitive), (si, r, f) => si(f, r));
1130811306

1130911307
return properties.Append(fields);
1131011308
};

0 commit comments

Comments
 (0)