/// <summary> /// Produces a rule for the specified Action for the given arguments. /// /// The default implementation can produce rules for standard .NET types. Languages should /// override this and provide any custom behavior they need and fallback to the default /// implementation if no custom behavior is required. /// </summary> protected override void MakeRule(OldDynamicAction action, object[] args, RuleBuilder rule) { ContractUtils.RequiresNotNull(action, "action"); ContractUtils.RequiresNotNull(args, "args"); object[] extracted; CodeContext callerContext = ExtractCodeContext(args, out extracted); ContractUtils.RequiresNotNull(callerContext, "callerContext"); switch (action.Kind) { case DynamicActionKind.GetMember: new GetMemberBinderHelper(callerContext, (OldGetMemberAction)action, extracted, rule).MakeNewRule(); return; case DynamicActionKind.SetMember: new SetMemberBinderHelper(callerContext, (OldSetMemberAction)action, extracted, rule).MakeNewRule(); return; case DynamicActionKind.DeleteMember: new DeleteMemberBinderHelper(callerContext, (OldDeleteMemberAction)action, extracted, rule).MakeRule(); return; case DynamicActionKind.ConvertTo: new ConvertToBinderHelper(callerContext, (OldConvertToAction)action, extracted, rule).MakeRule(); return; default: throw new NotImplementedException(action.ToString()); } }
internal Expression Bind(OldDynamicAction action, object[] args, ReadOnlyCollection<ParameterExpression> parameters, LabelTarget returnLabel) { var builder = new RuleBuilder(parameters, returnLabel); MakeRule(action, args, builder); if (builder.Target != null) { return builder.CreateRule(); } return null; }
public bool GetRule(OldDynamicAction action, CodeContext context, object[] args, RuleBuilder rule) { if (action.Kind == DynamicActionKind.GetMember) { return(MakeGetMemberRule((OldGetMemberAction)action, context, rule)); } return(false); }
public virtual Expression Bind(OldDynamicAction action, object[] args, ReadOnlyCollection <ParameterExpression> parameters, LabelTarget returnLabel) { var builder = new RuleBuilder(parameters, returnLabel); MakeRule(action, args, builder); if (builder.Target != null) { return(builder.CreateRule()); } return(null); }
private MetaObject MakeDeleteMemberTarget(SetOrDeleteMemberInfo delInfo, MetaObject target) { Type type = target.LimitType; Restrictions restrictions = target.Restrictions; Expression self = target.Expression; // needed for DeleteMember call until DynamicAction goes away OldDynamicAction act = OldDeleteMemberAction.Make( this, delInfo.Name ); if (typeof(TypeTracker).IsAssignableFrom(type)) { restrictions = restrictions.Merge( Restrictions.GetInstanceRestriction(target.Expression, target.Value) ); type = ((TypeTracker)target.Value).Type; self = null; } delInfo.Body.Restrictions = restrictions; if (self == null || !MakeOperatorDeleteMemberBody(delInfo, self, type, "DeleteMember")) { MemberGroup group = GetMember(act, type, delInfo.Name); if (group.Count != 0) { if (group[0].MemberType == TrackerTypes.Property) { MethodInfo del = ((PropertyTracker)group[0]).GetDeleteMethod(PrivateBinding); if (del != null) { MakePropertyDeleteStatement(delInfo, self, del); return(delInfo.Body.GetMetaObject(target)); } } delInfo.Body.FinishCondition(MakeError(MakeUndeletableMemberError(GetDeclaringMemberType(group), delInfo.Name))); } else { delInfo.Body.FinishCondition(MakeError(MakeMissingMemberError(type, delInfo.Name))); } } return(delInfo.Body.GetMetaObject(target)); }
/// <summary> /// Gets the members that are visible from the provided type of the specified name. /// /// The default implemetnation first searches the type, then the flattened heirachy of the type, and then /// registered extension methods. /// </summary> public virtual MemberGroup GetMember(OldDynamicAction action, Type type, string name) { MemberInfo[] foundMembers = type.GetMember(name); if (!PrivateBinding) { foundMembers = CompilerHelpers.FilterNonVisibleMembers(type, foundMembers); } MemberGroup members = new MemberGroup(foundMembers); // check for generic types w/ arity... Type[] types = type.GetNestedTypes(BindingFlags.Public); string genName = name + ReflectionUtils.GenericArityDelimiter; List <Type> genTypes = null; foreach (Type t in types) { if (t.Name.StartsWith(genName)) { if (genTypes == null) { genTypes = new List <Type>(); } genTypes.Add(t); } } if (genTypes != null) { List <MemberTracker> mt = new List <MemberTracker>(members); foreach (Type t in genTypes) { mt.Add(MemberTracker.FromMemberInfo(t)); } return(MemberGroup.CreateInternal(mt.ToArray())); } if (members.Count == 0) { members = new MemberGroup(type.GetMember(name, BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance)); if (members.Count == 0) { members = GetAllExtensionMembers(type, name); } } return(members); }
/// <summary> /// Produces a rule for the specified Action for the given arguments. /// /// The default implementation can produce rules for standard .NET types. Languages should /// override this and provide any custom behavior they need and fallback to the default /// implementation if no custom behavior is required. /// </summary> protected override void MakeRule(OldDynamicAction action, object[] args, RuleBuilder rule) { ContractUtils.RequiresNotNull(action, "action"); ContractUtils.RequiresNotNull(args, "args"); object[] extracted; CodeContext callerContext = ExtractCodeContext(args, out extracted); ContractUtils.RequiresNotNull(callerContext, "callerContext"); switch (action.Kind) { case DynamicActionKind.Call: new CallBinderHelper <OldCallAction>(callerContext, (OldCallAction)action, extracted, rule).MakeRule(); return; case DynamicActionKind.GetMember: new GetMemberBinderHelper(callerContext, (OldGetMemberAction)action, extracted, rule).MakeNewRule(); return; case DynamicActionKind.SetMember: new SetMemberBinderHelper(callerContext, (OldSetMemberAction)action, extracted, rule).MakeNewRule(); return; case DynamicActionKind.CreateInstance: new CreateInstanceBinderHelper(callerContext, (OldCreateInstanceAction)action, extracted, rule).MakeRule(); return; case DynamicActionKind.DoOperation: new DoOperationBinderHelper(callerContext, (OldDoOperationAction)action, extracted, rule).MakeRule(); return; case DynamicActionKind.DeleteMember: new DeleteMemberBinderHelper(callerContext, (OldDeleteMemberAction)action, extracted, rule).MakeRule(); return; case DynamicActionKind.ConvertTo: new ConvertToBinderHelper(callerContext, (OldConvertToAction)action, extracted, rule).MakeRule(); return; default: throw new NotImplementedException(action.ToString()); } }
/// <summary> /// Returns a list of possible members which could exist. ResolveMember needs to be called to verify their existance. Duplicate /// names can also be returned. /// </summary> protected abstract IEnumerable<string/*!*/>/*!*/ GetCandidateNames(MemberBinder/*!*/ binder, OldDynamicAction/*!*/ action, Type/*!*/ type);
/// <summary> /// Returns a list of members that exist on the type. The ResolvedMember structure indicates both /// the name and provides the MemberGroup. /// </summary> public IList<ResolvedMember/*!*/>/*!*/ ResolveMembers(MemberBinder/*!*/ binder, OldDynamicAction/*!*/ action, Type/*!*/ type) { Dictionary<string, ResolvedMember> members = new Dictionary<string, ResolvedMember>(); foreach (string name in GetCandidateNames(binder, action, type)) { if (members.ContainsKey(name)) { continue; } MemberGroup member = ResolveMember(binder, action, type, name); if (member.Count > 0) { members[name] = new ResolvedMember(name, member); } } ResolvedMember[] res = new ResolvedMember[members.Count]; members.Values.CopyTo(res, 0); return res; }
private static MemberGroup/*!*/ FilterSpecialNames(MemberGroup/*!*/ group, string/*!*/ name, OldDynamicAction/*!*/ action) { Assert.NotNull(group, name, action); bool filter = true; if (action.Kind == DynamicActionKind.Call || action.Kind == DynamicActionKind.ConvertTo || action.Kind == DynamicActionKind.DoOperation) { filter = false; } if (!IsPythonRecognizedOperator(name)) { filter = false; } List<MemberTracker> mts = null; for (int i = 0; i < group.Count; i++) { MemberTracker mt = group[i]; bool skip = false; if (mt.MemberType == TrackerTypes.Method) { MethodTracker meth = (MethodTracker)mt; if (meth.Method.IsSpecialName && mt.Name != "op_Implicit" && mt.Name != "op_Explicit") { if (!IsPropertyWithParameters(meth)) { skip = true; } } if (meth.Method.IsDefined(typeof(ClassMethodAttribute), true)) { return new MemberGroup(new ClassMethodTracker(group)); } } else if (mt.MemberType == TrackerTypes.Property) { PropertyTracker pt = (PropertyTracker)mt; if (name == pt.Name && pt.GetIndexParameters().Length > 0 && IsPropertyDefaultMember(pt)) { // exposed via __*item__, not the property name skip = true; } } else if (mt.MemberType == TrackerTypes.Field) { FieldInfo fi = ((FieldTracker)mt).Field; if (fi.IsDefined(typeof(SlotFieldAttribute), false)) { if (mts == null) { mts = MakeListWithPreviousMembers(group, mts, i); mt = new CustomAttributeTracker(mt.DeclaringType, mt.Name, (PythonTypeSlot)fi.GetValue(null)); } } } if (skip && filter) { if (mts == null) { // add any ones we skipped... mts = MakeListWithPreviousMembers(group, mts, i); } } else if (mts != null) { mts.Add(mt); } } if (mts != null) { if (mts.Count == 0) { return MemberGroup.EmptyGroup; } return new MemberGroup(mts.ToArray()); } return group; }
private void MakeSetMemberRule(SetOrDeleteMemberInfo memInfo, Type type, Expression self, MetaObject target) { if (MakeOperatorSetMemberBody(memInfo, self, target, type, "SetMember")) { return; } // needed for GetMember call until DynamicAction goes away OldDynamicAction act = OldSetMemberAction.Make( this, memInfo.Name ); MemberGroup members = GetMember(act, type, memInfo.Name); // if lookup failed try the strong-box type if available. if (members.Count == 0 && typeof(IStrongBox).IsAssignableFrom(type)) { self = Ast.Field(AstUtils.Convert(self, type), type.GetField("Value")); type = type.GetGenericArguments()[0]; members = GetMember(act, type, memInfo.Name); } Expression error; TrackerTypes memberTypes = GetMemberType(members, out error); if (error == null) { switch (memberTypes) { case TrackerTypes.Method: case TrackerTypes.TypeGroup: case TrackerTypes.Type: case TrackerTypes.Constructor: memInfo.Body.FinishCondition( MakeError(MakeReadOnlyMemberError(type, memInfo.Name)) ); break; case TrackerTypes.Event: memInfo.Body.FinishCondition( MakeError(MakeEventValidation(members, self, target.Expression, memInfo.CodeContext)) ); break; case TrackerTypes.Field: MakeFieldRule(memInfo, self, target, type, members); break; case TrackerTypes.Property: MakePropertyRule(memInfo, self, target, type, members); break; case TrackerTypes.Custom: MakeGenericBody(memInfo, self, target, type, members[0]); break; case TrackerTypes.All: // no match if (MakeOperatorSetMemberBody(memInfo, self, target, type, "SetMemberAfter")) { return; } memInfo.Body.FinishCondition( MakeError(MakeMissingMemberError(type, memInfo.Name)) ); break; default: throw new InvalidOperationException(); } } else { memInfo.Body.FinishCondition(error); } }
public override MemberGroup/*!*/ ResolveMember(MemberBinder/*!*/ binder, OldDynamicAction/*!*/ action, Type/*!*/ type, string/*!*/ name) { if (type.IsSealed && type.IsAbstract) { // static types don't have PythonOperationKind return MemberGroup.EmptyGroup; } // try mapping __*__ methods to .NET method names PythonOperationKind opMap; EnsureOperatorTable(); if (_pythonOperatorTable.TryGetValue(name, out opMap)) { if (IncludeOperatorMethod(type, opMap)) { OperatorMapping opInfo; if (IsReverseOperator(opMap)) { opInfo = OperatorMapping.GetOperatorMapping(opMap & ~PythonOperationKind.Reversed); } else { opInfo = OperatorMapping.GetOperatorMapping(opMap); } if (opInfo != null) { foreach (Type curType in binder.GetContributingTypes(type)) { if (curType == typeof(BigInteger) && (opInfo.Operator == PythonOperationKind.Mod || opInfo.Operator == PythonOperationKind.RightShift || opInfo.Operator == PythonOperationKind.LeftShift || opInfo.Operator == PythonOperationKind.Compare || opInfo.Operator == PythonOperationKind.Divide)) { // we override these with our own modulus/power PythonOperationKind which are different from BigInteger. continue; } Debug.Assert(opInfo.Name != "Equals"); MemberGroup res = GetBaseHelperOverloads(type, opInfo.Name, binder.GetMember(curType, opInfo.Name)); if (res.Count == 0 && opInfo.AlternateName != null) { res = binder.GetMember(curType, opInfo.AlternateName); if (opInfo.AlternateName == "Equals") { // "Equals" is available as an alternate method name. Because it's also on object and Python // doesn't define it on object we need to filter it out. res = FilterObjectEquality(res); } else { res = GetBaseHelperOverloads(type, opInfo.AlternateName, res); } } if (res.Count > 0) { return FilterForwardReverseMethods(name, res, type, opMap); } } } } } if (name == "__call__") { MemberGroup res = binder.GetMember(type, "Call"); if (res.Count > 0) { return res; } } return MemberGroup.EmptyGroup; }
public override MemberGroup/*!*/ ResolveMember(MemberBinder/*!*/ binder, OldDynamicAction/*!*/ action, Type/*!*/ type, string/*!*/ name) { if (name == ".ctor" || name == ".cctor") return MemberGroup.EmptyGroup; // normal binding MemberGroup res; foreach (Type curType in binder.GetContributingTypes(type)) { res = GetBaseHelperOverloads(type, name, FilterSpecialNames(binder.GetMember(curType, name), name, action)); if (res.Count > 0) { return res; } } if (type.IsInterface) { foreach (Type t in type.GetInterfaces()) { res = FilterSpecialNames(binder.GetMember(t, name), name, action); if (res.Count > 0) { return res; } } } return MemberGroup.EmptyGroup; }
public override MemberGroup/*!*/ GetMember(OldDynamicAction action, Type type, string name) { MemberGroup mg; if (!_resolvedMembers.TryGetCachedMember(type, name, action.Kind == DynamicActionKind.GetMember, out mg)) { mg = TypeInfo.GetMemberAll( this, action, type, name); _resolvedMembers.CacheSlot(type, name, PythonTypeOps.GetSlot(mg, name, PrivateBinding), mg); } return mg ?? MemberGroup.EmptyGroup; }
private MetaObject MakeGetMemberTarget(GetMemberInfo getMemInfo, MetaObject target) { Type type = target.LimitType.IsCOMObject ? target.Expression.Type : target.LimitType; Restrictions restrictions = target.Restrictions; Expression self = target.Expression; target = target.Restrict(target.LimitType); // needed for GetMember call until DynamicAction goes away OldDynamicAction act = OldGetMemberAction.Make( this, getMemInfo.Name ); // Specially recognized types: TypeTracker, NamespaceTracker, and StrongBox. // TODO: TypeTracker and NamespaceTracker should technically be IDO's. MemberGroup members = MemberGroup.EmptyGroup; if (typeof(TypeTracker).IsAssignableFrom(type)) { restrictions = restrictions.Merge( Restrictions.GetInstanceRestriction(target.Expression, target.Value) ); TypeGroup tg = target.Value as TypeGroup; Type nonGen; if (tg == null || tg.TryGetNonGenericType(out nonGen)) { members = GetMember(act, ((TypeTracker)target.Value).Type, getMemInfo.Name); if (members.Count > 0) { // we have a member that's on the type associated w/ the tracker, return that... type = ((TypeTracker)target.Value).Type; self = null; } } } if (members.Count == 0) { // Get the members members = GetMember(act, type, getMemInfo.Name); } if (members.Count == 0) { if (typeof(TypeTracker).IsAssignableFrom(type)) { // ensure we don't have a non-generic type, and if we do report an error now. This matches // the rule version of the default binder but should probably be removed long term Type x = ((TypeTracker)target.Value).Type; } else if (type.IsInterface) { // all interfaces have object members type = typeof(object); members = GetMember(act, type, getMemInfo.Name); } } Expression propSelf = self; // if lookup failed try the strong-box type if available. if (members.Count == 0 && typeof(IStrongBox).IsAssignableFrom(type)) { // properties/fields need the direct value, methods hold onto the strong box. propSelf = Ast.Field(AstUtils.Convert(self, type), type.GetField("Value")); type = type.GetGenericArguments()[0]; members = GetMember( act, type, getMemInfo.Name ); } MakeBodyHelper(getMemInfo, self, propSelf, type, members); getMemInfo.Body.Restrictions = restrictions; return(getMemInfo.Body.GetMetaObject(target)); }
/// <summary> /// Produces a rule for the specified Action for the given arguments. /// </summary> /// <param name="action">The Action that is being performed.</param> /// <param name="args">The arguments to the action as provided from the call site at runtime.</param> /// <param name="rule">The rule builder that will hold the result</param> protected abstract void MakeRule(OldDynamicAction action, object[] args, RuleBuilder rule);
/// <summary> /// Gets the members that are visible from the provided type of the specified name. /// /// The default implemetnation first searches the type, then the flattened heirachy of the type, and then /// registered extension methods. /// </summary> public virtual MemberGroup GetMember(OldDynamicAction action, Type type, string name) { MemberInfo[] foundMembers = type.GetMember(name); if (!PrivateBinding) { foundMembers = CompilerHelpers.FilterNonVisibleMembers(type, foundMembers); } MemberGroup members = new MemberGroup(foundMembers); // check for generic types w/ arity... Type[] types = type.GetNestedTypes(BindingFlags.Public); string genName = name + ReflectionUtils.GenericArityDelimiter; List<Type> genTypes = null; foreach (Type t in types) { if (t.Name.StartsWith(genName)) { if (genTypes == null) genTypes = new List<Type>(); genTypes.Add(t); } } if (genTypes != null) { List<MemberTracker> mt = new List<MemberTracker>(members); foreach (Type t in genTypes) { mt.Add(MemberTracker.FromMemberInfo(t)); } return MemberGroup.CreateInternal(mt.ToArray()); } if (members.Count == 0) { members = new MemberGroup(type.GetMember(name, BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance)); if (members.Count == 0) { members = GetAllExtensionMembers(type, name); } } return members; }
public bool GetRule(OldDynamicAction action, CodeContext context, object[] args, RuleBuilder rule) { if (action.Kind == DynamicActionKind.GetMember) { return MakeGetMemberRule((OldGetMemberAction)action, context, rule); } return false; }
public override MemberGroup/*!*/ ResolveMember(MemberBinder/*!*/ binder, OldDynamicAction/*!*/ action, Type/*!*/ type, string/*!*/ name) { Assert.NotNull(binder, action, type, name); if (name == _name) { return _resolver(binder, type); } return MemberGroup.EmptyGroup; }
public override MemberGroup/*!*/ ResolveMember(MemberBinder/*!*/ binder, OldDynamicAction/*!*/ action, Type/*!*/ type, string/*!*/ name) { if (binder.DomainManager.Configuration.PrivateBinding) { // in private binding mode Python exposes private members under a mangled name. string header = "_" + type.Name + "__"; if (name.StartsWith(header)) { string memberName = name.Substring(header.Length); MemberGroup res = new MemberGroup(type.GetMember(memberName, _privateFlags)); if (res.Count > 0) { return FilterFieldAndEvent(res); } res = new MemberGroup(type.GetMember(memberName, BindingFlags.FlattenHierarchy | _privateFlags)); if (res.Count > 0) { return FilterFieldAndEvent(res); } } } return MemberGroup.EmptyGroup; }
protected override IEnumerable<string/*!*/>/*!*/ GetCandidateNames(MemberBinder/*!*/ binder, OldDynamicAction/*!*/ action, Type/*!*/ type) { yield return _name; }
public override MemberGroup/*!*/ ResolveMember(MemberBinder/*!*/ binder, OldDynamicAction/*!*/ action, Type/*!*/ type, string/*!*/ name) { foreach (Type t in binder.GetContributingTypes(type)) { MemberGroup res = new MemberGroup(ArrayUtils.FindAll(t.GetMember(name, BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy), ProtectedOnly)); for (int i = 0; i < res.Count; i++) { MethodTracker meth = res[i] as MethodTracker; if (meth == null) { continue; } if (meth.Name == "Finalize" && meth.Method.GetBaseDefinition() == typeof(object).GetMethod("Finalize", BindingFlags.NonPublic | BindingFlags.Instance)) { MemberTracker[] retained = new MemberTracker[res.Count - 1]; if (res.Count == 1) { res = MemberGroup.EmptyGroup; } else { for (int j = 0; j < i; j++) { retained[j] = res[j]; } for (int j = i + 1; j < res.Count; j++) { retained[j - 1] = res[j]; } res = new MemberGroup(retained); } break; } } res = FilterSpecialNames(res, name, action); return GetBaseHelperOverloads(PythonTypeOps.GetFinalSystemType(type), name, res); } return MemberGroup.EmptyGroup; }
protected override IEnumerable<string/*!*/>/*!*/ GetCandidateNames(MemberBinder/*!*/ binder, OldDynamicAction/*!*/ action, Type/*!*/ type) { foreach (Type curType in binder.GetContributingTypes(type)) { foreach (MemberInfo mi in curType.GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static)) { if (mi.MemberType == MemberTypes.Method) { MethodInfo meth = (MethodInfo)mi; if (meth.IsSpecialName) { if (meth.IsDefined(typeof(PropertyMethodAttribute), true)) { if (meth.Name.StartsWith("Get") || meth.Name.StartsWith("Set")) { yield return meth.Name.Substring(3); } else { Debug.Assert(meth.Name.StartsWith("Delete")); yield return meth.Name.Substring(6); } } continue; } } yield return mi.Name; } } }
/// <summary> /// Gets the statically known member from the type with the specific name. Searches only the specified type to find the member. /// </summary> public static MemberGroup/*!*/ GetMember(PythonBinder/*!*/ binder, OldDynamicAction/*!*/ action, Type/*!*/ type, string/*!*/ name) { Assert.NotNull(binder, action, type, name); PerfTrack.NoteEvent(PerfTrack.Categories.ReflectedTypes, String.Format("LookupMember: {0} {1}", type.Name, name)); return GetMemberGroup(new LookupBinder(binder), action, type, name); }
protected override IEnumerable<string/*!*/>/*!*/ GetCandidateNames(MemberBinder/*!*/ binder, OldDynamicAction/*!*/ action, Type/*!*/ type) { EnsureOperatorTable(); foreach (SymbolId si in _pythonOperatorTable.Keys) { yield return SymbolTable.IdToString(si); } yield return "__call__"; }
protected override IEnumerable<string/*!*/>/*!*/ GetCandidateNames(MemberBinder/*!*/ binder, OldDynamicAction/*!*/ action, Type/*!*/ type) { if (!binder.DomainManager.Configuration.PrivateBinding) { yield break; } foreach (MemberInfo mi in type.GetMembers(_privateFlags | BindingFlags.FlattenHierarchy)) { yield return String.Concat("_", mi.DeclaringType.Name, "__", mi.Name); } }
/// <summary> /// Primary worker for getting the member(s) associated with a single name. Can be called with different MemberBinder's to alter the /// scope of the search. /// </summary> private static MemberGroup/*!*/ GetMemberGroup(MemberBinder/*!*/ memberBinder, OldDynamicAction/*!*/ action, Type/*!*/ type, string/*!*/ name) { foreach (MemberResolver resolver in _resolvers) { MemberGroup/*!*/ group = resolver.ResolveMember(memberBinder, action, type, name); if (group.Count > 0) { return group; } } return MemberGroup.EmptyGroup; }
protected override IEnumerable<string/*!*/>/*!*/ GetCandidateNames(MemberBinder/*!*/ binder, OldDynamicAction/*!*/ action, Type/*!*/ type) { // these members are visible but only accept derived types. foreach (Type t in binder.GetContributingTypes(type)) { MemberInfo[] mems = ArrayUtils.FindAll(t.GetMembers(BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic), ProtectedOnly); foreach (MemberInfo mi in mems) { yield return mi.Name; } } }
/// <summary> /// Primary worker for returning a list of all members in a type. Can be called with different MemberBinder's to alter the scope /// of the search. /// </summary> private static IList<ResolvedMember/*!*/>/*!*/ GetResolvedMembers(MemberBinder/*!*/ memberBinder, OldDynamicAction/*!*/ action, Type/*!*/ type) { List<ResolvedMember> res = new List<ResolvedMember>(); foreach (MemberResolver resolver in _resolvers) { res.AddRange(resolver.ResolveMembers(memberBinder, action, type)); } return res; }
/// <summary> /// Gets all the statically known members from the specified type. Searches only the specified type to find the members. /// /// The result may include multiple resolution. It is the callers responsibility to only treat the 1st one by name as existing. /// </summary> public static IList<ResolvedMember/*!*/>/*!*/ GetMembers(PythonBinder/*!*/ binder, OldDynamicAction/*!*/ action, Type/*!*/ type) { Assert.NotNull(binder, action, type); return GetResolvedMembers(new LookupBinder(binder), action, type); }
/// <summary> /// Looks up an individual member and returns a MemberGroup with the given members. /// </summary> public abstract MemberGroup/*!*/ ResolveMember(MemberBinder/*!*/ binder, OldDynamicAction/*!*/ action, Type/*!*/ type, string/*!*/ name);