コード例 #1
0
ファイル: CsdlAssociationEnd.cs プロジェクト: tapika/swupd
 public CsdlAssociationEnd(string role, CsdlTypeReference type, EdmMultiplicity multiplicity, CsdlOnDelete onDelete, CsdlDocumentation documentation, CsdlLocation location)
     : base(role, documentation, location)
 {
     this.type         = type;
     this.multiplicity = multiplicity;
     this.onDelete     = onDelete;
 }
コード例 #2
0
        protected virtual CsdlTypeReference ParseTypeReference(string typeString, XmlElementValueCollection childValues, CsdlLocation parentLocation, Optionality typeInfoOptionality)
        {
            bool isNullable = OptionalBoolean(CsdlConstants.Attribute_Nullable) ?? CsdlConstants.Default_Nullable;

            CsdlTypeReference elementType = null;

            if (typeString != null)
            {
                string[] typeInformation = typeString.Split(new char[] { '(', ')' });
                string   typeName        = typeInformation[0];
                switch (typeName)
                {
                case CsdlConstants.Value_Collection:
                {
                    string elementTypeName = typeInformation.Length > 1 ? typeInformation[1] : typeString;
                    elementType = new CsdlExpressionTypeReference(
                        new CsdlCollectionType(
                            this.ParseNamedTypeReference(elementTypeName, isNullable, parentLocation), parentLocation), isNullable, parentLocation);
                }

                break;

                case CsdlConstants.Value_Ref:
                {
                    string elementTypeName = typeInformation.Length > 1 ? typeInformation[1] : typeString;
                    elementType = new CsdlExpressionTypeReference(
                        new CsdlEntityReferenceType(
                            this.ParseNamedTypeReference(elementTypeName, isNullable, parentLocation), parentLocation), CsdlConstants.Default_Nullable, parentLocation);
                }

                break;

                default:
                    elementType = this.ParseNamedTypeReference(typeName, isNullable, parentLocation);
                    break;
                }
            }
            else if (childValues != null)
            {
                elementType = childValues.ValuesOfType <CsdlTypeReference>().FirstOrDefault();
            }

            if (elementType == null && typeInfoOptionality == Optionality.Required)
            {
                if (childValues != null)
                {
                    // If childValues is null, then it is the case when a required type attribute was expected.
                    // In this case, we do not report the error as it should already be reported by EdmXmlDocumentParser.RequiredType method.
                    this.ReportError(parentLocation, EdmErrorCode.MissingType, Edm.Strings.CsdlParser_MissingTypeAttributeOrElement);
                }
                else
                {
                    Debug.Assert(this.Errors.Any(), "There should be an error reported for the missing required type attribute.");
                }

                elementType = new CsdlNamedTypeReference(String.Empty, isNullable, parentLocation);
            }

            return(elementType);
        }
コード例 #3
0
        /// <summary>
        /// Parse the IsOf expression using <see cref="JsonElement"/>.
        /// </summary>
        /// <param name="element">The input JSON element.</param>
        /// <param name="context">The parser context.</param>
        /// <param name="isOfExp">The built IsOf expression.</param>
        /// <returns>true/false</returns>
        private static bool BuildIsOfExpression(JsonElement element, JsonParserContext context, out CsdlIsTypeExpression isOfExp)
        {
            Debug.Assert(context != null);
            isOfExp = null;

            // Is-of expressions are represented as an object with a member $IsOf whose value is an annotation expression,
            JsonElement propertyValue;

            if (element.ValueKind != JsonValueKind.Object || !element.TryGetProperty("$IsOf", out propertyValue))
            {
                return(false);
            }

            // whose value is  an annotation expression,
            CsdlExpressionBase expression = propertyValue.ProcessProperty("$IsOf", context, ParseExpression);

            // a member $Type whose value is a string containing an qualified type name, and optionally a member $Collection with a value of true.

            // If the specified type is a primitive type or a collection of primitive types,
            // the facet members $MaxLength, $Unicode, $Precision, $Scale, and $SRID MAY be specified if applicable to the specified primitive type.
            // If the facet members are not specified, their values are considered unspecified.
            CsdlTypeReference typeReference = CsdlJsonParseHelper.ParseCsdlTypeReference(element, context);

            isOfExp = new CsdlIsTypeExpression(typeReference, expression, context.Location());
            return(true);
        }
