public virtual Dictionary<string, MemberMetadata> GetCatelPropertiesToSerialize(Type type)
{
Argument.IsNotNull("type", type);
return _catelPropertiesToSerializeCache.GetFromCacheOrFetch(type, () =>
{
var serializableMembers = new Dictionary<string, MemberMetadata>();
var properties = GetCatelProperties(type);
foreach (var modelProperty in properties)
{
var memberMetadata = modelProperty.Value;
var propertyData = (PropertyData)memberMetadata.Tag;
bool isSerializable = propertyData.IsSerializable || propertyData.Type.IsModelBase();
if (!isSerializable)
{
// CTL-550
var cachedPropertyInfo = propertyData.GetPropertyInfo(type);
if (AttributeHelper.IsDecoratedWithAttribute<IncludeInSerializationAttribute>(cachedPropertyInfo.PropertyInfo))
{
isSerializable = true;
}
}
if (!isSerializable)
{
Log.Warning("Property '{0}' is not serializable, so will be excluded from the serialization. If this property needs to be included, use the 'IncludeInSerializationAttribute'", propertyData.Name);
continue;
}
if (!propertyData.IncludeInSerialization)
{
Log.Debug("Property '{0}' is flagged to be excluded from serialization", propertyData.Name);
continue;
}
var propertyInfo = propertyData.GetPropertyInfo(type);
if (propertyInfo != null)
{
if (!AttributeHelper.IsDecoratedWithAttribute<ExcludeFromSerializationAttribute>(propertyInfo.PropertyInfo))
{
serializableMembers.Add(modelProperty.Key, memberMetadata);
}
}
else
{
// Dynamic property, always include
serializableMembers.Add(modelProperty.Key, memberMetadata);
}
}
return serializableMembers;
});
}