internal static bool CanBindGet(object Instance, string MemberName, object[] Arguments, string[] ArgumentNames)
 {
     Symbols.Container baseReference = new Symbols.Container(Instance);
     BindingFlags lookupFlags = BindingFlags.GetProperty | BindingFlags.InvokeMethod;
     MemberInfo[] members = baseReference.GetMembers(ref MemberName, false);
     if ((members != null) && (members.Length != 0))
     {
         OverloadResolution.ResolutionFailure failure;
         if (members[0].MemberType == MemberTypes.Field)
         {
             return true;
         }
         Symbols.Method method = ResolveCall(baseReference, MemberName, members, Arguments, ArgumentNames, Symbols.NoTypeArguments, lookupFlags, false, ref failure);
         if (failure == OverloadResolution.ResolutionFailure.None)
         {
             return true;
         }
         if (((Arguments.Length > 0) && (members.Length == 1)) && IsZeroArgumentCall(members[0]))
         {
             method = ResolveCall(baseReference, MemberName, members, Symbols.NoArguments, Symbols.NoArgumentNames, Symbols.NoTypeArguments, lookupFlags, false, ref failure);
             if (failure == OverloadResolution.ResolutionFailure.None)
             {
                 return true;
             }
         }
     }
     return false;
 }
Exemple #2
0
        internal static bool CanBindGet(object Instance, string MemberName, object[] Arguments, string[] ArgumentNames)
        {
            Symbols.Container baseReference = new Symbols.Container(Instance);
            BindingFlags      lookupFlags   = BindingFlags.GetProperty | BindingFlags.InvokeMethod;

            MemberInfo[] members = baseReference.GetMembers(ref MemberName, false);
            if ((members != null) && (members.Length != 0))
            {
                OverloadResolution.ResolutionFailure failure;
                if (members[0].MemberType == MemberTypes.Field)
                {
                    return(true);
                }
                Symbols.Method method = ResolveCall(baseReference, MemberName, members, Arguments, ArgumentNames, Symbols.NoTypeArguments, lookupFlags, false, ref failure);
                if (failure == OverloadResolution.ResolutionFailure.None)
                {
                    return(true);
                }
                if (((Arguments.Length > 0) && (members.Length == 1)) && IsZeroArgumentCall(members[0]))
                {
                    method = ResolveCall(baseReference, MemberName, members, Symbols.NoArguments, Symbols.NoArgumentNames, Symbols.NoTypeArguments, lookupFlags, false, ref failure);
                    if (failure == OverloadResolution.ResolutionFailure.None)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemple #3
0
        internal static bool CanIndexSetComplex(object Instance, object[] Arguments, string[] ArgumentNames, bool OptimisticSet, bool RValueBase)
        {
            OverloadResolution.ResolutionFailure failure;
            Symbols.Container baseReference = new Symbols.Container(Instance);
            if (baseReference.IsArray)
            {
                return(ArgumentNames.Length == 0);
            }
            string       memberName  = "";
            BindingFlags setProperty = BindingFlags.SetProperty;

            MemberInfo[] members = baseReference.GetMembers(ref memberName, false);
            if ((members == null) || (members.Length == 0))
            {
                return(false);
            }
            Symbols.Method method = ResolveCall(baseReference, memberName, members, Arguments, ArgumentNames, Symbols.NoTypeArguments, setProperty, false, ref failure);
            if (failure != OverloadResolution.ResolutionFailure.None)
            {
                return(OptimisticSet);
            }
            if (RValueBase && baseReference.IsValueType)
            {
                return(false);
            }
            return(true);
        }
Exemple #4
0
 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();
             }
         }
     }
 }
Exemple #5
0
 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 bool CanBindCall(object Instance, string MemberName, object[] Arguments, string[] ArgumentNames, bool IgnoreReturn)
 {
     OverloadResolution.ResolutionFailure failure;
     Symbols.Container baseReference = new Symbols.Container(Instance);
     BindingFlags lookupFlags = BindingFlags.GetProperty | BindingFlags.InvokeMethod;
     if (IgnoreReturn)
     {
         lookupFlags |= BindingFlags.IgnoreReturn;
     }
     MemberInfo[] members = baseReference.GetMembers(ref MemberName, false);
     if ((members == null) || (members.Length == 0))
     {
         return false;
     }
     Symbols.Method method = ResolveCall(baseReference, MemberName, members, Arguments, ArgumentNames, Symbols.NoTypeArguments, lookupFlags, false, ref failure);
     return (failure == OverloadResolution.ResolutionFailure.None);
 }
