Ejemplo n.º 1
0
        /// <summary>
        /// Provides an Equals implementation.
        /// </summary>
        /// <param name="inputObject">Input Object.</param>
        /// <returns>True if both the objects are same or else returns false.</returns>
        public override bool Equals(Object inputObject)
        {
            ObjectCommandPropertyValue objectCommandPropertyValueObject = inputObject as ObjectCommandPropertyValue;

            if (objectCommandPropertyValueObject == null)
            {
                return(false);
            }

            object baseObject = PSObject.Base(PropertyValue);
            object inComingbaseObjectPropertyValue = PSObject.Base(objectCommandPropertyValueObject.PropertyValue);

            IComparable baseObjectComparable = baseObject as IComparable;

            if (baseObjectComparable != null)
            {
                return(LanguagePrimitives.Compare(baseObject, inComingbaseObjectPropertyValue, CaseSensitive, Culture) == 0);
            }
            else
            {
                if (baseObject == null && inComingbaseObjectPropertyValue == null)
                {
                    return(true);
                }
                if (baseObject != null && inComingbaseObjectPropertyValue != null)
                {
                    return(baseObject.ToString().Equals(inComingbaseObjectPropertyValue.ToString(), StringComparison.OrdinalIgnoreCase));
                }

                // One of the property values being compared is null.
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Provides an Equals implementation.
        /// </summary>
        /// <param name="inputObject">Input Object.</param>
        /// <returns>True if both the objects are same or else returns false.</returns>
        public override bool Equals(object inputObject)
        {
            ObjectCommandPropertyValue objectCommandPropertyValueObject = inputObject as ObjectCommandPropertyValue;

            if (objectCommandPropertyValueObject == null)
            {
                return(false);
            }

            object baseObject = PSObject.Base(PropertyValue);
            object inComingbaseObjectPropertyValue = PSObject.Base(objectCommandPropertyValueObject.PropertyValue);

            if (baseObject is IComparable)
            {
                var success = LanguagePrimitives.TryCompare(baseObject, inComingbaseObjectPropertyValue, CaseSensitive, Culture, out int result);
                return(success && result == 0);
            }

            if (baseObject == null && inComingbaseObjectPropertyValue == null)
            {
                return(true);
            }

            if (baseObject != null && inComingbaseObjectPropertyValue != null)
            {
                return(baseObject.ToString().Equals(inComingbaseObjectPropertyValue.ToString(), StringComparison.OrdinalIgnoreCase));
            }

            // One of the property values being compared is null.
            return(false);
        }
Ejemplo n.º 3
0
        public int Compare(OrderByPropertyEntry firstEntry, OrderByPropertyEntry secondEntry)
        {
            int num = 0;

            for (int i = 0; i < this.propertyComparers.Length; i++)
            {
                ObjectCommandPropertyValue first  = (i < firstEntry.orderValues.Count) ? firstEntry.orderValues[i] : ObjectCommandPropertyValue.NonExistingProperty;
                ObjectCommandPropertyValue second = (i < secondEntry.orderValues.Count) ? secondEntry.orderValues[i] : ObjectCommandPropertyValue.NonExistingProperty;
                num = this.propertyComparers[i].Compare(first, second);
                if (num != 0)
                {
                    return(num);
                }
            }
            return(num);
        }
Ejemplo n.º 4
0
 internal int Compare(ObjectCommandPropertyValue first, ObjectCommandPropertyValue second)
 {
     if (first.IsExistingProperty && second.IsExistingProperty)
     {
         return this.Compare(first.PropertyValue, second.PropertyValue);
     }
     if (first.IsExistingProperty)
     {
         return -1;
     }
     if (second.IsExistingProperty)
     {
         return 1;
     }
     return 0;
 }
Ejemplo n.º 5
0
 internal int Compare(ObjectCommandPropertyValue first, ObjectCommandPropertyValue second)
 {
     if (first.IsExistingProperty && second.IsExistingProperty)
     {
         return(this.Compare(first.PropertyValue, second.PropertyValue));
     }
     if (first.IsExistingProperty)
     {
         return(-1);
     }
     if (second.IsExistingProperty)
     {
         return(1);
     }
     return(0);
 }
Ejemplo n.º 6
0
        public int Compare(OrderByPropertyEntry firstEntry, OrderByPropertyEntry secondEntry)
        {
            // we have to take into consideration that some vectors
            // might be shorter than others
            int order = 0;

            for (int k = 0; k < _propertyComparers.Length; k++)
            {
                ObjectCommandPropertyValue firstValue = (k < firstEntry.orderValues.Count) ?
                                                        firstEntry.orderValues[k] : ObjectCommandPropertyValue.NonExistingProperty;
                ObjectCommandPropertyValue secondValue = (k < secondEntry.orderValues.Count) ?
                                                         secondEntry.orderValues[k] : ObjectCommandPropertyValue.NonExistingProperty;
                order = _propertyComparers[k].Compare(firstValue, secondValue);

                if (order != 0)
                {
                    return(order);
                }
            }
            return(order);
        }
Ejemplo n.º 7
0
 internal int Compare(ObjectCommandPropertyValue first, ObjectCommandPropertyValue second)
 {
     if (first.IsExistingProperty && second.IsExistingProperty)
     {
         return(Compare(first.PropertyValue, second.PropertyValue));
     }
     // if first.IsExistingProperty, !second.IsExistingProperty; otherwise the
     // first branch if would return. Regardless of key orders non existing property
     // will be considered greater than others
     if (first.IsExistingProperty)
     {
         return(-1);
     }
     // vice versa for the previous branch
     if (second.IsExistingProperty)
     {
         return(1);
     }
     // both are nonexisting
     return(0);
 }
Ejemplo n.º 8
0
 internal int Compare(ObjectCommandPropertyValue first, ObjectCommandPropertyValue second)
 {
     if (first.IsExistingProperty && second.IsExistingProperty)
     {
         return Compare(first.PropertyValue, second.PropertyValue);
     }
     // if first.IsExistingProperty, !second.IsExistingProperty; otherwise the
     // first branch if would return. Regardless of key orders non existing property 
     // will be considered greater than others
     if (first.IsExistingProperty)
     {
         return -1;
     }
     // vice versa for the previous branch
     if (second.IsExistingProperty)
     {
         return 1;
     }
     //both are nonexisting
     return 0;
 }