/// <summary> /// Returns a custom type descriptor for the specified type (either an entity or complex type). /// </summary> /// <param name="objectType">Type of object for which we need the descriptor</param> /// <param name="parent">The parent type descriptor</param> /// <returns>Custom type description for the specified type</returns> public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, ICustomTypeDescriptor parent) { // No need to deal with concurrency... Worst case scenario we have multiple // instances of this thing. ICustomTypeDescriptor td = null; if (!this._descriptors.TryGetValue(objectType, out td)) { // call into base so the TDs are chained parent = base.GetTypeDescriptor(objectType, parent); StructuralType edmType = this._typeDescriptionContext.GetEdmType(objectType); if (edmType != null && (edmType.BuiltInTypeKind == BuiltInTypeKind.EntityType || edmType.BuiltInTypeKind == BuiltInTypeKind.ComplexType)) { // only add an LTE TypeDescriptor if the type is an EF Entity or ComplexType td = new LinqToEntitiesTypeDescriptor(this._typeDescriptionContext, edmType, parent); } else { td = parent; } this._descriptors[objectType] = td; } return(td); }
/// <summary> /// Returns a custom type descriptor for the specified type (either an entity or complex type). /// </summary> /// <param name="objectType">Type of object for which we need the descriptor</param> /// <param name="parent">The parent type descriptor</param> /// <returns>Custom type description for the specified type</returns> public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, ICustomTypeDescriptor parent) { // No need to deal with concurrency... Worst case scenario we have multiple // instances of this thing. ICustomTypeDescriptor td = null; if (!this._descriptors.TryGetValue(objectType, out td)) { // call into base so the TDs are chained parent = base.GetTypeDescriptor(objectType, parent); StructuralType edmType = this._typeDescriptionContext.GetEdmType(objectType); if (edmType != null && (edmType.BuiltInTypeKind == BuiltInTypeKind.EntityType || edmType.BuiltInTypeKind == BuiltInTypeKind.ComplexType)) { // only add an LTE TypeDescriptor if the type is an EF Entity or ComplexType td = new LinqToEntitiesTypeDescriptor(this._typeDescriptionContext, edmType, parent); } else { td = parent; } this._descriptors[objectType] = td; } return td; }