protected override ISourceInfo ResolveSourceValue(MappingMemberInfo memberInfo) { IDictionary <string, TProp> sourceValues = memberInfo.SourceInstance as IDictionary <string, TProp>; if (sourceValues == null) { return(null); } TProp sourceProp; var sourceFound = sourceValues.TryGetValue(memberInfo.Name, out sourceProp); return(!sourceFound ? null : SourceInfo.Create(sourceProp));; }
protected override ISourceInfo ResolveSourceValue(MappingMemberInfo memberInfo) { var sourceValue = memberInfo.SourceInstance; var sourceType = memberInfo.SourceType; var propInfo = TryFindAppropriateProperty(memberInfo.Name, sourceType); if (propInfo == null) { return(null); } var value = propInfo.GetValue(sourceValue); return(new SourceInfo(value) { Attributes = propInfo.GetCustomAttributes().ToArray() }); }
protected override ISourceInfo ResolveSourceValue(MappingMemberInfo memberInfo) { var attribute = memberInfo.Attributes.FirstOrDefault(x => x is InjectValueAttribute) as InjectValueAttribute; if (attribute == null || attribute.Value == null) { Logger.LogError("InjectValueResolver::ResolveSourceValue", "Mappling value is not set"); return(null); } if (attribute.Value is string && string.IsNullOrWhiteSpace(attribute.Value.ToString())) { Logger.LogError("InjectValueResolver::ResolveSourceValue", "Mappling value cannot be empty"); return(null); } var convertedValue = Convert.ChangeType(attribute.Value, memberInfo.Type); return(SourceInfo.Create(convertedValue));; }
protected abstract ISourceInfo ResolveSourceValue(MappingMemberInfo memberInfo);