Exemplo n.º 1
0
        public static Boolean SameData <T>(this T val1, T val2)
        {
            Boolean issame = true;

            FieldInfo[] fi = val1.GetType().GetFields();
            foreach (FieldInfo f in fi)
            {
                Variance v = new Variance();
                v.Prop = f.Name;
                v.valA = f.GetValue(val1);
                v.valB = f.GetValue(val2);

                if (v.valA != null && v.valB != null)
                {
                    if (!v.valA.Equals(v.valB))
                    {
                        issame = false;
                    }
                }
            }
            return(issame);
        }
Exemplo n.º 2
0
        public static List <Variance> DetailedCompare <T>(this T val1, T val2)
        {
            List <Variance> variances = new List <Variance>();

            FieldInfo[] fi = val1.GetType().GetFields();
            foreach (FieldInfo f in fi)
            {
                Variance v = new Variance();
                v.Prop = f.Name;
                v.valA = f.GetValue(val1);
                v.valB = f.GetValue(val2);

                if (v.valA != null && v.valB != null)
                {
                    if (!v.valA.Equals(v.valB))
                    {
                        variances.Add(v);
                    }
                }
            }
            return(variances);
        }