コード例 #4
0
 public CsdlAssociationEnd(string role, CsdlTypeReference type, EdmMultiplicity multiplicity, CsdlOnDelete onDelete, CsdlDocumentation documentation, CsdlLocation location)
     : base(role, documentation, location)
 {
     this.type = type;
     this.multiplicity = multiplicity;
     this.onDelete = onDelete;
 }
コード例 #5
0
 public CsdlProperty(string name, CsdlTypeReference type, bool isFixedConcurrency, string defaultValue, CsdlDocumentation documentation, CsdlLocation location)
     : base(name, documentation, location)
 {
     this.type = type;
     this.isFixedConcurrency = isFixedConcurrency;
     this.defaultValue       = defaultValue;
 }
コード例 #6
0
        private CsdlOperationReturn OnReturnTypeElement(XmlElementInfo element, XmlElementValueCollection childValues)
        {
            string            typeName = RequiredType(CsdlConstants.Attribute_Type);
            CsdlTypeReference type     = this.ParseTypeReference(typeName, childValues, element.Location, Optionality.Required);

            return(new CsdlOperationReturn(type, element.Location));
        }
コード例 #7
0
ファイル: CsdlProperty.cs プロジェクト: larsenjo/odata.net
 public CsdlProperty(string name, CsdlTypeReference type, bool isFixedConcurrency, string defaultValue, CsdlDocumentation documentation, CsdlLocation location)
     : base(name, documentation, location)
 {
     this.type = type;
     this.isFixedConcurrency = isFixedConcurrency;
     this.defaultValue = defaultValue;
 }
コード例 #8
0
        private CsdlTypeReference OnCollectionTypeElement(XmlElementInfo element, XmlElementValueCollection childValues)
        {
            string            elementTypeName = OptionalType(CsdlConstants.Attribute_ElementType);
            CsdlTypeReference elementType     = this.ParseTypeReference(elementTypeName, childValues, element.Location, Optionality.Required);

            return(new CsdlExpressionTypeReference(new CsdlCollectionType(elementType, element.Location), elementType.IsNullable, element.Location));
        }
コード例 #9
0
ファイル: CsdlTerm.cs プロジェクト: noflashbang/odata.net
 public CsdlTerm(string name, CsdlTypeReference type, string appliesTo, string defaultValue, CsdlDocumentation documentation, CsdlLocation location)
     : base(name, documentation, location)
 {
     this.type         = type;
     this.appliesTo    = appliesTo;
     this.defaultValue = defaultValue;
 }
コード例 #10
0
        internal static CsdlFunction Function(
            string name,
            CsdlOperationParameter[] parameters = default(CsdlOperationParameter[]),
            CsdlTypeReference typeReference     = null,
            bool isBound                    = false,
            string entitySetPath            = null,
            bool isComposable               = false,
            CsdlDocumentation documentation = null,
            CsdlLocation location           = null)
        {
            if (parameters == null)
            {
                parameters = new CsdlOperationParameter[] { };
            }

            return(new CsdlFunction(
                       name,
                       parameters,
                       typeReference,
                       isBound,
                       entitySetPath,
                       isComposable,
                       documentation,
                       location));
        }
コード例 #11
0
ファイル: CsdlTerm.cs プロジェクト: larsenjo/odata.net
 public CsdlTerm(string name, CsdlTypeReference type, string appliesTo, string defaultValue, CsdlDocumentation documentation, CsdlLocation location)
     : base(name, documentation, location)
 {
     this.type = type;
     this.appliesTo = appliesTo;
     this.defaultValue = defaultValue;
 }
