Example #1
0
        public void Map(string inlineEditProperty = null)
        {
            var fromType       = FromModel.GetType();
            var fromProperties = fromType.GetProperties(BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);

            var toType       = ToModel.GetType();
            var toProperties = toType.GetProperties(BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);

            // if include list is not null then only update property in the list
            if (!string.IsNullOrWhiteSpace(inlineEditProperty))
            {
                toProperties = toProperties.Where(w => w.Name == inlineEditProperty).ToArray();
            }

            foreach (var toPropertyInfo in toProperties)
            {
                var fromPropertyInfo = fromProperties.SingleOrDefault(w => w.Name == toPropertyInfo.Name);
                if (fromPropertyInfo == null)
                {
                    continue;
                }

                HandleBool(toPropertyInfo, fromPropertyInfo.GetValue(FromModel, null));
                HandleInt(toPropertyInfo, fromPropertyInfo.GetValue(FromModel, null));
                HandleString(toPropertyInfo, fromPropertyInfo.GetValue(FromModel, null));
                HandleDateTime(toPropertyInfo, fromPropertyInfo.GetValue(FromModel, null));
            }
        }
Example #2
0
 public ToFro(FromModel fromModel, FromObject fromObject)
 {
     FromModel = fromModel;
     FromObject = fromObject;
 }
Example #3
0
 public ToFro(FromModel fromModel, FromObject fromObject)
 {
     FromModel  = fromModel;
     FromObject = fromObject;
 }