Example #1
0
        private void HandleInlineTypeElement(XmlReader reader)
        {
            SchemaComplexType schemaComplexType = new SchemaComplexType(this);

            schemaComplexType.Parse(reader);
            this.TryAddType((SchemaType)schemaComplexType, true);
        }
Example #2
0
        // <summary>
        // Handler for the InlineType element
        // </summary>
        // <param name="reader"> xml reader currently positioned at InlineType element </param>
        private void HandleInlineTypeElement(XmlReader reader)
        {
            DebugCheck.NotNull(reader);

            var complexType = new SchemaComplexType(this);

            complexType.Parse(reader);

            TryAddType(complexType, true /*doNotAddErrorForEmptyName*/);
        }
Example #3
0
        private void ValidateFunctionImportReturnType(
            SchemaElement owner,
            SchemaType returnType,
            EntityContainerEntitySet entitySet,
            bool entitySetPathDefined)
        {
            SchemaEntityType schemaEntityType = returnType as SchemaEntityType;

            if (entitySet != null && entitySetPathDefined)
            {
                owner.AddError(ErrorCode.FunctionImportEntitySetAndEntitySetPathDeclared, EdmSchemaErrorSeverity.Error, (object)Strings.FunctionImportEntitySetAndEntitySetPathDeclared((object)this.FQName));
            }
            if (schemaEntityType != null)
            {
                if (entitySet == null)
                {
                    owner.AddError(ErrorCode.FunctionImportReturnsEntitiesButDoesNotSpecifyEntitySet, EdmSchemaErrorSeverity.Error, (object)Strings.FunctionImportReturnEntitiesButDoesNotSpecifyEntitySet((object)this.FQName));
                }
                else
                {
                    if (entitySet.EntityType == null || schemaEntityType.IsOfType((StructuredType)entitySet.EntityType))
                    {
                        return;
                    }
                    owner.AddError(ErrorCode.FunctionImportEntityTypeDoesNotMatchEntitySet, EdmSchemaErrorSeverity.Error, (object)Strings.FunctionImportEntityTypeDoesNotMatchEntitySet((object)this.FQName, (object)entitySet.EntityType.FQName, (object)entitySet.Name));
                }
            }
            else
            {
                SchemaComplexType schemaComplexType = returnType as SchemaComplexType;
                if (schemaComplexType != null)
                {
                    if (entitySet == null && !entitySetPathDefined)
                    {
                        return;
                    }
                    owner.AddError(ErrorCode.ComplexTypeAsReturnTypeAndDefinedEntitySet, EdmSchemaErrorSeverity.Error, owner.LineNumber, owner.LinePosition, (object)Strings.ComplexTypeAsReturnTypeAndDefinedEntitySet((object)this.FQName, (object)schemaComplexType.Name));
                }
                else
                {
                    if (entitySet == null && !entitySetPathDefined)
                    {
                        return;
                    }
                    owner.AddError(ErrorCode.FunctionImportSpecifiesEntitySetButDoesNotReturnEntityType, EdmSchemaErrorSeverity.Error, (object)Strings.FunctionImportSpecifiesEntitySetButNotEntityType((object)this.FQName));
                }
            }
        }
Example #4
0
        // <summary>
        // Handler for the InlineType element
        // </summary>
        // <param name="reader"> xml reader currently positioned at InlineType element </param>
        private void HandleInlineTypeElement(XmlReader reader)
        {
            DebugCheck.NotNull(reader);

            var complexType = new SchemaComplexType(this);

            complexType.Parse(reader);

            TryAddType(complexType, true /*doNotAddErrorForEmptyName*/);
        }
        /// <summary>
        ///     Converts an complex type from SOM to metadata
        /// </summary>
        /// <param name="element"> The SOM element to process </param>
        /// <param name="providerManifest"> The provider manifest to be used for conversion </param>
        /// <param name="convertedItemCache"> The item collection for currently existing metadata objects </param>
        /// <param name="newGlobalItems"> The new GlobalItem objects that are created as a result of this conversion </param>
        /// <returns> The complex type object resulting from the convert </returns>
        private static ComplexType ConvertToComplexType(
            SchemaComplexType element,
            DbProviderManifest providerManifest,
            ConversionCache convertedItemCache,
            Dictionary<SchemaElement, GlobalItem> newGlobalItems)
        {
            var complexType = new ComplexType(
                element.Name,
                element.Namespace,
                GetDataSpace(providerManifest));
            newGlobalItems.Add(element, complexType);

            foreach (var somProperty in element.Properties)
            {
                complexType.AddMember(
                    ConvertToProperty(
                        somProperty,
                        providerManifest,
                        convertedItemCache,
                        newGlobalItems));
            }

            // set the abstract and sealed type values for the entity type
            complexType.Abstract = element.IsAbstract;

            if (element.BaseType != null)
            {
                complexType.BaseType = (EdmType)(LoadSchemaElement(
                    element.BaseType,
                    providerManifest,
                    convertedItemCache,
                    newGlobalItems));
            }

            // Extract the optional Documentation
            if (element.Documentation != null)
            {
                complexType.Documentation = ConvertToDocumentation(element.Documentation);
            }
            AddOtherContent(element, complexType);

            return complexType;
        }