Beispiel #1
0
        public static bool operator ==(Property first, Property second)
        {
            if (Object.ReferenceEquals(first, null) && Object.ReferenceEquals(second, null))
            {
                return(true);
            }
            else if ((Object.ReferenceEquals(first, null) && !Object.ReferenceEquals(second, null)) || (!Object.ReferenceEquals(first, null) && Object.ReferenceEquals(second, null)))
            {
                return(false);
            }
            else
            {
                if (!first.IsCompatibleWith(second.Type))
                {
                    throw new Exception("Incompatible property types.");
                }

                bool result = false;

                switch (first.Type)
                {
                case PropertyType.Bool:
                case PropertyType.Byte:
                case PropertyType.Int32:
                case PropertyType.Int64:
                case PropertyType.Enum:
                case PropertyType.TimeSpan:
                case PropertyType.DateTime:
                case PropertyType.Reference:
                    if (first.value.LongValue == second.value.LongValue)
                    {
                        result = true;
                    }

                    break;

                case PropertyType.Float:
                    if (first.value.FloatValue == second.value.FloatValue)
                    {
                        result = true;
                    }

                    break;

                case PropertyType.String:
                    if (first.value.StringValue == second.value.StringValue)
                    {
                        result = true;
                    }
                    break;

                case PropertyType.ReferenceVector:
                    result = CompareHelper.CompareLists(first.value.LongValues, second.value.LongValues, true);
                    break;

                case PropertyType.BoolVector:
                case PropertyType.ByteVector:
                case PropertyType.EnumVector:
                case PropertyType.Int32Vector:
                case PropertyType.Int64Vector:
                case PropertyType.DateTimeVector:
                    result = CompareHelper.CompareLists(first.value.LongValues, second.value.LongValues, false);
                    break;

                case PropertyType.FloatVector:
                    result = CompareHelper.CompareLists(first.value.FloatValues, second.value.FloatValues);
                    break;

                case PropertyType.StringVector:
                    result = CompareHelper.CompareLists(first.value.StringValues, second.value.StringValues);
                    break;
                }

                return(result);
            }
        }