コード例 #12
0
        private CsdlCollectionExpression OnCollectionElement(XmlElementInfo element, XmlElementValueCollection childValues)
        {
            string            typeName = OptionalType(CsdlConstants.Attribute_Type);
            CsdlTypeReference type     = this.ParseTypeReference(typeName, childValues, element.Location, Optionality.Optional);
            IEnumerable <CsdlExpressionBase> elementValues = childValues.ValuesOfType <CsdlExpressionBase>();

            return(new CsdlCollectionExpression(type, elementValues, element.Location));
        }
コード例 #13
0
        private CsdlOperationParameter OnFunctionImportParameterElement(XmlElementInfo element, XmlElementValueCollection childValues)
        {
            string            name     = Required(CsdlConstants.Attribute_Name);
            string            typeName = RequiredType(CsdlConstants.Attribute_Type);
            CsdlTypeReference type     = this.ParseTypeReference(typeName, null, element.Location, Optionality.Required);

            return(new CsdlOperationParameter(name, type, element.Location));
        }
コード例 #14
0
        private CsdlProperty OnPropertyElement(XmlElementInfo element, XmlElementValueCollection childValues)
        {
            string            typeName     = OptionalType(CsdlConstants.Attribute_Type);
            CsdlTypeReference type         = this.ParseTypeReference(typeName, childValues, element.Location, Optionality.Required);
            string            name         = Required(CsdlConstants.Attribute_Name);
            string            defaultValue = Optional(CsdlConstants.Attribute_DefaultValue);

            return(new CsdlProperty(name, type, defaultValue, element.Location));
        }
コード例 #15
0
        /// <summary>
        /// Parse the record expression expression using <see cref="JsonElement"/>.
        /// </summary>
        /// <param name="element">The input JSON element.</param>
        /// <param name="context">The parser context.</param>
        /// <returns>the built record expression.</returns>
        private static CsdlRecordExpression ParseRecordExpression(JsonElement element, JsonParserContext context)
        {
            Debug.Assert(context != null);

            // A record expression MAY specify the structured type of its result, which MUST be an entity type or complex type in scope.
            // If not explicitly specified, the type is derived from the expression’s context

            // The type of a record expression is represented as the @type control information
            // for example: "@type": "https://example.org/vocabs/person#org.example.person.Manager",
            // So far, ODL doesn't support the type "@type" with relative path, only supports like "#Model.VipCustomer", or without #
            // for 4.0, this name MUST be prefixed with the hash symbol (#);
            // or non-OData 4.0 payloads, built-in primitive type values SHOULD be represented without the hash symbol,
            // but consumers of 4.01 or greater payloads MUST support values with or without the hash symbol.

            CsdlTypeReference typeReference = null;

            if (element.TryGetProperty("@type", out JsonElement typeValue))
            {
                // Try to build the type. The type should be "Complex type" or "Entity Type".
                string typeName = typeValue.ProcessProperty("@type", context, (e, c) => e.ParseAsString(c));
                int    index    = typeName.IndexOf('#');
                if (index >= 0)
                {
                    typeName = typeName.Substring(index + 1); // remove the "#"
                }

                typeReference = new CsdlNamedTypeReference(typeName, true, context.Location());
            }

            IList <CsdlPropertyValue> propertyValues = new List <CsdlPropertyValue>();

            element.ParseAsObject(context, (propertyName, propertyValue) =>
            {
                // skips the @type, because it's processed above.
                if (propertyName == "@type")
                {
                    return;
                }

                // It MAY contain annotations for itself and its members. Annotations for record members are prefixed with the member name.
                // So far, it's not supported. So report non-fatal error for all the annotations on record.
                if (propertyName.IndexOf('@') != -1)
                {
                    context.ReportError(EdmErrorCode.UnsupportedElement, Strings.CsdlJsonParser_UnsupportedJsonMember(context.Path));
                    return;
                }

                CsdlExpressionBase propertyValueExpression = ParseExpression(propertyValue, context);
                propertyValues.Add(new CsdlPropertyValue(propertyName, propertyValueExpression, context.Location()));
            });

            return(new CsdlRecordExpression(typeReference, propertyValues, context.Location()));
        }
