internal static void ObjectLateIndexSetComplex(object Instance, object[] Arguments, string[] ArgumentNames, bool OptimisticSet, bool RValueBase) { if (Arguments == null) { Arguments = Symbols.NoArguments; } if (ArgumentNames == null) { ArgumentNames = Symbols.NoArgumentNames; } Symbols.Container baseReference = new Symbols.Container(Instance); if (baseReference.IsArray) { if (ArgumentNames.Length > 0) { throw new ArgumentException(Utils.GetResourceString("Argument_InvalidNamedArgs")); } baseReference.SetArrayValue(Arguments); } else { if (ArgumentNames.Length > Arguments.Length) { throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValue")); } if (Arguments.Length < 1) { throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValue")); } string memberName = ""; if (baseReference.IsCOMObject) { LateBinding.LateIndexSetComplex(Instance, Arguments, ArgumentNames, OptimisticSet, RValueBase); } else { OverloadResolution.ResolutionFailure failure; BindingFlags setProperty = BindingFlags.SetProperty; MemberInfo[] members = baseReference.GetMembers(ref memberName, true); Symbols.Method targetProcedure = ResolveCall(baseReference, memberName, members, Arguments, ArgumentNames, Symbols.NoTypeArguments, setProperty, false, ref failure); if (failure == OverloadResolution.ResolutionFailure.None) { if (RValueBase && baseReference.IsValueType) { throw new Exception(Utils.GetResourceString("RValueBaseForValueType", new string[] { baseReference.VBFriendlyName, baseReference.VBFriendlyName })); } baseReference.InvokeMethod(targetProcedure, Arguments, null, setProperty); } else if (!OptimisticSet) { ResolveCall(baseReference, memberName, members, Arguments, ArgumentNames, Symbols.NoTypeArguments, setProperty, true, ref failure); throw new InternalErrorException(); } } } }
private static object CallMethod(Symbols.Container BaseReference, string MethodName, object[] Arguments, string[] ArgumentNames, Type[] TypeArguments, bool[] CopyBack, BindingFlags InvocationFlags, bool ReportErrors, ref OverloadResolution.ResolutionFailure Failure) { Failure = OverloadResolution.ResolutionFailure.None; if ((ArgumentNames.Length > Arguments.Length) || ((CopyBack != null) && (CopyBack.Length != Arguments.Length))) { Failure = OverloadResolution.ResolutionFailure.InvalidArgument; if (ReportErrors) { throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValue")); } return(null); } if (Symbols.HasFlag(InvocationFlags, BindingFlags.SetProperty) && (Arguments.Length < 1)) { Failure = OverloadResolution.ResolutionFailure.InvalidArgument; if (ReportErrors) { throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValue")); } return(null); } MemberInfo[] members = BaseReference.GetMembers(ref MethodName, ReportErrors); if ((members == null) || (members.Length == 0)) { Failure = OverloadResolution.ResolutionFailure.MissingMember; if (ReportErrors) { members = BaseReference.GetMembers(ref MethodName, true); } return(null); } Symbols.Method targetProcedure = ResolveCall(BaseReference, MethodName, members, Arguments, ArgumentNames, TypeArguments, InvocationFlags, ReportErrors, ref Failure); if (Failure == OverloadResolution.ResolutionFailure.None) { return(BaseReference.InvokeMethod(targetProcedure, Arguments, CopyBack, InvocationFlags)); } return(null); }
internal static void ObjectLateIndexSetComplex(object Instance, object[] Arguments, string[] ArgumentNames, bool OptimisticSet, bool RValueBase) { if (Arguments == null) { Arguments = Symbols.NoArguments; } if (ArgumentNames == null) { ArgumentNames = Symbols.NoArgumentNames; } Symbols.Container baseReference = new Symbols.Container(Instance); if (baseReference.IsArray) { if (ArgumentNames.Length > 0) { throw new ArgumentException(Utils.GetResourceString("Argument_InvalidNamedArgs")); } baseReference.SetArrayValue(Arguments); } else { if (ArgumentNames.Length > Arguments.Length) { throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValue")); } if (Arguments.Length < 1) { throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValue")); } string memberName = ""; if (baseReference.IsCOMObject) { LateBinding.LateIndexSetComplex(Instance, Arguments, ArgumentNames, OptimisticSet, RValueBase); } else { OverloadResolution.ResolutionFailure failure; BindingFlags setProperty = BindingFlags.SetProperty; MemberInfo[] members = baseReference.GetMembers(ref memberName, true); Symbols.Method targetProcedure = ResolveCall(baseReference, memberName, members, Arguments, ArgumentNames, Symbols.NoTypeArguments, setProperty, false, ref failure); if (failure == OverloadResolution.ResolutionFailure.None) { if (RValueBase && baseReference.IsValueType) { throw new Exception(Utils.GetResourceString("RValueBaseForValueType", new string[] { baseReference.VBFriendlyName, baseReference.VBFriendlyName })); } baseReference.InvokeMethod(targetProcedure, Arguments, null, setProperty); } else if (!OptimisticSet) { ResolveCall(baseReference, memberName, members, Arguments, ArgumentNames, Symbols.NoTypeArguments, setProperty, true, ref failure); throw new InternalErrorException(); } } } }
internal static object InvokeUserDefinedOperator(Symbols.Method OperatorMethod, bool ForceArgumentValidation, params object[] Arguments) { if ((!OperatorMethod.ArgumentsValidated || ForceArgumentValidation) && !OverloadResolution.CanMatchArguments(OperatorMethod, Arguments, Symbols.NoArgumentNames, Symbols.NoTypeArguments, false, null)) { string str = ""; List<string> errors = new List<string>(); bool flag = OverloadResolution.CanMatchArguments(OperatorMethod, Arguments, Symbols.NoArgumentNames, Symbols.NoTypeArguments, false, errors); foreach (string str2 in errors) { str = str + "\r\n " + str2; } throw new InvalidCastException(Utils.GetResourceString("MatchArgumentFailure2", new string[] { OperatorMethod.ToString(), str })); } Symbols.Container container = new Symbols.Container(OperatorMethod.DeclaringType); return container.InvokeMethod(OperatorMethod, Arguments, null, BindingFlags.InvokeMethod); }