Exemple #7
0
        internal static bool CanBindCall(object Instance, string MemberName, object[] Arguments, string[] ArgumentNames, bool IgnoreReturn)
        {
            OverloadResolution.ResolutionFailure failure;
            Symbols.Container baseReference = new Symbols.Container(Instance);
            BindingFlags      lookupFlags   = BindingFlags.GetProperty | BindingFlags.InvokeMethod;

            if (IgnoreReturn)
            {
                lookupFlags |= BindingFlags.IgnoreReturn;
            }
            MemberInfo[] members = baseReference.GetMembers(ref MemberName, false);
            if ((members == null) || (members.Length == 0))
            {
                return(false);
            }
            Symbols.Method method = ResolveCall(baseReference, MemberName, members, Arguments, ArgumentNames, Symbols.NoTypeArguments, lookupFlags, false, ref failure);
            return(failure == OverloadResolution.ResolutionFailure.None);
        }
Exemple #8
0
        internal static bool CanBindSet(object Instance, string MemberName, object Value, bool OptimisticSet, bool RValueBase)
        {
            OverloadResolution.ResolutionFailure failure;
            Symbols.Container baseReference = new Symbols.Container(Instance);
            object[]          arguments     = new object[] { Value };
            MemberInfo[]      members       = baseReference.GetMembers(ref MemberName, false);
            if ((members == null) || (members.Length == 0))
            {
                return(false);
            }
            if (members[0].MemberType == MemberTypes.Field)
            {
                if (((arguments.Length == 1) && RValueBase) && baseReference.IsValueType)
                {
                    return(false);
                }
                return(true);
            }
            Symbols.Method method = ResolveCall(baseReference, MemberName, members, arguments, Symbols.NoArgumentNames, Symbols.NoTypeArguments, BindingFlags.SetProperty, false, ref failure);
            if (failure == OverloadResolution.ResolutionFailure.None)
            {
                if (RValueBase && baseReference.IsValueType)
                {
                    return(false);
                }
                return(true);
            }
            BindingFlags lookupFlags = BindingFlags.GetProperty | BindingFlags.InvokeMethod;

            if (failure == OverloadResolution.ResolutionFailure.MissingMember)
            {
                method = ResolveCall(baseReference, MemberName, members, Symbols.NoArguments, Symbols.NoArgumentNames, Symbols.NoTypeArguments, lookupFlags, false, ref failure);
                if (failure == OverloadResolution.ResolutionFailure.None)
                {
                    return(true);
                }
            }
            return(OptimisticSet);
        }
 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 bool CanIndexSetComplex(object Instance, object[] Arguments, string[] ArgumentNames, bool OptimisticSet, bool RValueBase)
 {
     OverloadResolution.ResolutionFailure failure;
     Symbols.Container baseReference = new Symbols.Container(Instance);
     if (baseReference.IsArray)
     {
         return (ArgumentNames.Length == 0);
     }
     string memberName = "";
     BindingFlags setProperty = BindingFlags.SetProperty;
     MemberInfo[] members = baseReference.GetMembers(ref memberName, false);
     if ((members == null) || (members.Length == 0))
     {
         return false;
     }
     Symbols.Method method = ResolveCall(baseReference, memberName, members, Arguments, ArgumentNames, Symbols.NoTypeArguments, setProperty, false, ref failure);
     if (failure != OverloadResolution.ResolutionFailure.None)
     {
         return OptimisticSet;
     }
     if (RValueBase && baseReference.IsValueType)
     {
         return false;
     }
     return true;
 }
 internal static bool CanBindSet(object Instance, string MemberName, object Value, bool OptimisticSet, bool RValueBase)
 {
     OverloadResolution.ResolutionFailure failure;
     Symbols.Container baseReference = new Symbols.Container(Instance);
     object[] arguments = new object[] { Value };
     MemberInfo[] members = baseReference.GetMembers(ref MemberName, false);
     if ((members == null) || (members.Length == 0))
     {
         return false;
     }
     if (members[0].MemberType == MemberTypes.Field)
     {
         if (((arguments.Length == 1) && RValueBase) && baseReference.IsValueType)
         {
             return false;
         }
         return true;
     }
     Symbols.Method method = ResolveCall(baseReference, MemberName, members, arguments, Symbols.NoArgumentNames, Symbols.NoTypeArguments, BindingFlags.SetProperty, false, ref failure);
     if (failure == OverloadResolution.ResolutionFailure.None)
     {
         if (RValueBase && baseReference.IsValueType)
         {
             return false;
         }
         return true;
     }
     BindingFlags lookupFlags = BindingFlags.GetProperty | BindingFlags.InvokeMethod;
     if (failure == OverloadResolution.ResolutionFailure.MissingMember)
     {
         method = ResolveCall(baseReference, MemberName, members, Symbols.NoArguments, Symbols.NoArgumentNames, Symbols.NoTypeArguments, lookupFlags, false, ref failure);
         if (failure == OverloadResolution.ResolutionFailure.None)
         {
             return true;
         }
     }
     return OptimisticSet;
 }