public GetRegularProperties ( |
||
type | Type of the model. | |
Résultat | MemberMetadata>.Dictionary |
public Dictionary<string, MemberMetadata> GetRegularProperties(Type type)
{
Argument.IsNotNull("type", type);
return _regularPropertiesCache.GetFromCacheOrFetch(type, () =>
{
var dictionary = new Dictionary<string, MemberMetadata>();
var catelPropertyNames = GetCatelPropertyNames(type, true);
var regularProperties = type.GetPropertiesEx();
foreach (var propertyInfo in regularProperties)
{
if (catelPropertyNames.Contains(propertyInfo.Name) ||
propertyInfo.DeclaringType == typeof(ModelBase))
{
continue;
}
var memberMetadata = new MemberMetadata(type, propertyInfo.PropertyType, SerializationMemberGroup.RegularProperty, propertyInfo.Name)
{
Tag = propertyInfo
};
var nameOverride = GetNameOverrideForSerialization(propertyInfo);
if (!string.IsNullOrWhiteSpace(nameOverride))
{
memberMetadata.MemberNameForSerialization = nameOverride;
}
dictionary[propertyInfo.Name] = memberMetadata;
}
return dictionary;
});
}
/// <summary> /// Gets the type of the member. /// </summary> /// <param name="modelType">Type of the model.</param> /// <param name="memberName">Name of the member.</param> /// <returns>The <see cref="Type"/> of the member.</returns> protected Type GetMemberType(Type modelType, string memberName) { var catelProperties = SerializationManager.GetCatelProperties(modelType); if (catelProperties.ContainsKey(memberName)) { return(catelProperties[memberName].MemberType); } var regularProperties = SerializationManager.GetRegularProperties(modelType); if (regularProperties.ContainsKey(memberName)) { return(regularProperties[memberName].MemberType); } var fields = SerializationManager.GetFields(modelType); if (fields.ContainsKey(memberName)) { return(fields[memberName].MemberType); } return(null); }