MemberInformation
Represents information about a member.
using Stashbox.Configuration;
using Stashbox.Registration;
using System;
using System.Reflection;
namespace Stashbox.Entity
{
public class MemberInformation
{
public MemberInfo MemberInfo { get; set; }
public TypeInformation TypeInformation { get; set; }
public MemberInformation Clone()
{
return new MemberInformation {
MemberInfo = MemberInfo,
TypeInformation = TypeInformation.Clone()
};
}
public bool CanInject(ContainerConfiguration configuration, RegistrationContext contextData)
{
bool num = configuration.MemberInjectionWithoutAnnotationEnabled || contextData.AutoMemberInjectionEnabled;
Rules.AutoMemberInjectionRules autoMemberInjectionRules = contextData.AutoMemberInjectionEnabled ? contextData.AutoMemberInjectionRule : configuration.MemberInjectionWithoutAnnotationRule;
if (num) {
if (!TypeInformation.ForcedDependency && (TypeInformation.MemberType != MemberType.Field || (autoMemberInjectionRules & Rules.AutoMemberInjectionRules.PrivateFields) != Rules.AutoMemberInjectionRules.PrivateFields)) {
if (TypeInformation.MemberType == MemberType.Property) {
if ((autoMemberInjectionRules & Rules.AutoMemberInjectionRules.PropertiesWithPublicSetter) != Rules.AutoMemberInjectionRules.PropertiesWithPublicSetter || !((PropertyInfo)MemberInfo).HasSetMethod(false))
return (autoMemberInjectionRules & Rules.AutoMemberInjectionRules.PropertiesWithLimitedAccess) == Rules.AutoMemberInjectionRules.PropertiesWithLimitedAccess;
return true;
}
return false;
}
return true;
}
return TypeInformation.ForcedDependency;
}
}
}