コード例 #16
0
        public static CsdlTypeReference ParseCsdlTypeReference(JsonElement element, JsonParserContext context)
        {
            Debug.Assert(element.ValueKind == JsonValueKind.Object);

            // $Type
            // For single-valued terms the value of $Type is the qualified name of the property/term�s type.
            // For collection-valued terms the value of $Type is the qualified name of the term�s item type, and the member $Collection MUST be present with the literal value true.
            // Absence of the $Type member means the type is Edm.String.
            string typeName = element.ParseOptionalProperty("$Type", context, (v, p) => v.ParseAsString(p));

            typeName = typeName == null ? "Edm.String" : typeName;

            // $Collection
            // For collection-valued properties the value of $Type is the qualified name of the property�s item type,
            // and the member $Collection MUST be present with the literal value true.
            bool?collection = element.ParseOptionalProperty("$Collection", context, (v, p) => v.ParseAsBoolean(p));

            // $Nullable,
            // The value of $Nullable is one of the Boolean literals true or false. Absence of the member means false.
            bool?isNullable = element.ParseOptionalProperty("$Nullable", context, (v, p) => v.ParseAsBoolean(p));
            bool nullable   = isNullable == null ? false : isNullable.Value;

            // $MaxLength,
            // The value of $MaxLength is a positive integer.
            // CSDL xml defines a symbolic value max that is only allowed in OData 4.0 responses. This symbolic value is not allowed in CDSL JSON documents at all.
            int?maxLength = element.ParseOptionalProperty("$MaxLength", context, (v, p) => v.ParseAsInteger(p));

            // $Unicode,
            // The value of $Unicode is one of the Boolean literals true or false. Absence of the member means true.
            bool?unicode = element.ParseOptionalProperty("$Unicode", context, (v, p) => v.ParseAsBoolean(p));

            // $Precision,
            // The value of $Precision is a number.
            int?precision = element.ParseOptionalProperty("$Precision", context, (v, p) => v.ParseAsInteger(p));

            // $Scale,
            int?scale = element.ParseOptionalProperty("$Scale", context, (v, p) => v.ParseAsInteger(p));

            // $SRID,
            // The value of $SRID is a string containing a number or the symbolic value variable.
            // So far, ODL doesn't support string of SRID.
            int?srid = element.ParseOptionalProperty("$SRID", context, (v, p) => v.ParseAsInteger(p));

            CsdlLocation      location = context.Location();
            CsdlTypeReference csdlType = ParseNamedTypeReference(typeName, nullable, false, maxLength, unicode, precision, scale, srid, location);

            if (collection != null && collection.Value)
            {
                csdlType = new CsdlExpressionTypeReference(new CsdlCollectionType(csdlType, location), nullable, location);
            }

            return(csdlType);
        }
コード例 #17
0
        private CsdlExpressionBase OnIsTypeExpression(XmlElementInfo element, XmlElementValueCollection childValues)
        {
            string            typeName = OptionalType(CsdlConstants.Attribute_Type);
            CsdlTypeReference type     = this.ParseTypeReference(typeName, childValues, element.Location, Optionality.Required);

            IEnumerable <CsdlExpressionBase> expressions = childValues.ValuesOfType <CsdlExpressionBase>();

            if (expressions.Count() != 1)
            {
                this.ReportError(element.Location, EdmErrorCode.InvalidIsTypeExpressionIncorrectNumberOfOperands, Edm.Strings.CsdlParser_InvalidIsTypeExpressionIncorrectNumberOfOperands);
            }

            return(new CsdlIsTypeExpression(type, expressions.ElementAtOrDefault(0), element.Location));
        }
