/// <summary> /// Returns an object that can be used to configure a property of the entity type. /// If the specified property is not already part of the model, it will be added. /// </summary> /// <typeparam name="T">The type of the property to be configured.</typeparam> /// <param name="propertyExpression">A lambda expression representing the property to be configured ( blog => blog.Url).</param> /// <returns><see cref="XmlPropertyTypeBuilder{TEntity,TProperty}"/>An object that can be used to configure the property.</returns> public XmlPropertyTypeBuilder <TEntity, T> Property <T>(Expression <Func <TEntity, T> > propertyExpression) { ExpressionHelper.GetPropertyInfo(propertyExpression, out string propertyName, out PropertyInfo propertyInfo); if (propertyInfo.PropertyType.IsInterface && !XmlCollectionHelper.IsSupportedCollectionType(propertyInfo.PropertyType)) { throw new InvalidOperationException($"Serialization/deserialization from interfaces is not allowd. Property:{propertyInfo.DeclaringType.Name}.{propertyName} of type:{propertyInfo.PropertyType.Name}. Choose a concrete type for selected property."); } XmlPropertyTypeInfo xmlPropertyTypeInfo = _xmlEntityTypeInfo.GetOrCreatePropertyTypeInfo(propertyName, propertyInfo); return(new XmlPropertyTypeBuilder <TEntity, T>(_xmlEntityTypeInfo, xmlPropertyTypeInfo, _xmlModelTypeInfo, _xmlModelTypeBuilder)); }
public XmlPropertyTypeInfo GetOrCreatePropertyTypeInfo(Type entityType, string propertyName, PropertyInfo propertyInfo) { XmlEntityTypeInfo xmlEntityTypeInfo = GetOrCreateTypeInfo(entityType); return(xmlEntityTypeInfo.GetOrCreatePropertyTypeInfo(propertyName, propertyInfo)); }