private static int?ComputeSrid(IEdmTypeDefinition typeDefinition) { if (typeDefinition.UnderlyingType.IsGeography()) { return(CsdlConstants.Default_SpatialGeographySrid); } if (typeDefinition.UnderlyingType.IsGeometry()) { return(CsdlConstants.Default_SpatialGeometrySrid); } return(null); }
private void VisitTypeDefinition(IEdmTypeDefinition typeDefinition) { string qualifiedName = typeDefinition.FullTypeName(); if (_types.ContainsKey(qualifiedName)) { return; // processed } MetaTypeDefinitionType metaTypeDef = new MetaTypeDefinitionType(); metaTypeDef.QualifiedName = qualifiedName; metaTypeDef.Name = typeDefinition.Name; _types[qualifiedName] = metaTypeDef; }
public void TestAuthorizationVocabularySchemeNameTypeDefinition() { var schemaType = this._authorizationModel.FindDeclaredType("Org.OData.Authorization.V1.SchemeName"); Assert.NotNull(schemaType); Assert.Equal(EdmTypeKind.TypeDefinition, schemaType.TypeKind); IEdmTypeDefinition schemeName = schemaType as IEdmTypeDefinition; Assert.NotNull(schemeName); Assert.Same(EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.String), schemeName.UnderlyingType); string description = this._authorizationModel.GetDescriptionAnnotation(schemeName); Assert.Equal("The name of the authorization scheme.", description); }
/// <summary> /// Initializes a new instance of the <see cref="EdmTypeDefinitionReference"/> class. /// </summary> /// <param name="typeDefinition">The definition refered to by this reference.</param> /// <param name="isNullable">Denotes whether the type can be nullable.</param> /// <param name="isUnbounded">Denotes whether the length is unbounded.</param> /// <param name="maxLength">Maximum length of a value of this type.</param> /// <param name="isUnicode">Denotes if string is encoded using Unicode.</param> /// <param name="precision">Precision of values with this type.</param> /// <param name="scale">Scale of values with this type.</param> /// <param name="spatialReferenceIdentifier">Spatial Reference Identifier for the spatial type being created.</param> public EdmTypeDefinitionReference( IEdmTypeDefinition typeDefinition, bool isNullable, bool isUnbounded, int?maxLength, bool?isUnicode, int?precision, int?scale, int?spatialReferenceIdentifier) : base(typeDefinition, isNullable) { this.IsUnbounded = isUnbounded; this.MaxLength = maxLength; this.IsUnicode = isUnicode; this.Precision = precision; this.Scale = scale; this.SpatialReferenceIdentifier = spatialReferenceIdentifier; }
private static Type GetUnsignedIntInstanceType(IEdmTypeDefinition type, bool isNullable) { if (type == null) { throw new ArgumentNullException("type"); } if (type.Name == "UInt32") { return(isNullable ? typeof(UInt32?) : typeof(UInt32)); } else if (type.Name == "UInt16") { return(isNullable ? typeof(UInt16?) : typeof(UInt16)); } else if (type.Name == "UInt64") { return(isNullable ? typeof(UInt64?) : typeof(UInt64)); } else { return(GetPrimitiveInstanceType(type.UnderlyingType, isNullable)); } }
internal void WriteTypeDefinitionElementHeader(IEdmTypeDefinition typeDefinition) { this.xmlWriter.WriteStartElement(CsdlConstants.Element_TypeDefinition); this.WriteRequiredAttribute(CsdlConstants.Attribute_Name, typeDefinition.Name, EdmValueWriter.StringAsXml); this.WriteRequiredAttribute(CsdlConstants.Attribute_UnderlyingType, typeDefinition.UnderlyingType, this.TypeDefinitionAsXml); }
/// <summary> /// Initializes a new instance of the <see cref="EdmTypeDefinitionReference"/> class. /// </summary> /// <param name="typeDefinition">The definition refered to by this reference.</param> /// <param name="isNullable">Denotes whether the type can be nullable.</param> public EdmTypeDefinitionReference(IEdmTypeDefinition typeDefinition, bool isNullable) : base(typeDefinition, isNullable) { }
protected virtual void ProcessTypeDefinition(IEdmTypeDefinition definition) { this.ProcessSchemaElement(definition); this.ProcessType(definition); this.ProcessSchemaType(definition); }
public static OpenApiSchema CreateSchemaTypeDefinitionSchema(this ODataContext context, IEdmTypeDefinition typeDefinition) { return(context.CreateSchema(typeDefinition.UnderlyingType)); }
protected override void ProcessTypeDefinition(IEdmTypeDefinition element) { base.ProcessTypeDefinition(element); this.CheckSchemaElementReference(element.UnderlyingType); }
internal abstract void WriteTypeDefinitionElementHeader(IEdmTypeDefinition typeDefinition);
/// <summary> /// Attach DefaultPrimitiveValueConverter to the model if the name and the underlying type of the given type definition /// matches the default unsigned int type definitions defined in <see cref="PrimitiveValueConverterConstants"/>. /// </summary> /// <param name="typeDefinition">The type definition to be added to the schema.</param> /// <param name="edmTypeDefinition">The EDM type definition to be added to the model.</param> private void AttachDefaultPrimitiveValueConverter(CsdlTypeDefinition typeDefinition, IEdmTypeDefinition edmTypeDefinition) { Debug.Assert(typeDefinition != null, "typeDefinition != null"); string defaultUnderlyingType; switch (typeDefinition.Name) { case PrimitiveValueConverterConstants.UInt16TypeName: defaultUnderlyingType = PrimitiveValueConverterConstants.DefaultUInt16UnderlyingType; break; case PrimitiveValueConverterConstants.UInt32TypeName: defaultUnderlyingType = PrimitiveValueConverterConstants.DefaultUInt32UnderlyingType; break; case PrimitiveValueConverterConstants.UInt64TypeName: defaultUnderlyingType = PrimitiveValueConverterConstants.DefaultUInt64UnderlyingType; break; default: // Not unsigned int type definition. return; } if (String.CompareOrdinal(defaultUnderlyingType, typeDefinition.UnderlyingTypeName) != 0) { // Not default underlying type for unsigned int. return; } this.Model.SetPrimitiveValueConverter(edmTypeDefinition, DefaultPrimitiveValueConverter.Instance); }
public void ProcessType(IEdmTypeDefinition typeDefinition, bool inCollection) { ProcessType(typeDefinition.UnderlyingType, inCollection); }
private static Type GetUnsignedIntInstanceType(IEdmTypeDefinition type, bool isNullable) { if (type == null) { throw new ArgumentNullException("type"); } if (type.Name == "UInt32") { return isNullable ? typeof(UInt32?) : typeof(UInt32); } else if (type.Name == "UInt16") { return isNullable ? typeof(UInt16?) : typeof(UInt16); } else if (type.Name == "UInt64") { return isNullable ? typeof(UInt64?) : typeof(UInt64); } else { return GetPrimitiveInstanceType(type.UnderlyingType, isNullable); } }
protected override void ProcessTypeDefinition(IEdmTypeDefinition element) { this.BeginElement(element, this.schemaWriter.WriteTypeDefinitionElementHeader); base.ProcessTypeDefinition(element); this.EndElement(element); }
private void VisitTypeDefinition(IEdmTypeDefinition typeDefinition) { }