private static void RegisterCustomConverter(MetaProperty info) { if (info.CustomConverterType != null) { FieldConverterResolver.Instance.Register(info.CustomConverterType); } }
private static void UpdateDefaultValue(MemberInfo memberInfo, MetaProperty info) { var defaultAttribute = memberInfo.GetCustomAttribute<DefaultValueAttribute>(); if (defaultAttribute == null) return; info.DefaultValue = defaultAttribute.Value; }
private static void UpdateSPFieldInfo(MemberInfo memberInfo, MetaProperty info) { var fieldAttribute = memberInfo.GetCustomAttribute<SpFieldAttribute>(); if (fieldAttribute == null) { throw new ArgumentException(string.Format("Member {0} has no attribute SpFieldAttribute", memberInfo.Name), "memberInfo"); } info.SpFieldInternalName = fieldAttribute.InternalName ?? info.MemberName; info.CustomConverterType = fieldAttribute.CustomConverterType; }
public static MetaProperty Create(FieldInfo fieldInfo) { var info = new MetaProperty { MemberName = fieldInfo.Name, MemberType = fieldInfo.FieldType, }; UpdateSPFieldInfo(fieldInfo, info); UpdateDefaultValue(fieldInfo, info); RegisterCustomConverter(info); return info; }
private static string GetMessage(MetaProperty info) { var message = GetMessage(info.MemberName, info.SpFieldInternalName); message = message + string.Format("Property or field type: {0}.", info.MemberType.FullName); if (info.CustomConverterType != null) { message = message + string.Format("Custom converter type: {0}.", info.CustomConverterType.FullName); } if (info.DefaultValue != null) { message = message + string.Format("Default value type: {0}.", info.DefaultValue.GetType().FullName); } return message; }
internal PropertyMappingException(MetaProperty info, Exception innerException) : base(GetMessage(info), innerException) { }