Exemplo n.º 1
0
        public bool RoundDatesEquals(CCompSettings rhs)
        {
            bool result = true;

            List <KeyValuePair <string, string> > roundDates = RoundDates; // Чтобы свойство вычислялось только 1 раз

            if (roundDates == null || roundDates.Count == 0)
            {
                result = rhs.RoundDates == null || rhs.RoundDates.Count == 0;
            }
            else
            {
                List <KeyValuePair <string, string>?> roundDatesrhs = rhs.RoundDates.Cast <KeyValuePair <string, string>?>().ToList(); // Чтобы свойство вычислялось только 1 раз
                foreach (KeyValuePair <string, string> RoundDate in roundDates)
                {
                    KeyValuePair <string, string>?RoundDaterhs = roundDatesrhs.FirstOrDefault(arg => arg.Value.Key == RoundDate.Key);
                    if (RoundDate.Value == null)
                    {
                        result = RoundDaterhs == null;
                    }
                    else
                    {
                        result = RoundDate.Value == RoundDaterhs.Value.Value;
                    }

                    if (!result)
                    {
                        break;
                    }
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public override bool Equals(object o)
        {
            if (o is CCompSettings)
            {
                CCompSettings rhs = o as CCompSettings;
                return(OnlySerializablePropsEquals(rhs) && RoundDatesEquals(rhs));
            }

            return(false);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Равны ли все сериализуемые свойства?
        /// </summary>
        /// <param name="rhs"></param>
        /// <returns></returns>
        public bool OnlySerializablePropsEquals(CCompSettings rhs)
        {
            foreach (PropertyInfo pi in GetType().GetProperties())
            {
                if (!Attribute.IsDefined(pi, typeof(XmlIgnoreAttribute)))
                {   // Свойство сериализуется
                    object lhsVal = pi.GetValue(this, null);
                    object rhsVal = pi.GetValue(rhs, null);
                    if (!(lhsVal == null && rhsVal == null))
                    {
                        if (lhsVal == null || rhsVal == null)
                        {
                            return(false);
                        }
                        else if (!lhsVal.Equals(rhsVal))
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Exemplo n.º 4
0
 public bool DescriptionPropsEquals(CCompSettings rhs)
 {
     return(CompName == rhs.CompName);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Конструктор копирования
 /// </summary>
 /// <param name="rhs"></param>
 public CCompSettings(CCompSettings rhs) :
     base(rhs)
 {
 }