Exemplo n.º 1
0
            public void Add(MethodSymbol methodSymbol, MethodInfo methodInfo)
            {
                var key   = GenerateKey(methodSymbol.Name, methodSymbol.GetParameterTypes());
                var entry = new Entry(key, methodSymbol, methodInfo);

                _table.Add(entry.Key, entry);
            }
Exemplo n.º 2
0
        private static void AddMethod(MethodTable methodTable, ICollection <MethodSymbol> methodList, Type declaringType, MethodSymbol methodSymbol, MethodInfo methodInfo)
        {
            // Check if we already have a method with the same name and parameters declared.
            var exisitingMethodEntry = methodTable[methodSymbol.Name, methodSymbol.GetParameterTypes()];

            if (exisitingMethodEntry != null)
            {
                // Ok we have one. Check if the existing member is not more specific.
                if (ExistingMemberIsMoreSpecific(declaringType, exisitingMethodEntry.MethodInfo, methodInfo))
                {
                    // The existing member is more specific. So we don't add the new one.
                    return;
                }

                // The new member is more specific. Remove the old one.
                methodTable.Remove(exisitingMethodEntry);
                methodList.Remove(exisitingMethodEntry.MethodSymbol);
            }

            // Either the new member is more specific or we don't had
            // a member with same name.
            methodTable.Add(methodSymbol, methodInfo);
            methodList.Add(methodSymbol);
        }