コード例 #18
0
        private CsdlOperationParameter OnParameterElement(XmlElementInfo element, XmlElementValueCollection childValues)
        {
            string name         = Required(CsdlConstants.Attribute_Name);
            string typeName     = OptionalType(CsdlConstants.Attribute_Type);
            string defaultValue = null;
            bool   isOptional   = false;

            CsdlTypeReference type = this.ParseTypeReference(typeName, childValues, element.Location, Optionality.Required);

            // TODO (Issue #855): handle out-of-line annotations
            XmlElementValue optionalAnnotationValue = childValues.Where(c =>
                                                                        c is XmlElementValue <CsdlAnnotation> &&
                                                                        (c.ValueAs <CsdlAnnotation>().Term == CoreVocabularyModel.OptionalParameterTerm.ShortQualifiedName() ||
                                                                         c.ValueAs <CsdlAnnotation>().Term == CoreVocabularyModel.OptionalParameterTerm.FullName()))
                                                      .FirstOrDefault();

            if (optionalAnnotationValue != null)
            {
                isOptional = true;
                CsdlRecordExpression optionalValueExpression = optionalAnnotationValue.ValueAs <CsdlAnnotation>().Expression as CsdlRecordExpression;
                if (optionalValueExpression != null)
                {
                    foreach (CsdlPropertyValue property in optionalValueExpression.PropertyValues)
                    {
                        CsdlConstantExpression propertyValue = property.Expression as CsdlConstantExpression;
                        if (propertyValue != null)
                        {
                            if (property.Property == CsdlConstants.Attribute_DefaultValue)
                            {
                                defaultValue = propertyValue.Value;
                            }
                        }
                    }
                }

                childValues.Remove(optionalAnnotationValue);
            }

            return(new CsdlOperationParameter(name, type, element.Location, isOptional, defaultValue));
        }
コード例 #19
0
        /// <summary>
        /// Parse the Cast expression using <see cref="JsonElement"/>.
        /// </summary>
        /// <param name="element">The input JSON element.</param>
        /// <param name="context">The parser context.</param>
        /// <param name="castExp">The built cast expression.</param>
        /// <returns>true/false.</returns>
        private static bool TryParseCastExpression(JsonElement element, JsonParserContext context, out CsdlCastExpression castExp)
        {
            Debug.Assert(context != null);

            castExp = null;
            // Cast expressions are represented as an object with a member $Cast
            JsonElement propertyValue;

            if (element.ValueKind != JsonValueKind.Object || !element.TryGetProperty("$Cast", out propertyValue))
            {
                return(false);
            }

            // with a member $Cast whose value is an annotation expression
            CsdlExpressionBase expression = propertyValue.ProcessProperty("$Cast", context, ParseExpression);

            // a member $Type whose value is a string containing the qualified type name, and optionally a member $Collection with a value of true.
            CsdlTypeReference typeReference = CsdlJsonParseHelper.ParseCsdlTypeReference(element, context);

            castExp = new CsdlCastExpression(typeReference, expression, context.Location());
            return(true);
        }
コード例 #20
0
 public CsdlValueTerm(string name, CsdlTypeReference type, CsdlDocumentation documentation, CsdlLocation location)
     : base(name, documentation, location)
 {
     this.type = type;
 }
