internal static MemberDataBase MemberDataFromReflection(MemberReference member, DeclaringTypeData declaringType)
        {
            try
            {
                switch (member.MetadataToken.TokenType)
                {
                case TokenType.TypeDef:
                    return(declaringType.AssemblyData.GetTypeData((TypeDefinition)member));

                case TokenType.Method:
                {
                    var method = (MethodDefinition)member;

                    if (method.IsConstructor)
                    {
                        return(ConstructorData.ConstructorDataFromReflection(method, declaringType));
                    }

                    if (method.IsSpecialName)
                    {
                        if (method.IsPublic && method.IsStatic && method.Name.StartsWith("op_"))
                        {
                            return(new OperatorData(method, declaringType));
                        }

                        return(null);
                    }

                    return(MethodData.MethodDataFromReflection(method, declaringType));
                }

                case TokenType.Field:
                {
                    var field = (FieldDefinition)member;

                    // Filter out the "value__" field on enums
                    if (declaringType.TypeKind == TypeKind.Enum && field.IsStatic == false)
                    {
                        return(null);
                    }

                    if (field.IsLiteral && field.IsInitOnly == false)
                    {
                        return(ConstantData.ConstantDataFromReflection(field, declaringType));
                    }

                    return(FieldData.FieldDataFromReflection(field, declaringType));
                }

                case TokenType.Event:
                    return(EventData.EventDataFromReflection((EventDefinition)member, declaringType));

                case TokenType.Property:
                {
                    var property = (PropertyDefinition)member;
                    if (property.HasParameters)
                    {
                        return(IndexerData.IndexerDataFromReflection(property, declaringType));
                    }

                    return(PropertyData.PropertyDataFromReflection(property, declaringType));
                }

                default:
                    Debug.Fail("Unknown TokenType: " + member.MetadataToken.TokenType);
                    return(null);
                }
            }
            catch (AssemblyResolutionException ex)
            {
                // TODO: How should we handle this? This happens when an assembly reference cant be found.
                Debug.Fail("Could not load assembly: " + ex.ToString());
                return(null);
            }
        }
 /// <summary>
 /// The visit implementation for <see cref="ConstantData"/> instances.
 /// </summary>
 public virtual void VisitConstantData(ConstantData item)
 {
     this.DefaultVisit(item);
 }