/// <summary>Convert CSpace TypeMetadata into OSpace TypeMetadata</summary> /// <param name="clrType"></param> /// <returns>OSpace type metadata</returns> private EdmType ConvertOSpaceToCSpaceType(EdmType clrType) { EdmType cdmType = null; if (Helper.IsCollectionType(clrType)) { var elemType = ConvertOSpaceToCSpaceType(((CollectionType)clrType).TypeUsage.EdmType); cdmType = new CollectionType(elemType); } else if (Helper.IsRowType(clrType)) { var cdmProperties = new List<EdmProperty>(); var rowType = (RowType)clrType; foreach (var column in rowType.Properties) { var cdmPropertyType = ConvertOSpaceToCSpaceType(column.TypeUsage.EdmType); var cdmPorperty = new EdmProperty(column.Name, TypeUsage.Create(cdmPropertyType)); cdmProperties.Add(cdmPorperty); } cdmType = new RowType(cdmProperties, rowType.InitializerMetadata); } else if (Helper.IsRefType(clrType)) { cdmType = new RefType((EntityType)(ConvertOSpaceToCSpaceType(((RefType)clrType).ElementType))); } else { cdmType = ((ObjectTypeMapping)GetMap(clrType)).EdmType; } Debug.Assert((null != cdmType), "null converted clr type"); return cdmType; }
public void IsCollectionType_returns_true_when_collection_property() { var collectionType = new CollectionType(); var property = new EdmProperty("P", TypeUsage.Create(collectionType)); Assert.False(property.IsComplexType); Assert.False(property.IsPrimitiveType); Assert.False(property.IsEnumType); Assert.True(property.IsCollectionType); }
protected virtual void Visit(CollectionType collectionType) { Visit(collectionType.BaseType); Visit(collectionType.TypeUsage); }
internal override TypeUsage GetTypeUsage() { if (_typeUsage != null) { return _typeUsage; } Debug.Assert(_typeSubElement != null, "For attributes typeusage should have been resolved"); if (_typeSubElement != null) { var collectionType = new CollectionType(_typeSubElement.GetTypeUsage()); collectionType.AddMetadataProperties(OtherContent); _typeUsage = TypeUsage.Create(collectionType); } return _typeUsage; }
protected internal override void VisitCollectionType(CollectionType collectionType) { this._schemaWriter.WriteCollectionTypeElementHeader(); base.VisitCollectionType(collectionType); this._schemaWriter.WriteEndElement(); }
protected override void Visit(CollectionType collectionType) { int index; if (!AddObjectToSeenListAndHashBuilder(collectionType, out index)) { return; } AddObjectStartDumpToHashBuilder(collectionType, index); #region Inner data visit AddObjectContentToHashBuilder(collectionType.Identity); // Identity contains Name, NamespaceName and FullName base.Visit(collectionType); #endregion AddObjectEndDumpToHashBuilder(); }
private static bool TryGetCommonType(CollectionType collectionType1, CollectionType collectionType2, out EdmType commonType) { TypeUsage commonTypeUsage = null; if (!TryGetCommonType(collectionType1.TypeUsage, collectionType2.TypeUsage, out commonTypeUsage)) { commonType = null; return false; } commonType = new CollectionType(commonTypeUsage); return true; }
internal CollectionType(TypeUsage elementType) : base(CollectionType.GetIdentity(Check.NotNull <TypeUsage>(elementType, nameof(elementType))), "Transient", elementType.EdmType.DataSpace) { this._typeUsage = elementType; this.SetReadOnly(); }