Ejemplo n.º 1
0
        public Method FindMethodByName(string name)
        {
            //
            // First make a quick, case-sensitive look-up.
            //

            int i = InvariantStringArray.BinarySearch(_methodNames, name);

            if (i >= 0)
            {
                return(_sortedMethods[i]);
            }

            //
            // Failing, use a slower case-insensitive look-up.
            // TODO: Consider speeding up FindMethodByName for case-insensitive look-ups.
            //

            foreach (Method method in _methods)
            {
                if (CaselessString.Equals(method.Name, name))
                {
                    return(method);
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
 private object[] MapArguments(string[] names, object[] args)
 {
     Debug.Assert(names != null);
     Debug.Assert(args != null);
     Debug.Assert(names.Length == args.Length);
     object[] objArray = new object[this._parameters.Length];
     for (int i = 0; i < names.Length; i++)
     {
         string s = names[i];
         if ((s != null) && (s.Length != 0))
         {
             object obj2 = args[i];
             if (obj2 != null)
             {
                 int index = -1;
                 if (s.Length <= 2)
                 {
                     char ch;
                     char ch2;
                     if (s.Length == 2)
                     {
                         ch  = s[0];
                         ch2 = s[1];
                     }
                     else
                     {
                         ch  = '0';
                         ch2 = s[0];
                     }
                     if ((((ch >= '0') && (ch <= '9')) && (ch2 >= '0')) && (ch2 <= '9'))
                     {
                         index = int.Parse(s, NumberStyles.Number, CultureInfo.InvariantCulture);
                         if (index < this._parameters.Length)
                         {
                             objArray[index] = obj2;
                         }
                     }
                 }
                 if (index < 0)
                 {
                     int num3 = InvariantStringArray.BinarySearch(this._parameterNames, s);
                     if (num3 >= 0)
                     {
                         index = this._sortedParameters[num3].Position;
                     }
                 }
                 if (index >= 0)
                 {
                     objArray[index] = obj2;
                 }
             }
         }
     }
     return(objArray);
 }
Ejemplo n.º 3
0
        private object[] MapArguments(string[] names, object[] args)
        {
            Debug.Assert(names != null);
            Debug.Assert(args != null);
            Debug.Assert(names.Length == args.Length);

            object[] mapped = new object[_parameters.Length];

            for (int i = 0; i < names.Length; i++)
            {
                string name = names[i];

                if (name == null || name.Length == 0)
                {
                    continue;
                }

                object arg = args[i];

                if (arg == null)
                {
                    continue;
                }

                int position = -1;

                if (name.Length <= 2)
                {
                    char ch1;
                    char ch2;

                    if (name.Length == 2)
                    {
                        ch1 = name[0];
                        ch2 = name[1];
                    }
                    else
                    {
                        ch1 = '0';
                        ch2 = name[0];
                    }

                    if (ch1 >= '0' && ch1 <= '9' &&
                        ch2 >= '0' && ch2 <= '9')
                    {
                        position = int.Parse(name, NumberStyles.Number, CultureInfo.InvariantCulture);

                        if (position < _parameters.Length)
                        {
                            mapped[position] = arg;
                        }
                    }
                }

                if (position < 0)
                {
                    int order = InvariantStringArray.BinarySearch(_parameterNames, name, /* ignoreCase */ true);
                    if (order >= 0)
                    {
                        position = _sortedParameters[order].Position;
                    }
                }

                if (position >= 0)
                {
                    mapped[position] = arg;
                }
            }

            return(mapped);
        }