Beispiel #1
0
        public void ParseCsdlEnumTypeWithMembersWorksAsExpected()
        {
            string json = @"""IsolationLevel"": {
  ""$Kind"": ""EnumType"",
  ""$IsFlags"": true,
  ""Snapshot"": 1,
  ""*****@*****.**"": ""All data returned for a request"",
 ""@Core.Description"": ""Supported isolation levels""
        }";

            CsdlEnumType enumType = ParseCsdlSchemaElement(json, SchemaJsonParser.ParseCsdlEnumType);

            Assert.NotNull(enumType);

            Assert.Equal("IsolationLevel", enumType.Name);
            Assert.True(enumType.IsFlags);
            CsdlAnnotation annotation = Assert.Single(enumType.VocabularyAnnotations);

            Assert.Equal("Core.Description", annotation.Term);
            CsdlConstantExpression descripExp = Assert.IsType <CsdlConstantExpression>(annotation.Expression);

            Assert.Equal("Supported isolation levels", descripExp.Value);

            CsdlEnumMember enumMember = Assert.Single(enumType.Members);

            Assert.Equal("Snapshot", enumMember.Name);
            Assert.Equal(1, enumMember.Value.Value);

            annotation = Assert.Single(enumMember.VocabularyAnnotations);
            Assert.Equal("Core.DisplayName", annotation.Term);
            CsdlConstantExpression displayNameExp = Assert.IsType <CsdlConstantExpression>(annotation.Expression);

            Assert.Equal("All data returned for a request", displayNameExp.Value);
        }
Beispiel #2
0
 public CsdlSemanticsEnumTypeDefinition(CsdlSemanticsSchema context, CsdlEnumType enumeration)
     : base(enumeration)
 {
     this.Context     = context;
     this.enumeration = enumeration;
     this.fullName    = EdmUtil.GetFullNameForSchemaElement(this.Context?.Namespace, this.enumeration?.Name);
 }
 public CsdlSemanticsEnumTypeDefinition(CsdlSemanticsSchema context, CsdlEnumType enumeration) : base(enumeration)
 {
     this.underlyingTypeCache = new Cache <CsdlSemanticsEnumTypeDefinition, IEdmPrimitiveType>();
     this.membersCache        = new Cache <CsdlSemanticsEnumTypeDefinition, IEnumerable <IEdmEnumMember> >();
     this.context             = context;
     this.enumeration         = enumeration;
 }
 public CsdlSemanticsEnumTypeDefinition(CsdlSemanticsSchema context, CsdlEnumType enumeration)
     : base(enumeration)
 {
     this.Context     = context;
     this.enumeration = enumeration;
 }
Beispiel #5
0
        internal static CsdlSchema Schema(
            string namespaceName,
            string alias    = null,
            Version version = null,
            CsdlStructuredType[] csdlStructuredTypes = default(CsdlStructuredType[]),
            CsdlEnumType[] csdlEnumTypes             = default(CsdlEnumType[]),
            CsdlOperation[] csdlOperations           = default(CsdlOperation[]),
            CsdlTerm[] csdlTerms = default(CsdlTerm[]),
            CsdlEntityContainer[] csdlEntityContainers = default(CsdlEntityContainer[]),
            CsdlAnnotations[] csdlAnnotations          = default(CsdlAnnotations[]),
            CsdlTypeDefinition[] csdlTypeDefinitions   = default(CsdlTypeDefinition[]),
            CsdlLocation location = null)
        {
            if (csdlStructuredTypes == null)
            {
                csdlStructuredTypes = new CsdlStructuredType[] { };
            }

            if (csdlEnumTypes == null)
            {
                csdlEnumTypes = new CsdlEnumType[] { };
            }

            if (csdlOperations == null)
            {
                csdlOperations = new CsdlOperation[] { };
            }

            if (csdlTerms == null)
            {
                csdlTerms = new CsdlTerm[] { };
            }

            if (csdlEntityContainers == null)
            {
                csdlEntityContainers = new CsdlEntityContainer[] { };
            }

            if (csdlAnnotations == null)
            {
                csdlAnnotations = new CsdlAnnotations[] { };
            }

            if (csdlTypeDefinitions == null)
            {
                csdlTypeDefinitions = new CsdlTypeDefinition[] { };
            }

            var csdlSchema = new CsdlSchema(
                namespaceName,
                alias,
                version,
                csdlStructuredTypes,
                csdlEnumTypes,
                csdlOperations,
                csdlTerms,
                csdlEntityContainers,
                csdlAnnotations,
                csdlTypeDefinitions,
                location /*location*/);

            return(csdlSchema);
        }