コード例 #21
0
        internal static IEdmTypeReference WrapTypeReference(CsdlSemanticsSchema schema, CsdlTypeReference type)
        {
            CsdlNamedTypeReference reference = type as CsdlNamedTypeReference;

            if (reference != null)
            {
                CsdlPrimitiveTypeReference reference2 = reference as CsdlPrimitiveTypeReference;
                if (reference2 != null)
                {
                    switch (reference2.Kind)
                    {
                    case EdmPrimitiveTypeKind.Binary:
                        return(new CsdlSemanticsBinaryTypeReference(schema, (CsdlBinaryTypeReference)reference2));

                    case EdmPrimitiveTypeKind.Boolean:
                    case EdmPrimitiveTypeKind.Byte:
                    case EdmPrimitiveTypeKind.Double:
                    case EdmPrimitiveTypeKind.Guid:
                    case EdmPrimitiveTypeKind.Int16:
                    case EdmPrimitiveTypeKind.Int32:
                    case EdmPrimitiveTypeKind.Int64:
                    case EdmPrimitiveTypeKind.SByte:
                    case EdmPrimitiveTypeKind.Single:
                    case EdmPrimitiveTypeKind.Stream:
                        return(new CsdlSemanticsPrimitiveTypeReference(schema, reference2));

                    case EdmPrimitiveTypeKind.DateTime:
                    case EdmPrimitiveTypeKind.DateTimeOffset:
                    case EdmPrimitiveTypeKind.Time:
                        return(new CsdlSemanticsTemporalTypeReference(schema, (CsdlTemporalTypeReference)reference2));

                    case EdmPrimitiveTypeKind.Decimal:
                        return(new CsdlSemanticsDecimalTypeReference(schema, (CsdlDecimalTypeReference)reference2));

                    case EdmPrimitiveTypeKind.String:
                        return(new CsdlSemanticsStringTypeReference(schema, (CsdlStringTypeReference)reference2));

                    case EdmPrimitiveTypeKind.Geography:
                    case EdmPrimitiveTypeKind.GeographyPoint:
                    case EdmPrimitiveTypeKind.GeographyLineString:
                    case EdmPrimitiveTypeKind.GeographyPolygon:
                    case EdmPrimitiveTypeKind.GeographyCollection:
                    case EdmPrimitiveTypeKind.GeographyMultiPolygon:
                    case EdmPrimitiveTypeKind.GeographyMultiLineString:
                    case EdmPrimitiveTypeKind.GeographyMultiPoint:
                    case EdmPrimitiveTypeKind.Geometry:
                    case EdmPrimitiveTypeKind.GeometryPoint:
                    case EdmPrimitiveTypeKind.GeometryLineString:
                    case EdmPrimitiveTypeKind.GeometryPolygon:
                    case EdmPrimitiveTypeKind.GeometryCollection:
                    case EdmPrimitiveTypeKind.GeometryMultiPolygon:
                    case EdmPrimitiveTypeKind.GeometryMultiLineString:
                    case EdmPrimitiveTypeKind.GeometryMultiPoint:
                        return(new CsdlSemanticsSpatialTypeReference(schema, (CsdlSpatialTypeReference)reference2));
                    }
                }
                return(new CsdlSemanticsNamedTypeReference(schema, reference));
            }
            CsdlExpressionTypeReference expressionUsage = type as CsdlExpressionTypeReference;

            if (expressionUsage != null)
            {
                CsdlRowType typeExpression = expressionUsage.TypeExpression as CsdlRowType;
                if (typeExpression != null)
                {
                    return(new CsdlSemanticsRowTypeExpression(expressionUsage, new CsdlSemanticsRowTypeDefinition(schema, typeExpression)));
                }
                CsdlCollectionType collection = expressionUsage.TypeExpression as CsdlCollectionType;
                if (collection != null)
                {
                    return(new CsdlSemanticsCollectionTypeExpression(expressionUsage, new CsdlSemanticsCollectionTypeDefinition(schema, collection)));
                }
                CsdlEntityReferenceType entityTypeReference = expressionUsage.TypeExpression as CsdlEntityReferenceType;
                if (entityTypeReference != null)
                {
                    return(new CsdlSemanticsEntityReferenceTypeExpression(expressionUsage, new CsdlSemanticsEntityReferenceTypeDefinition(schema, entityTypeReference)));
                }
            }
            return(null);
        }
