public virtual Dictionary<string, MemberMetadata> GetRegularPropertiesToSerialize(Type type)
{
Argument.IsNotNull("type", type);
return _regularPropertiesToSerializeCache.GetFromCacheOrFetch(type, () =>
{
var serializableMembers = new Dictionary<string, MemberMetadata>();
var catelPropertyNames = new HashSet<string>();
var isModelBase = type.IsModelBase();
if (isModelBase)
{
catelPropertyNames = GetCatelPropertyNames(type, true);
}
var regularProperties = GetRegularProperties(type);
foreach (var typeProperty in regularProperties)
{
var memberMetadata = typeProperty.Value;
var propertyInfo = (PropertyInfo)memberMetadata.Tag;
if (!catelPropertyNames.Contains(memberMetadata.MemberName))
{
// If not a ModelBase, include by default
var include = !isModelBase;
if (AttributeHelper.IsDecoratedWithAttribute<IncludeInSerializationAttribute>(propertyInfo))
{
include = true;
}
if (AttributeHelper.IsDecoratedWithAttribute<ExcludeFromSerializationAttribute>(propertyInfo))
{
include = false;
}
if (include)
{
serializableMembers.Add(typeProperty.Key, memberMetadata);
}
}
}
return serializableMembers;
});
}