示例#1
0
        private static List <TypeEquality> ResolveProperties(List <PropertyInfo> targetProperties,
                                                             List <PropertyInfo> sourceProperties)
        {
            List <TypeEquality> resolvers = new List <TypeEquality>();

            foreach (var targetProperty in targetProperties)
            {
                var targetResolve = new ResolveModel(targetProperty);
                var sources       = ResolveSources(targetProperty, sourceProperties);

                if (sources == null || sources.Count <= 0)
                {
                    continue;
                }
                var currentresolvers = sources.Select(s => new TypeEquality(targetResolve, s)).ToList();

                foreach (var typeEquality in currentresolvers)
                {
                    if (typeEquality.IsTargetString)
                    {
                        typeEquality.UpdateValueHadler(new StringValueHandler());
                    }
                    else if (typeEquality.AreEnumerables)
                    {
                        typeEquality.UpdateValueHadler(new EnumerablesValueHandler());
                    }
                    else if (!typeEquality.AreEquel)
                    {
                        typeEquality.UpdateValueHadler(new DiffrentTypesValueHandler());
                    }
                    else if (typeEquality.AreEquel)
                    {
                        typeEquality.UpdateValueHadler(new SameTypeValueHandler());
                    }
                }

                resolvers.AddRange(currentresolvers);
            }

            return(resolvers);
        }
示例#2
0
 public TypeEquality(ResolveModel targetResolve, ResolveModel sourceResolve)
 {
     SourceResolve = sourceResolve;
     TargetResolve = targetResolve;
 }