示例#1
0
 internal MetadataMember ResolveMetadataMemberAccess(
     MetadataMember metadataMember,
     string name,
     ErrorContext errCtx)
 {
     return(this.TypeResolver.ResolveMetadataMemberAccess(metadataMember, name, errCtx));
 }
示例#2
0
        internal MetadataMember ResolveMetadataMemberAccess(MetadataMember qualifier, string name, ErrorContext errCtx)
        {
            var fullName = GetFullName(qualifier.Name, name);

            if (qualifier.MetadataMemberClass
                == MetadataMemberClass.Namespace)
            {
                //
                // Try resolving as a type.
                //
                MetadataType type;
                if (TryGetTypeFromMetadata(fullName, out type))
                {
                    return(type);
                }

                //
                // Try resolving as a function.
                //
                MetadataFunctionGroup function;
                if (TryGetFunctionFromMetadata(qualifier.Name, name, out function))
                {
                    return(function);
                }

                //
                // Otherwise, resolve as a namespace.
                //
                return(new MetadataNamespace(fullName));
            }
            else if (qualifier.MetadataMemberClass
                     == MetadataMemberClass.Type)
            {
                var type = (MetadataType)qualifier;
                if (TypeSemantics.IsEnumerationType(type.TypeUsage))
                {
                    EnumMember member;
                    if (_perspective.TryGetEnumMember(
                            (EnumType)type.TypeUsage.EdmType, name, _parserOptions.NameComparisonCaseInsensitive /*ignoreCase*/, out member))
                    {
                        Debug.Assert(member != null, "member != null");
                        Debug.Assert(
                            _parserOptions.NameComparer.Equals(name, member.Name), "_parserOptions.NameComparer.Equals(name, member.Name)");
                        return(new MetadataEnumMember(fullName, type.TypeUsage, member));
                    }
                    else
                    {
                        var message = Strings.NotAMemberOfType(name, qualifier.Name);
                        throw EntitySqlException.Create(errCtx, message, null);
                    }
                }
            }

            var message1 = Strings.InvalidMetadataMemberClassResolution(
                qualifier.Name, qualifier.MetadataMemberClassName, MetadataNamespace.NamespaceClassName);

            throw EntitySqlException.Create(errCtx, message1, null);
        }
示例#3
0
        // <summary>
        // Initializes TypeResolver instance
        // </summary>
        internal TypeResolver(Perspective perspective, ParserOptions parserOptions)
        {
            DebugCheck.NotNull(perspective);

            _perspective       = perspective;
            _parserOptions     = parserOptions;
            _aliasedNamespaces = new Dictionary <string, MetadataNamespace>(parserOptions.NameComparer);
            _namespaces        = new HashSet <MetadataNamespace>(
                MetadataMember.CreateMetadataMemberNameEqualityComparer(parserOptions.NameComparer));
            _functionDefinitions    = new Dictionary <string, List <InlineFunctionInfo> >(parserOptions.NameComparer);
            _includeInlineFunctions = true;
            _resolveLeftMostUnqualifiedNameAsNamespaceOnly = false;
        }
示例#4
0
        internal MetadataMember ResolveSimpleFunctionName(
            string name,
            ErrorContext errCtx)
        {
            MetadataMember metadataMember = this.TypeResolver.ResolveUnqualifiedName(name, false, errCtx);

            if (metadataMember.MetadataMemberClass == MetadataMemberClass.Namespace)
            {
                EntityContainer      defaultContainer = this.TypeResolver.Perspective.GetDefaultContainer();
                ExpressionResolution resolution;
                if (defaultContainer != null && this.TryResolveEntityContainerMemberAccess(defaultContainer, name, out resolution) && resolution.ExpressionClass == ExpressionResolutionClass.MetadataMember)
                {
                    metadataMember = (MetadataMember)resolution;
                }
            }
            return(metadataMember);
        }
示例#5
0
        internal MetadataMember ResolveMetadataMemberAccess(
            MetadataMember qualifier,
            string name,
            ErrorContext errCtx)
        {
            string fullName = TypeResolver.GetFullName(qualifier.Name, name);

            if (qualifier.MetadataMemberClass == MetadataMemberClass.Namespace)
            {
                MetadataType type;
                if (this.TryGetTypeFromMetadata(fullName, out type))
                {
                    return((MetadataMember)type);
                }
                MetadataFunctionGroup functionGroup;
                if (this.TryGetFunctionFromMetadata(qualifier.Name, name, out functionGroup))
                {
                    return((MetadataMember)functionGroup);
                }
                return((MetadataMember) new MetadataNamespace(fullName));
            }
            if (qualifier.MetadataMemberClass == MetadataMemberClass.Type)
            {
                MetadataType metadataType = (MetadataType)qualifier;
                if (TypeSemantics.IsEnumerationType(metadataType.TypeUsage))
                {
                    EnumMember outMember;
                    if (this._perspective.TryGetEnumMember((EnumType)metadataType.TypeUsage.EdmType, name, this._parserOptions.NameComparisonCaseInsensitive, out outMember))
                    {
                        return((MetadataMember) new MetadataEnumMember(fullName, metadataType.TypeUsage, outMember));
                    }
                    string errorMessage = Strings.NotAMemberOfType((object)name, (object)qualifier.Name);
                    throw EntitySqlException.Create(errCtx, errorMessage, (Exception)null);
                }
            }
            string errorMessage1 = Strings.InvalidMetadataMemberClassResolution((object)qualifier.Name, (object)qualifier.MetadataMemberClassName, (object)MetadataNamespace.NamespaceClassName);

            throw EntitySqlException.Create(errCtx, errorMessage1, (Exception)null);
        }
示例#6
0
 internal TypeResolver(Perspective perspective, ParserOptions parserOptions)
 {
     this._perspective            = perspective;
     this._parserOptions          = parserOptions;
     this._aliasedNamespaces      = new Dictionary <string, MetadataNamespace>((IEqualityComparer <string>)parserOptions.NameComparer);
     this._namespaces             = new HashSet <MetadataNamespace>((IEqualityComparer <MetadataNamespace>)MetadataMember.CreateMetadataMemberNameEqualityComparer(parserOptions.NameComparer));
     this._functionDefinitions    = new Dictionary <string, List <InlineFunctionInfo> >((IEqualityComparer <string>)parserOptions.NameComparer);
     this._includeInlineFunctions = true;
     this._resolveLeftMostUnqualifiedNameAsNamespaceOnly = false;
 }