コード例 #22
0
 public CsdlCollectionType(CsdlTypeReference elementType, CsdlLocation location)
     : base(location)
 {
     this.elementType = elementType;
 }
コード例 #23
0
ファイル: CsdlFunctionParameter.cs プロジェクト: tapika/swupd
 public CsdlFunctionParameter(string name, CsdlTypeReference type, EdmFunctionParameterMode mode, CsdlDocumentation documentation, CsdlLocation location)
     : base(name, documentation, location)
 {
     this.type = type;
     this.mode = mode;
 }
コード例 #24
0
 public CsdlEntityReferenceType(CsdlTypeReference entityType, CsdlLocation location)
     : base(location)
 {
     this.entityType = entityType;
 }
コード例 #25
0
 public CsdlOperationParameter(string name, CsdlTypeReference type, CsdlDocumentation documentation, CsdlLocation location)
     : base(name, documentation, location)
 {
     this.type = type;
 }
コード例 #26
0
 public CsdlIsTypeExpression(CsdlTypeReference type, CsdlExpressionBase operand, CsdlLocation location)
     : base(location)
 {
     this.type    = type;
     this.operand = operand;
 }
コード例 #27
0
 public CsdlFunctionReturnType(CsdlTypeReference returnType, CsdlLocation location)
     : base(location)
 {
     this.returnType = returnType;
 }
コード例 #28
0
 public CsdlFunctionParameter(string name, CsdlTypeReference type, EdmFunctionParameterMode mode, CsdlDocumentation documentation, CsdlLocation location)
     : base(name, documentation, location)
 {
     this.type = type;
     this.mode = mode;
 }
コード例 #29
0
 public CsdlOperationParameter(string name, CsdlTypeReference type, CsdlLocation location, bool isOptional, string defaultValue)
     : this(name, type, location)
 {
     this.isOptional   = isOptional;
     this.defaultValue = defaultValue;
 }
コード例 #30
0
 public CsdlProperty(string name, CsdlTypeReference type, string defaultValue, CsdlLocation location)
     : base(name, location)
 {
     this.type         = type;
     this.defaultValue = defaultValue;
 }
コード例 #31
0
 public CsdlCollectionType(CsdlTypeReference elementType, CsdlLocation location)
     : base(location)
 {
     this.elementType = elementType;
 }
コード例 #32
0
 public CsdlIsTypeExpression(CsdlTypeReference type, CsdlExpressionBase operand, CsdlLocation location)
     : base(location)
 {
     this.type = type;
     this.operand = operand;
 }
