Beispiel #1
0
        private ISourceInfo GetProperyByPath(MapSourcePropertyAttribute srcPropMap, object sourceValue)
        {
            object propValue;
            var    path = srcPropMap.Path.Split('.');

            PropertyInfo prop;

            propValue = sourceValue;

            for (int i = 0; i < path.Length; i++)
            {
                prop = TryFindAppropriateProperty(path[i], propValue.GetType());
                if (prop == null)
                {
                    propValue = null;
                    break;
                }
                propValue = prop.GetValue(propValue);
                if (propValue == null)
                {
                    return(null);
                }
            }
            return(SourceInfo.Create(propValue));
        }
Beispiel #2
0
        private ISourceInfo GetPropertyByName(MappingMemberInfo memberInfo, MapSourcePropertyAttribute srcPropMap,
                                              object sourceValue)
        {
            var sourceType = memberInfo.SourceType;
            var srcProp    = TryFindAppropriateProperty(srcPropMap.Name, sourceType);

            var value = srcProp.GetValue(sourceValue);

            return(new SourceInfo(value)
            {
                Attributes = srcProp.GetCustomAttributes().ToArray()
            });
        }