Microsoft.CSharp.RuntimeBinder.SymbolTable.PopulateSymbolTableWithName C# (CSharp) Method

PopulateSymbolTableWithName() private method

private PopulateSymbolTableWithName ( string name, IEnumerable typeArguments, Type callingType ) : void
name string
typeArguments IEnumerable
callingType System.Type
return void
        internal void PopulateSymbolTableWithName(
            string name,
            IEnumerable<Type> typeArguments,
            Type callingType)
        {
            // The first argument is the object that we're calling off of.
            if (callingType.GetTypeInfo().IsGenericType)
            {
                callingType = callingType.GetTypeInfo().GetGenericTypeDefinition();
            }
            if (name == SpecialNames.Indexer)
            {
                // What about named indexers?
                if (callingType == typeof(string))
                {
                    name = "Chars";
                }
                else
                {
                    name = "Item";
                }
            }
            NameHashKey key = new NameHashKey(callingType, name);

            // If we've already populated this name/type pair, then just leave.
            if (_namesLoadedForEachType.Contains(key))
            {
                return;
            }

            // Add the names.
            IEnumerable<MemberInfo> members = AddNamesOnType(key);

            // Take each member and load each type's conversions into the symbol table.
            if (members != null)
            {
                foreach (MemberInfo member in members)
                {
                    if (member is MethodInfo)
                    {
                        foreach (ParameterInfo param in (member as MethodInfo).GetParameters())
                        {
                            AddConversionsForType(param.ParameterType);
                        }
                    }
                    else if (member is ConstructorInfo)
                    {
                        foreach (ParameterInfo param in (member as ConstructorInfo).GetParameters())
                        {
                            AddConversionsForType(param.ParameterType);
                        }
                    }
                }
            }

            // Take each type argument and load its conversions into the symbol table.
            if (typeArguments != null)
            {
                foreach (Type o in typeArguments)
                {
                    AddConversionsForType(o);
                }
            }
        }