Exemple #1
0
        /// <summary>
        /// Gets the sort function.
        /// </summary>
        /// <param name="b1">
        /// The b1.
        /// </param>
        /// <param name="b2">
        /// The b2.
        /// </param>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        public override int GetSortFunction(CatalogValue b1, CatalogValue b2)
        {
            if (b1 == null && b2 != null)
            {
                return(-1);
            }

            if (b1 != null && b2 == null)
            {
                return(1);
            }

            if (b1 == null)
            {
                return(0);
            }

            if (b1.SortInfo > 0)
            {
                if (b2.SortInfo <= 0)
                {
                    return(-1);
                }

                var c = b1.SortInfo - b2.SortInfo;
                return(c == 0 ? string.CompareOrdinal(b1.Text, b2.Text) : c);
            }

            return(b2.SortInfo > 0 ? 1 : string.CompareOrdinal(b1.Text, b2.Text));
        }
Exemple #2
0
        /// <summary>
        /// Adds the with ownership.
        /// </summary>
        /// <param name="catalogValue">
        /// The catalog value.
        /// </param>
        /// <returns>
        /// The <see cref="CatalogValue"/>.
        /// </returns>
        protected virtual CatalogValue AddWithOwnership(CatalogValue catalogValue)
        {
            if (this.Values == null)
            {
                this.Values = new CatalogValueSet();
            }

            return(this.Values.AddWithOwnership(catalogValue));
        }
Exemple #3
0
        /// <summary>
        /// Adds the with ownership.
        /// </summary>
        /// <param name="catalogValue">
        /// The catalog value.
        /// </param>
        /// <returns>
        /// The <see cref="CatalogValue"/>.
        /// </returns>
        public CatalogValue AddWithOwnership(CatalogValue catalogValue)
        {
            if (this.Values == null)
            {
                this.Values = new List <CatalogValue>();
            }

            this.Values.Add(catalogValue);
            this.Unsorted = true;
            return(catalogValue);
        }
Exemple #4
0
        /// <summary>
        /// Fix catalog comparer considering sort information and code.
        /// </summary>
        /// <param name="b1">
        /// The b1.
        /// </param>
        /// <param name="b2">
        /// The b2.
        /// </param>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        private static int FixCatComparerSortInfoAndCode(CatalogValue b1, CatalogValue b2)
        {
            var sortInfo1 = b1.SortInfo;
            var sortInfo2 = b2.SortInfo;

            if (sortInfo1 > 0)
            {
                if (sortInfo2 == 0)
                {
                    return(1);
                }
                else if (sortInfo1 != sortInfo2)
                {
                    return(sortInfo1 - sortInfo2);
                }
            }
            else if (sortInfo2 > 0)
            {
                return(-1);
            }

            return(b1.Code - b2.Code);
        }
Exemple #5
0
 /// <summary>
 /// Fix catalog Comparer.
 /// </summary>
 /// <param name="b1">
 /// The b1.
 /// </param>
 /// <param name="b2">
 /// The b2.
 /// </param>
 /// <returns>
 /// The <see cref="int"/>.
 /// </returns>
 private static int FixCatComparer(CatalogValue b1, CatalogValue b2)
 {
     return(string.CompareOrdinal(b1?.Text, b2?.Text));
 }
Exemple #6
0
 /// <summary>
 /// Gets the sort function.
 /// </summary>
 /// <param name="c1">
 /// The c1.
 /// </param>
 /// <param name="c2">
 /// The c2.
 /// </param>
 /// <returns>
 /// The <see cref="int"/>.
 /// </returns>
 public override int GetSortFunction(CatalogValue c1, CatalogValue c2)
 {
     return(this.Database?.FixedCatSortBySortInfoAndCode ?? false
                ? FixCatComparerSortInfoAndCode(c1, c2)
                : FixCatComparer(c1, c2));
 }
Exemple #7
0
 /// <summary>
 /// Gets the sort function.
 /// </summary>
 /// <param name="c1">
 /// The c1.
 /// </param>
 /// <param name="c2">
 /// The c2.
 /// </param>
 /// <returns>
 /// The <see cref="int"/>.
 /// </returns>
 public virtual int GetSortFunction(CatalogValue c1, CatalogValue c2) => 0;
Exemple #8
0
 /// <summary>
 /// Adds the specified catalog value.
 /// </summary>
 /// <param name="catalogValue">
 /// The catalog value.
 /// </param>
 /// <returns>
 /// The <see cref="CatalogValue"/>.
 /// </returns>
 public CatalogValue Add(CatalogValue catalogValue)
 {
     return(this.AddWithOwnership(catalogValue.CreateCopy()));
 }