ExprPropertyInfo
using System;
using System.Reflection;
namespace Microsoft.CSharp.RuntimeBinder.Semantics
{
internal sealed class ExprPropertyInfo : ExprWithType
{
public PropWithType Property { get; }
public PropertyInfo PropertyInfo {
get {
AggregateType ats = Property.Ats;
PropertySymbol propertySymbol = Property.Prop();
TypeArray typeArray = TypeManager.SubstTypeArray(propertySymbol.Params, ats, null);
Type type = ats.AssociatedSystemType;
PropertyInfo associatedPropertyInfo = propertySymbol.AssociatedPropertyInfo;
if (!type.IsGenericType && !type.IsNested)
type = associatedPropertyInfo.DeclaringType;
PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
foreach (PropertyInfo propertyInfo in properties) {
if (RuntimeBinderExtensions.HasSameMetadataDefinitionAs(propertyInfo, associatedPropertyInfo)) {
bool flag = true;
ParameterInfo[] array = (propertyInfo.GetSetMethod(true) != (MethodInfo)null) ? propertyInfo.GetSetMethod(true).GetParameters() : propertyInfo.GetGetMethod(true).GetParameters();
for (int j = 0; j < typeArray.Count; j++) {
if (!ExprWithType.TypesAreEqual(array[j].ParameterType, typeArray[j].AssociatedSystemType)) {
flag = false;
break;
}
}
if (flag)
return propertyInfo;
}
}
throw Error.InternalCompilerError();
}
}
public ExprPropertyInfo(CType type, PropertySymbol propertySymbol, AggregateType propertyType)
: base(ExpressionKind.PropertyInfo, type)
{
Property = new PropWithType(propertySymbol, propertyType);
}
}
}