internal bool TryGetType(
            PrimitiveTypeKind primitiveTypeKind,
            IEnumerable <Facet> facets,
            out PrimitiveType type)
        {
            type = (PrimitiveType)null;
            List <PrimitiveType> primitiveTypeList = EntityUtil.CheckArgumentOutOfRange <List <PrimitiveType> >(this._primitiveTypeMap, (int)primitiveTypeKind, nameof(primitiveTypeKind));

            if (primitiveTypeList == null || 0 >= primitiveTypeList.Count)
            {
                return(false);
            }
            if (primitiveTypeList.Count == 1)
            {
                type = primitiveTypeList[0];
                return(true);
            }
            if (facets == null)
            {
                FacetDescription[] facetDescriptions = EdmProviderManifest.GetInitialFacetDescriptions(primitiveTypeKind);
                if (facetDescriptions == null)
                {
                    type = primitiveTypeList[0];
                    return(true);
                }
                facets = (IEnumerable <Facet>)CacheForPrimitiveTypes.CreateInitialFacets(facetDescriptions);
            }
            bool flag = false;

            foreach (Facet facet in facets)
            {
                if ((primitiveTypeKind == PrimitiveTypeKind.String || primitiveTypeKind == PrimitiveTypeKind.Binary) && (facet.Value != null && facet.Name == "MaxLength") && Helper.IsUnboundedFacetValue(facet))
                {
                    flag = true;
                }
            }
            int num1 = 0;

            foreach (PrimitiveType primitiveType in primitiveTypeList)
            {
                if (flag)
                {
                    if (type == null)
                    {
                        type = primitiveType;
                        num1 = Helper.GetFacet((IEnumerable <FacetDescription>)primitiveType.FacetDescriptions, "MaxLength").MaxValue.Value;
                    }
                    else
                    {
                        int num2 = Helper.GetFacet((IEnumerable <FacetDescription>)primitiveType.FacetDescriptions, "MaxLength").MaxValue.Value;
                        if (num2 > num1)
                        {
                            type = primitiveType;
                            num1 = num2;
                        }
                    }
                }
                else
                {
                    type = primitiveType;
                    break;
                }
            }
            return(true);
        }