public PropertyValueReference(EvaluationContext ctx, PropertyInfoMirror property, object obj, TypeMirror declaringType, MethodMirror getter, Value[] indexerArgs) : base(ctx) { this.declaringType = declaringType; this.indexerArgs = indexerArgs; this.property = property; this.getter = getter; this.obj = obj; var objectMirror = obj as ObjectMirror; if (objectMirror != null) { EnsureContextHasDomain(objectMirror.Domain); } flags = GetFlags(property, getter); }
public PropertyValueReference(EvaluationContext ctx, PropertyInfoMirror property, object obj, TypeMirror declaringType, MethodMirror getter, Value[] indexerArgs) : base(ctx) { this.property = property; this.obj = obj; this.declaringType = declaringType; this.indexerArgs = indexerArgs; flags = ObjectValueFlags.Property; if (property.GetSetMethod(true) == null) { flags |= ObjectValueFlags.ReadOnly; } if (getter.IsStatic) { flags |= ObjectValueFlags.Global; } if (getter.IsPublic) { flags |= ObjectValueFlags.Public; } else if (getter.IsPrivate) { flags |= ObjectValueFlags.Private; } else if (getter.IsFamily) { flags |= ObjectValueFlags.Protected; } else if (getter.IsFamilyAndAssembly) { flags |= ObjectValueFlags.Internal; } else if (getter.IsFamilyOrAssembly) { flags |= ObjectValueFlags.InternalProtected; } if (property.DeclaringType.IsValueType) { flags |= ObjectValueFlags.ReadOnly; // Setting property values on structs is not supported by sdb } }
protected override ValueReference GetMember(EvaluationContext ctx, object t, object co, string name) { TypeMirror type = (TypeMirror)t; while (type != null) { FieldInfoMirror field = type.GetField(name); if (field != null) { return(new FieldValueReference(ctx, field, co, type)); } PropertyInfoMirror prop = type.GetProperty(name); if (prop != null) { return(new PropertyValueReference(ctx, prop, co, type, null)); } type = type.BaseType; } return(null); }
internal static ObjectValueFlags GetFlags(PropertyInfoMirror property, MethodMirror getter) { var flags = ObjectValueFlags.Property; if (property.GetSetMethod(true) == null) { flags |= ObjectValueFlags.ReadOnly; } if (getter.IsStatic) { flags |= ObjectValueFlags.Global; } if (getter.IsPublic) { flags |= ObjectValueFlags.Public; } else if (getter.IsPrivate) { flags |= ObjectValueFlags.Private; } else if (getter.IsFamily) { flags |= ObjectValueFlags.Protected; } else if (getter.IsFamilyAndAssembly) { flags |= ObjectValueFlags.Internal; } else if (getter.IsFamilyOrAssembly) { flags |= ObjectValueFlags.InternalProtected; } if (property.DeclaringType.IsValueType) { flags |= ObjectValueFlags.ReadOnly; // Setting property values on structs is not supported by sdb } return(flags); }