internal override bool ResolveNameAndSetTypeUsage(
            Converter.ConversionCache convertedItemCache, Dictionary<SchemaElement, GlobalItem> newGlobalItems)
        {
            if (_typeUsage == null)
            {
                Debug.Assert(!(_type is ScalarType));

                var edmType = (EdmType)Converter.LoadSchemaElement(_type, _type.Schema.ProviderManifest, convertedItemCache, newGlobalItems);
                var entityType = edmType as EntityType;

                Debug.Assert(entityType != null);

                var refType = new RefType(entityType);
                refType.AddMetadataProperties(OtherContent);
                _typeUsage = TypeUsage.Create(refType);
            }
            return true;
        }
        internal override bool ResolveNameAndSetTypeUsage(
            Converter.ConversionCache convertedItemCache, Dictionary<SchemaElement, GlobalItem> newGlobalItems)
        {
            if (_type is ScalarType) //Create and store type usage for scalar type
            {
                _typeUsageBuilder.ValidateAndSetTypeUsage(_type as ScalarType, false);
                _typeUsage = _typeUsageBuilder.TypeUsage;
                return true;
            }
            else //Try to resolve edm type. If not now, it will resolve in the second pass
            {
                var edmType = (EdmType)Converter.LoadSchemaElement(_type, _type.Schema.ProviderManifest, convertedItemCache, newGlobalItems);
                if (edmType != null)
                {
                    _typeUsageBuilder.ValidateAndSetTypeUsage(edmType, false); //use typeusagebuilder so dont lose facet information
                    _typeUsage = _typeUsageBuilder.TypeUsage;
                }

                return _typeUsage != null;
            }
        }
 internal bool ResolveNestedTypeNames(
     Converter.ConversionCache convertedItemCache, Dictionary<SchemaElement, GlobalItem> newGlobalItems)
 {
     if (_typeSubElement == null)
     {
         return false;
     }
     return _typeSubElement.ResolveNameAndSetTypeUsage(convertedItemCache, newGlobalItems);
 }
        internal override bool ResolveNameAndSetTypeUsage(
            Converter.ConversionCache convertedItemCache, Dictionary<SchemaElement, GlobalItem> newGlobalItems)
        {
            if (_typeUsage == null)
            {
                if (_typeSubElement != null) //Has sub-elements
                {
                    return _typeSubElement.ResolveNameAndSetTypeUsage(convertedItemCache, newGlobalItems);
                }
                else //Does not have sub-elements; try to resolve
                {
                    if (_type is ScalarType) //Create and store type usage for scalar type
                    {
                        _typeUsageBuilder.ValidateAndSetTypeUsage(_type as ScalarType, false);
                        _typeUsage = _typeUsageBuilder.TypeUsage;
                    }
                    else //Try to resolve edm type. If not now, it will resolve in the second pass
                    {
                        var edmType =
                            (EdmType)Converter.LoadSchemaElement(_type, _type.Schema.ProviderManifest, convertedItemCache, newGlobalItems);
                        if (edmType != null)
                        {
                            if (_isRefType)
                            {
                                var entityType = edmType as EntityType;
                                DebugCheck.NotNull(entityType);
                                _typeUsage = TypeUsage.Create(new RefType(entityType));
                            }
                            else
                            {
                                _typeUsageBuilder.ValidateAndSetTypeUsage(edmType, false);
                                //use typeusagebuilder so dont lose facet information
                                _typeUsage = _typeUsageBuilder.TypeUsage;
                            }
                        }
                    }
                    if (_collectionKind != CollectionKind.None)
                    {
                        _typeUsage = TypeUsage.Create(new CollectionType(_typeUsage));
                    }

                    return _typeUsage != null;
                }
            }
            return true;
        }
 internal override bool ResolveNameAndSetTypeUsage(
     Converter.ConversionCache convertedItemCache, Dictionary<SchemaElement, GlobalItem> newGlobalItems)
 {
     var result = true;
     if (_typeUsage == null)
     {
         foreach (var property in _properties)
         {
             if (!property.ResolveNameAndSetTypeUsage(convertedItemCache, newGlobalItems))
             {
                 result = false;
             }
         }
     }
     return result;
 }
 internal abstract bool ResolveNameAndSetTypeUsage(
     Converter.ConversionCache convertedItemCache, Dictionary<SchemaElement, GlobalItem> newGlobalItems);
        internal override bool ResolveNameAndSetTypeUsage(
            Converter.ConversionCache convertedItemCache, Dictionary<SchemaElement, GlobalItem> newGlobalItems)
        {
            Debug.Fail(
                "This method was not called from anywhere in the code before. If you got here you need to update this method and possibly ResolveNestedTypeNames()");

            return false;
        }
 internal bool ResolveNestedTypeNames(
     Converter.ConversionCache convertedItemCache, Dictionary<SchemaElement, GlobalItem> newGlobalItems)
 {
     Debug.Assert(_typeSubElement != null, "Nested type expected.");
     return _typeSubElement.ResolveNameAndSetTypeUsage(convertedItemCache, newGlobalItems);
 }
 internal void EnsureEnumTypeFacets(
     Converter.ConversionCache convertedItemCache, Dictionary<SchemaElement, GlobalItem> newGlobalItems)
 {
     Debug.Assert(Type is SchemaEnumType);
     var propertyType = (EdmType)Converter.LoadSchemaElement(Type, Type.Schema.ProviderManifest, convertedItemCache, newGlobalItems);
     _typeUsageBuilder.ValidateAndSetTypeUsage(propertyType, false); //use typeusagebuilder so dont lose facet information
 }