Exemplo n.º 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);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Compares two PropertyValue objects on specific way - used for joins.
        /// </summary>
        /// <param name="first"></param>
        /// <param name="second"></param>
        /// <returns>TRUE if condition is fulfilled and FALSE in other case.</returns>
        public static bool operator ==(PropertyValue first, PropertyValue 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.GetType() == typeof(LongPropertyValue))
                {
                    if (second.GetType() == typeof(LongPropertyValue))
                    {
                        return(first.LongValue == second.LongValue);
                    }
                    else if (second.GetType() == typeof(LongPropertyValues))
                    {
                        return(second.LongValues.Contains(first.LongValue));
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (first.GetType() == typeof(LongPropertyValues))
                {
                    if (second.GetType() == typeof(LongPropertyValue))
                    {
                        return(first.LongValues.Contains(second.LongValue));
                    }
                    if (second.GetType() == typeof(LongPropertyValues))
                    {
                        return(CompareHelper.CompareLists(first.LongValues, second.LongValues, true));
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (first.GetType() == typeof(FloatPropertyValue))
                {
                    if (second.GetType() == typeof(FloatPropertyValue))
                    {
                        return(first.FloatValue == second.FloatValue);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (first.GetType() == typeof(StringPropertyValue))
                {
                    if (second.GetType() == typeof(StringPropertyValue))
                    {
                        return(first.StringValue == second.StringValue);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (first.GetType() == typeof(FloatPropertyValues))
                {
                    if (second.GetType() == typeof(FloatPropertyValues))
                    {
                        return(CompareHelper.CompareLists(first.FloatValues, second.FloatValues));
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (first.GetType() == typeof(StringPropertyValues))
                {
                    if (second.GetType() == typeof(StringPropertyValues))
                    {
                        return(CompareHelper.CompareLists(first.StringValues, second.StringValues));
                    }
                    else
                    {
                        return(false);
                    }
                }

                return(false);
            }
        }