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); }
protected internal virtual void SetField(int sequenceNumber, int length, DataType dataType, Optionality optionalCode, string elementName, string value = null) { _items.Add(new AbstractSequenceItem(sequenceNumber, length, dataType, optionalCode.GetDescription(), "*", elementName, value)); }