Пример #1
0
 public int CheckIfNull(StoreItem x, StoreItem y)
 {
     if (x == null)
     {
         if (y == null)
         {
             return 0;
         }
         else
         {
             return -1;
         }
     }
     else
     {
         if (y == null)
         {
             return 1;
         }
         else
         {
             return -10; // Not null;
         }
     }
 }
        public virtual void Init(StoreItem item, UnityUIStoreLoader unityStoreLoader)
        {
            storeItem = item;
            storeLoader = unityStoreLoader;
            ItemTextureCache.GetItemTexture(storeItem.ItemInformation.ImageName, OnReceivedItemTexture);
            StoreItemText.text = storeItem.ItemInformation.Name;

            SetPriceDisplay();
        }
Пример #3
0
        public int CompareItemsByPropertys(StoreItem x, StoreItem y)
        {
            int nullcheck = CheckIfNull(x, y);
            if (nullcheck != -10)
            {
                return nullcheck * direction;
            }
            int checkDetails = CheckDetailIsValid(x, y);
            if (checkDetails != -10)
            {
                return checkDetails * direction;
            }

            //List<StoreItemDetail> xDetails = x.ItemDetail;
            //List<StoreItemDetail> YDetails = y.ItemDetail;
            bool xIsPropFound = false;
            bool yIsPropFound = false;
            int xValue = 0;
            int yValue = 0;

            //foreach (StoreItemDetail detail in xDetails)
            //{
            //    if (detail.Name == propertyToSort)
            //    {
            //        xIsPropFound = true;
            //        try
            //        {
            //            xValue = int.Parse(detail.Value.ToString());
            //        }
            //        catch
            //        {
            //            xValue = 0;
            //        }
            //        break;
            //    }
            //}

            //foreach (var detail in YDetails)
            //{
            //    if (detail.Name == propertyToSort)
            //    {
            //        yIsPropFound = true;
            //        try
            //        {
            //            yValue = int.Parse(detail.Value.ToString());
            //        }
            //        catch
            //        {
            //            yValue = 0;
            //        }
            //        break;
            //    }
            //}

            int checkPropertyFound = CheckIsPropertyFound(xIsPropFound, yIsPropFound);
            if (checkPropertyFound != -10)
            {
                return checkPropertyFound;
            }

            if (xValue == yValue)
            {
                return 0;
            }
            else if (xValue < yValue)
            {
                return 1 * direction;
            }
            else
            {
                return -1 * direction;
            }
        }
Пример #4
0
 int CheckDetailIsValid(StoreItem x, StoreItem y)
 {
     //TODO Check for validation
     int returened = -10;
     //if (string.IsNullOrEmpty(x["Detail"].ToString()))
     //{
     //    if (string.IsNullOrEmpty(y["Detail"].ToString()))
     //    {
     //        returened = 0;
     //    }
     //    else
     //    {
     //        returened = 1;
     //    }
     //}
     //else
     //{
     //    if (string.IsNullOrEmpty(y["Detail"].ToString()))
     //    {
     //        returened = -1;
     //    }
     //    else
     //    {
     //        returened = -10; // Not null;
     //    }
     //}
     return returened;
 }