Example #1
0
        /// <summary>
        /// Used during the resolve phase to resolve the type name to the object that represents that type
        /// </summary>
        internal override void ResolveTopLevelNames()
        {
            base.ResolveTopLevelNames();

            if (_relationship == null)
            {
                SchemaType element;
                if (!Schema.ResolveTypeName(this, _unresolvedRelationshipTypeName, out element))
                {
                    return;
                }

                _relationship = element as IRelationship;
                if (_relationship == null)
                {
                    AddError(ErrorCode.InvalidPropertyType, EdmSchemaErrorSeverity.Error,
                             System.Data.Entity.Strings.InvalidRelationshipSetType(element.Name));
                    return;
                }
            }

            foreach (EntityContainerRelationshipSetEnd end in Ends)
            {
                end.ResolveTopLevelNames();
            }
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        private bool TryResolveBaseType()
        {
            if (_baseTypeResolveResult.HasValue)
            {
                return(_baseTypeResolveResult.Value);
            }

            if (BaseType != null)
            {
                _baseTypeResolveResult = true;
                return(_baseTypeResolveResult.Value);
            }

            if (UnresolvedBaseType == null)
            {
                _baseTypeResolveResult = true;
                return(_baseTypeResolveResult.Value);
            }

            SchemaType element;

            if (!Schema.ResolveTypeName(this, UnresolvedBaseType, out element))
            {
                _baseTypeResolveResult = false;
                return(_baseTypeResolveResult.Value);
            }

            BaseType = element as StructuredType;
            if (BaseType == null)
            {
                AddError(ErrorCode.InvalidBaseType, EdmSchemaErrorSeverity.Error,
                         System.Data.Entity.Strings.InvalidBaseTypeForStructuredType(UnresolvedBaseType, FQName));
                _baseTypeResolveResult = false;
                return(_baseTypeResolveResult.Value);
            }

            // verify that creating this link to the base type will not introduce a cycle;
            // if so, break the link and add an error
            if (CheckForInheritanceCycle())
            {
                BaseType = null;

                AddError(ErrorCode.CycleInTypeHierarchy, EdmSchemaErrorSeverity.Error,
                         System.Data.Entity.Strings.CycleInTypeHierarchy(FQName));
                _baseTypeResolveResult = false;
                return(_baseTypeResolveResult.Value);
            }

            _baseTypeResolveResult = true;
            return(true);
        }
Example #3
0
 /// <summary>
 /// Resolves the underlying type.
 /// </summary>
 internal override void ResolveTopLevelNames()
 {
     // if the underlying type was not specified in the CSDL we use int by default
     if (_unresolvedUnderlyingTypeName == null)
     {
         _underlyingType = Schema.SchemaManager.SchemaTypes
                           .Single(t => t is ScalarType && ((ScalarType)t).TypeKind == PrimitiveTypeKind.Int32);
     }
     else
     {
         Debug.Assert(_unresolvedUnderlyingTypeName != string.Empty);
         Schema.ResolveTypeName(this, _unresolvedUnderlyingTypeName, out _underlyingType);
     }
 }
        internal override void ResolveTopLevelNames()
        {
            base.ResolveTopLevelNames();

            Debug.Assert(this.Type == null, "This must be resolved exactly once");

            if (Schema.ResolveTypeName(this, UnresolvedType, out _type))
            {
                if (Schema.DataModel == SchemaDataModelOption.ProviderManifestModel && _typeUsageBuilder.HasUserDefinedFacets)
                {
                    bool isInProviderManifest = Schema.DataModel == SchemaDataModelOption.ProviderManifestModel;
                    _typeUsageBuilder.ValidateAndSetTypeUsage((ScalarType)_type, !isInProviderManifest);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        internal override void ResolveTopLevelNames()
        {
            base.ResolveTopLevelNames();

            SchemaType element;

            if (!Schema.ResolveTypeName(this, _unresolvedRelationshipName, out element))
            {
                return;
            }

            _relationship = element as IRelationship;
            if (_relationship == null)
            {
                AddError(ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error,
                         System.Data.Entity.Strings.BadNavigationPropertyRelationshipNotRelationship(_unresolvedRelationshipName));
                return;
            }

            bool foundBothEnds = true;

            if (!_relationship.TryGetEnd(_unresolvedFromEndRole, out _fromEnd))
            {
                AddError(ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error,
                         System.Data.Entity.Strings.BadNavigationPropertyUndefinedRole(_unresolvedFromEndRole, _relationship.FQName));
                foundBothEnds = false;
            }

            if (!_relationship.TryGetEnd(_unresolvedToEndRole, out _toEnd))
            {
                AddError(ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error,
                         System.Data.Entity.Strings.BadNavigationPropertyUndefinedRole(_unresolvedToEndRole, _relationship.FQName));

                foundBothEnds = false;
            }

            if (foundBothEnds && _fromEnd == _toEnd)
            {
                AddError(ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error,
                         System.Data.Entity.Strings.BadNavigationPropertyRolesCannotBeTheSame);
            }
        }
Example #6
0
        /// <summary>
        /// do whole element resolution
        /// </summary>
        internal override void ResolveTopLevelNames()
        {
            base.ResolveTopLevelNames();

            if (Type == null && _unresolvedType != null)
            {
                SchemaType element;
                if (!Schema.ResolveTypeName(this, _unresolvedType, out element))
                {
                    return;
                }

                Type = element as SchemaEntityType;
                if (Type == null)
                {
                    AddError(ErrorCode.InvalidRelationshipEndType, EdmSchemaErrorSeverity.Error,
                             System.Data.Entity.Strings.InvalidRelationshipEndType(ParentElement.Name, element.FQName));
                }
            }
        }
        /// <summary>
        /// Resolve the type string to a SchemaType object
        /// </summary>
        /// <param name="typeName"></param>
        /// <returns></returns>
        protected virtual SchemaType ResolveType(string typeName)
        {
            SchemaType element;

            if (!Schema.ResolveTypeName(this, typeName, out element))
            {
                return(null);
            }

            if (!(element is SchemaComplexType) && !(element is ScalarType) && !(element is SchemaEnumType))
            {
                AddError(ErrorCode.InvalidPropertyType, EdmSchemaErrorSeverity.Error,
                         System.Data.Entity.Strings.InvalidPropertyType(UnresolvedType));
                return(null);
            }

            SchemaType structuredType = element as SchemaType;

            return(element);
        }
Example #8
0
        /// <summary>
        /// Used during the resolve phase to resolve the type name to the object that represents that type
        /// </summary>
        internal override void ResolveTopLevelNames()
        {
            base.ResolveTopLevelNames();

            if (_entityType == null)
            {
                SchemaType type = null;
                if (!Schema.ResolveTypeName(this, _unresolvedEntityTypeName, out type))
                {
                    return;
                }

                _entityType = type as SchemaEntityType;
                if (_entityType == null)
                {
                    AddError(ErrorCode.InvalidPropertyType, EdmSchemaErrorSeverity.Error,
                             System.Data.Entity.Strings.InvalidEntitySetType(_unresolvedEntityTypeName));
                    return;
                }
            }
        }
Example #9
0
        internal override void ResolveTopLevelNames()
        {
            base.ResolveTopLevelNames();

            if (_unresolvedType != null)
            {
                Debug.Assert(Schema.DataModel != SchemaDataModelOption.ProviderManifestModel, "ProviderManifest cannot have ReturnType as an attribute");
                Schema.ResolveTypeName(this, UnresolvedReturnType, out _type);
            }

            if (null != _returnTypeList)
            {
                foreach (ReturnType returnType in _returnTypeList)
                {
                    returnType.ResolveTopLevelNames();
                }
            }

            foreach (Parameter parameter in this.Parameters)
            {
                parameter.ResolveTopLevelNames();
            }
        }
Example #10
0
        internal override void ResolveTopLevelNames()
        {
            if (null != UnresolvedReturnType)
            {
                if (Schema.ResolveTypeName(this, UnresolvedReturnType, out _type))
                {
                    if (_type is ScalarType)
                    {
                        _typeUsageBuilder.ValidateAndSetTypeUsage(_type as ScalarType, false);
                    }
                }
            }

            foreach (Parameter parameter in this.Parameters)
            {
                parameter.ResolveTopLevelNames();
            }

            if (ReturnTypeList != null)
            {
                Debug.Assert(ReturnTypeList.Count == 1, "returnTypeList should always be non-empty.  Multiple ReturnTypes are only possible on FunctionImports.");
                ReturnTypeList[0].ResolveTopLevelNames();
            }
        }