예제 #1
0
        /// <summary>
        /// Adds a function overload to the group.
        /// </summary>
        /// <param name="functionpointer">The <see cref="FnFunctionPointer"/> that contains the reference to the C# method."</param>
        public void AddFunctionPointer(FnFunctionPointer functionpointer)
        {
            Type[] newFunctionTypeArray = functionpointer.GetFunctionTypeArray();

            //check that an overload of these function types hasn't been previously entered
            for (int i = 0; i < FunctionPointers.Count; i++)
            {
                Type[] currentFunctionsTypeArray = FunctionPointers[i].GetFunctionTypeArray();

                //if we find a potential overload match
                if (currentFunctionsTypeArray.Length == newFunctionTypeArray.Length)
                {
                    for (int j = 0; j < currentFunctionsTypeArray.Length; j++)
                    {
                        //if we find a mismatch
                        if (currentFunctionsTypeArray[j] != newFunctionTypeArray[j])
                        {
                            break;
                        }
                        //else if we get to the end of the list with no mistakes
                        else if (j == currentFunctionsTypeArray.Length - 1)
                        {
                            throw new ArgumentException("The Argument types you have submitted have been previously entered for another overload", "Conflicting overload data: " + newFunctionTypeArray.ToString());
                        }
                    }
                }
            }

            FunctionPointers.Add(functionpointer);
        }
예제 #2
0
 public void AddFunctionPointer(FnFunctionPointer functionpointer)
 {
     Type[] functionTypeArray1 = functionpointer.GetFunctionTypeArray();
     for (int index1 = 0; index1 < this.FunctionPointers.Count; ++index1)
     {
         Type[] functionTypeArray2 = this.FunctionPointers[index1].GetFunctionTypeArray();
         if (functionTypeArray2.Length == functionTypeArray1.Length)
         {
             for (int index2 = 0; index2 < functionTypeArray2.Length && !(functionTypeArray2[index2] != functionTypeArray1[index2]); ++index2)
             {
                 if (index2 == functionTypeArray2.Length - 1)
                 {
                     throw new ArgumentException("The Argument types you have submitted have been previously entered for another overload", "Conflicting overload data: " + functionTypeArray1.ToString());
                 }
             }
         }
     }
     this.FunctionPointers.Add(functionpointer);
 }