Esempio n. 1
0
        int Compare(PSObject x, PSObject y)
        {
            if (Descending.ToBool())
            {
                var temp = x;
                x = y;
                y = temp;
            }

            if (this.Property == null)
            {
                return(LanguagePrimitives.Compare(x, y));
            }

            foreach (var property in this.Property)
            {
                var xPropertyValue = x.BaseObject.GetType().GetProperty(property.ToString(), BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase).GetValue(x.BaseObject, null);
                var yPropertyValue = y.BaseObject.GetType().GetProperty(property.ToString(), BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase).GetValue(y.BaseObject, null);

                var result = LanguagePrimitives.Compare(xPropertyValue, yPropertyValue);
                if (result != 0)
                {
                    return(result);
                }
            }

            return(0);
        }
Esempio n. 2
0
        int Compare(PSObject x, PSObject y)
        {
            if (Descending.ToBool())
            {
                var temp = x;
                x = y;
                y = temp;
            }

            if (this.Property == null)
            {
                return(LanguagePrimitives.Compare(x, y));
            }

            foreach (var property in this.Property)
            {
                var xPropertyValue = x.Properties[property.ToString()].Value;
                var yPropertyValue = y.Properties[property.ToString()].Value;

                var result = LanguagePrimitives.Compare(xPropertyValue, yPropertyValue);
                if (result != 0)
                {
                    return(result);
                }
            }

            return(0);
        }