コード例 #33
0
        internal static IEdmTypeReference WrapTypeReference(CsdlSemanticsSchema schema, CsdlTypeReference type)
        {
            var typeReference = type as CsdlNamedTypeReference;

            if (typeReference != null)
            {
                var primitiveReference = typeReference as CsdlPrimitiveTypeReference;
                if (primitiveReference != null)
                {
                    switch (primitiveReference.Kind)
                    {
                    case EdmPrimitiveTypeKind.Boolean:
                    case EdmPrimitiveTypeKind.Byte:
                    case EdmPrimitiveTypeKind.Date:
                    case EdmPrimitiveTypeKind.Double:
                    case EdmPrimitiveTypeKind.Guid:
                    case EdmPrimitiveTypeKind.Int16:
                    case EdmPrimitiveTypeKind.Int32:
                    case EdmPrimitiveTypeKind.Int64:
                    case EdmPrimitiveTypeKind.SByte:
                    case EdmPrimitiveTypeKind.Single:
                    case EdmPrimitiveTypeKind.Stream:
                        return(new CsdlSemanticsPrimitiveTypeReference(schema, primitiveReference));

                    case EdmPrimitiveTypeKind.Binary:
                        return(new CsdlSemanticsBinaryTypeReference(schema, (CsdlBinaryTypeReference)primitiveReference));

                    case EdmPrimitiveTypeKind.DateTimeOffset:
                    case EdmPrimitiveTypeKind.Duration:
                    case EdmPrimitiveTypeKind.TimeOfDay:
                        return(new CsdlSemanticsTemporalTypeReference(schema, (CsdlTemporalTypeReference)primitiveReference));

                    case EdmPrimitiveTypeKind.Decimal:
                        return(new CsdlSemanticsDecimalTypeReference(schema, (CsdlDecimalTypeReference)primitiveReference));

                    case EdmPrimitiveTypeKind.String:
                        return(new CsdlSemanticsStringTypeReference(schema, (CsdlStringTypeReference)primitiveReference));

                    case EdmPrimitiveTypeKind.Geography:
                    case EdmPrimitiveTypeKind.GeographyPoint:
                    case EdmPrimitiveTypeKind.GeographyLineString:
                    case EdmPrimitiveTypeKind.GeographyPolygon:
                    case EdmPrimitiveTypeKind.GeographyCollection:
                    case EdmPrimitiveTypeKind.GeographyMultiPolygon:
                    case EdmPrimitiveTypeKind.GeographyMultiLineString:
                    case EdmPrimitiveTypeKind.GeographyMultiPoint:
                    case EdmPrimitiveTypeKind.Geometry:
                    case EdmPrimitiveTypeKind.GeometryPoint:
                    case EdmPrimitiveTypeKind.GeometryLineString:
                    case EdmPrimitiveTypeKind.GeometryPolygon:
                    case EdmPrimitiveTypeKind.GeometryCollection:
                    case EdmPrimitiveTypeKind.GeometryMultiPolygon:
                    case EdmPrimitiveTypeKind.GeometryMultiLineString:
                    case EdmPrimitiveTypeKind.GeometryMultiPoint:
                        return(new CsdlSemanticsSpatialTypeReference(schema, (CsdlSpatialTypeReference)primitiveReference));
                    }
                }
                else
                {
                    CsdlUntypedTypeReference csdlUntypedTypeReference = typeReference as CsdlUntypedTypeReference;
                    if (csdlUntypedTypeReference != null)
                    {
                        return(new CsdlSemanticsUntypedTypeReference(schema, csdlUntypedTypeReference));
                    }

                    if (schema.FindType(typeReference.FullName) is IEdmTypeDefinition)
                    {
                        return(new CsdlSemanticsTypeDefinitionReference(schema, typeReference));
                    }
                }

                return(new CsdlSemanticsNamedTypeReference(schema, typeReference));
            }

            var typeExpression = type as CsdlExpressionTypeReference;

            if (typeExpression != null)
            {
                var collectionType = typeExpression.TypeExpression as CsdlCollectionType;
                if (collectionType != null)
                {
                    return(new CsdlSemanticsCollectionTypeExpression(typeExpression, new CsdlSemanticsCollectionTypeDefinition(schema, collectionType)));
                }

                var entityReferenceType = typeExpression.TypeExpression as CsdlEntityReferenceType;
                if (entityReferenceType != null)
                {
                    return(new CsdlSemanticsEntityReferenceTypeExpression(typeExpression, new CsdlSemanticsEntityReferenceTypeDefinition(schema, entityReferenceType)));
                }
            }

            return(null);
        }
コード例 #34
0
 public CsdlEntityReferenceType(CsdlTypeReference entityType, CsdlLocation location)
     : base(location)
 {
     this.entityType = entityType;
 }
コード例 #35
0
 public CsdlOperationReturnType(CsdlTypeReference returnType, CsdlLocation location)
     : base(location)
 {
     this.returnType = returnType;
 }
コード例 #36
0
 public CsdlOperationParameter(string name, CsdlTypeReference type, CsdlDocumentation documentation, CsdlLocation location)
     : base(name, documentation, location)
 {
     this.type = type;
 }