public override DynamicMetaObject FallbackInvokeMember(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion) { int offset = CallInfo.ArgumentCount - CallInfo.ArgumentNames.Count; for (int argIx = 0; argIx < args.Length; argIx++) { // レシーバとその助詞を探す。 var arg = args[argIx]; if (arg.Value == null) { continue; } //if ((arg.Value is IProduireClass) == false) // continue; var pType = _reference.GetProduireType(arg.LimitType); if (pType == null) { continue; } var suffix = argIx < offset ? null : CallInfo.ArgumentNames[argIx + offset]; // 対応する動詞が存在するか探す。 bool hasVerb = pType.Verbs .Where(v => v.Name == Name) .Where(v => v.Complements .Where(c => c is ReceiverComplement) .Any(c => c.ParticleText == suffix)) .Any(); if (hasVerb) { return(FindVerb(argIx, args)); } } return(base.FallbackInvokeMember(target, args, errorSuggestion)); }
public override DynamicMetaObject FallbackGetMember(DynamicMetaObject target, DynamicMetaObject errorSuggestion) { var pType = _reference.GetProduireType(target.LimitType); if (pType == null) { return(base.FallbackGetMember(target, errorSuggestion)); } return (GetProperty(target, pType) ?? GetEvent(target, pType) ?? base.FallbackGetMember(target, errorSuggestion)); }
public override DynamicMetaObject FallbackSetMember(DynamicMetaObject target, DynamicMetaObject value, DynamicMetaObject errorSuggestion) { var pType = _reference.GetProduireType(target.LimitType); if (pType == null) { return(base.FallbackSetMember(target, value, errorSuggestion)); } var tmpVar = Expression.Variable(typeof(object)); return(new DynamicMetaObject( Expression.Block( new[] { tmpVar }, Expression.Assign(tmpVar, value.Expression), Expression.Call( Expression.Constant(pType), MethodInfo, Expression.Convert(target.Expression, InstanceType), Expression.Constant(this.Name), tmpVar), tmpVar), BindingRestrictions.GetTypeRestriction(target.Expression, target.LimitType))); }