示例#1
0
        private IEnumerable <IEdmSchemaType> ComputeTypes()
        {
            List <IEdmSchemaType> types = new List <IEdmSchemaType>();

            foreach (var structuredType in this.schema.StructuredTypes)
            {
                CsdlEntityType entity = structuredType as CsdlEntityType;
                if (entity != null)
                {
                    types.Add(new CsdlSemanticsEntityTypeDefinition(this, entity));
                }
                else
                {
                    CsdlComplexType complex = structuredType as CsdlComplexType;
                    if (complex != null)
                    {
                        types.Add(new CsdlSemanticsComplexTypeDefinition(this, complex));
                    }
                }
            }

            foreach (var enumType in this.schema.EnumTypes)
            {
                types.Add(new CsdlSemanticsEnumTypeDefinition(this, enumType));
            }

            return(types);
        }
示例#2
0
        private IEnumerable <IEdmSchemaType> ComputeTypes()
        {
            List <IEdmSchemaType> list = new List <IEdmSchemaType>();

            foreach (CsdlStructuredType type in this.schema.StructuredTypes)
            {
                CsdlEntityType entity = type as CsdlEntityType;
                if (entity != null)
                {
                    list.Add(new CsdlSemanticsEntityTypeDefinition(this, entity));
                }
                else
                {
                    CsdlComplexType complex = type as CsdlComplexType;
                    if (complex != null)
                    {
                        list.Add(new CsdlSemanticsComplexTypeDefinition(this, complex));
                    }
                }
            }
            foreach (CsdlEnumType type4 in this.schema.EnumTypes)
            {
                list.Add(new CsdlSemanticsEnumTypeDefinition(this, type4));
            }
            return(list);
        }
示例#3
0
        private IEnumerable <IEdmSchemaType> ComputeTypes()
        {
            List <IEdmSchemaType> types = new List <IEdmSchemaType>();

            foreach (var typeDefinition in schema.TypeDefinitions)
            {
                this.AttachDefaultPrimitiveValueConverter(typeDefinition);
                types.Add(new CsdlSemanticsTypeDefinitionDefinition(this, typeDefinition));
            }

            foreach (var structuredType in this.schema.StructuredTypes)
            {
                CsdlEntityType entity = structuredType as CsdlEntityType;
                if (entity != null)
                {
                    types.Add(new CsdlSemanticsEntityTypeDefinition(this, entity));
                }
                else
                {
                    CsdlComplexType complex = structuredType as CsdlComplexType;
                    if (complex != null)
                    {
                        types.Add(new CsdlSemanticsComplexTypeDefinition(this, complex));
                    }
                }
            }

            foreach (var enumType in this.schema.EnumTypes)
            {
                types.Add(new CsdlSemanticsEnumTypeDefinition(this, enumType));
            }

            return(types);
        }
 public CsdlSemanticsComplexTypeDefinition(CsdlSemanticsSchema context, CsdlComplexType complex) : base(context, complex)
 {
     this.baseTypeCache = new Cache <CsdlSemanticsComplexTypeDefinition, IEdmComplexType>();
     this.complex       = complex;
 }
示例#5
0
 public CsdlSemanticsComplexTypeDefinition(CsdlSemanticsSchema context, CsdlComplexType complex)
     : base(context, complex)
 {
     this.complex = complex;
 }
示例#6
0
 public CsdlSemanticsComplexTypeDefinition(CsdlSemanticsSchema context, CsdlComplexType complex)
     : base(context, complex)
 {
     this.complex  = complex;
     this.fullName = EdmUtil.GetFullNameForSchemaElement(context?.Namespace, this.complex?.Name);
 }
示例#7
0
        public void ParseCsdlComplexTypeWithMembersWorksAsExpected()
        {
            string json = @"""CountRestrictionsType"": {
    ""$Kind"": ""ComplexType"",
    ""Countable"": {
        ""$Type"": ""Edm.Boolean"",
        ""$DefaultValue"": true,
        ""@Core.Description"": ""Entities can be counted (only valid if targeting an entity set)""
    },
    ""NonCountableProperties"": {
        ""$Collection"": true,
        ""$Type"": ""Edm.PropertyPath"",
        ""@Core.Description"": ""Members of these collection properties cannot be counted""
    },
    ""NonCountableNavigationProperties"": {
        ""$Collection"": true,
        ""$Type"": ""Edm.NavigationPropertyPath"",
        ""@Core.Description"": ""Members of these navigation properties cannot be counted""
    }
}";

            CsdlComplexType complexType = ParseCsdlSchemaElement(json, SchemaJsonParser.ParseCsdlComplexType);

            Assert.NotNull(complexType);

            Assert.Equal("CountRestrictionsType", complexType.Name);
            Assert.False(complexType.IsAbstract);
            Assert.False(complexType.IsOpen);
            Assert.Null(complexType.BaseTypeName);
            Assert.Empty(complexType.NavigationProperties);

            Assert.Equal(3, complexType.StructuralProperties.Count());

            // Countable
            CsdlProperty countable = complexType.StructuralProperties.FirstOrDefault(p => p.Name == "Countable");

            Assert.NotNull(countable);
            CsdlPrimitiveTypeReference primitiveType = Assert.IsType <CsdlPrimitiveTypeReference>(countable.Type);

            Assert.Equal(EdmPrimitiveTypeKind.Boolean, primitiveType.Kind);
            Assert.Equal("true", countable.DefaultValue);
            Assert.IsType <CsdlConstantExpression>(Assert.Single(countable.VocabularyAnnotations).Expression);

            // NonCountableProperties
            CsdlProperty nonCountable = complexType.StructuralProperties.FirstOrDefault(p => p.Name == "NonCountableProperties");

            Assert.NotNull(nonCountable);
            CsdlExpressionTypeReference expressionType = Assert.IsType <CsdlExpressionTypeReference>(nonCountable.Type);
            CsdlNamedTypeReference      namedType      = Assert.IsType <CsdlNamedTypeReference>(Assert.IsType <CsdlCollectionType>(expressionType.TypeExpression).ElementType);

            Assert.Equal("Edm.PropertyPath", namedType.FullName);
            Assert.Null(nonCountable.DefaultValue);
            Assert.IsType <CsdlConstantExpression>(Assert.Single(nonCountable.VocabularyAnnotations).Expression);

            // NonCountableNavigationProperties
            CsdlProperty nonCountableNav = complexType.StructuralProperties.FirstOrDefault(p => p.Name == "NonCountableNavigationProperties");

            Assert.NotNull(nonCountableNav);
            expressionType = Assert.IsType <CsdlExpressionTypeReference>(nonCountableNav.Type);
            namedType      = Assert.IsType <CsdlNamedTypeReference>(Assert.IsType <CsdlCollectionType>(expressionType.TypeExpression).ElementType);
            Assert.Equal("Edm.NavigationPropertyPath", namedType.FullName);
            Assert.Null(nonCountableNav.DefaultValue);
            Assert.IsType <CsdlConstantExpression>(Assert.Single(nonCountableNav.VocabularyAnnotations).Expression);
        }