Exemplo n.º 1
0
        protected override ItemType CreateItemTypeWithErrorStatus(string errorMessage)
        {
            var newMessageType = new ItemTypeHelper().CreateMessageTypeWithError(errorMessage);

            return(new user_item()
            {
                status = StatusEnumeration.error, message = new MessageType[] { newMessageType }
            });
        }
        private void CheckTypeMatching(QueryItem[] items1, QueryItem[] items2)
        {
            if (this.orderByItemTypes == null)
            {
                lock (this)
                {
                    if (this.orderByItemTypes == null)
                    {
                        this.orderByItemTypes = new ItemType[items1.Length];
                        for (int i = 0; i < items1.Length; ++i)
                        {
                            this.orderByItemTypes[i] = ItemTypeHelper.GetItemType(items1[i].GetItem());
                        }
                    }
                }
            }

            for (int i = 0; i < items1.Length; ++i)
            {
                if (this.orderByItemTypes[i] != ItemTypeHelper.GetItemType(items1[i].GetItem()))
                {
                    throw new NotSupportedException(
                              string.Format(
                                  CultureInfo.InvariantCulture,
                                  RMResources.UnsupportedCrossPartitionOrderByQueryOnMixedTypes,
                                  orderByItemTypes[i],
                                  ItemTypeHelper.GetItemType(items1[i].GetItem()),
                                  items1[i].GetItem()));
                }

                if (this.orderByItemTypes[i] != ItemTypeHelper.GetItemType(items2[i].GetItem()))
                {
                    throw new NotSupportedException(
                              string.Format(
                                  CultureInfo.InvariantCulture,
                                  RMResources.UnsupportedCrossPartitionOrderByQueryOnMixedTypes,
                                  orderByItemTypes[i],
                                  ItemTypeHelper.GetItemType(items2[i].GetItem()),
                                  items2[i].GetItem()));
                }
            }
        }
Exemplo n.º 3
0
    // Load from file
    public bool Load(string fileName)
    {
        MapData mapData = null;

        Helper.Load <MapData>(fileName, ref mapData);

        if (mapData == null)
        {
            Debug.Log("Map not found!");
            return(false);
        }

//		mapData.Log();

        // Clear items
        Clear();

        // Get footholds
        int[,] footholds = mapData.footholds;

        // Set rows
        rows = footholds.GetRow();

        // Set columns
        columns = footholds.GetColumn();

        // Create map items
        _items = new MapItem[rows, columns];

        for (int i = 0; i < rows; i++)
        {
            int row = rows - 1 - i;

            for (int j = 0; j < columns; j++)
            {
                FootholdType footholdType = footholds[i, j].ToFootholdType();

                if (footholdType != FootholdType.None)
                {
                    ItemType itemType = footholdType.ToItemType();

                    AddItem(itemType, GetItemPrefab(itemType), row, j);
                }
            }
        }

        // Set start cell
        _startRow    = rows - 1 - mapData.startRow;
        _startColumn = mapData.startColumn;

        // Set direction
        _direction = mapData.direction;

        // Set time foothold duration
        mapData.DeserializeTimeFootholds((row, column, duration) => {
            MapItem item = _items[rows - 1 - row, column];

            if (item != null)
            {
                TimeScript time = item.item.GetComponent <TimeScript>();

                if (time != null)
                {
                    time.duration = duration;
                }
                else
                {
                    //Log.Debug("TimeScript required!");
                }
            }
            else
            {
                //Log.Debug("TimeFoothold is null!");
            }
        });

        // Get foothold
        GameObject foothold = _items[_startRow, _startColumn].item;

        if (foothold != null)
        {
            // Create frog
            GameObject frog = Instantiate(GetItemPrefab(ItemTypeHelper.GetFrog(_direction))) as GameObject;
            frog.name = "Frog";
            frog.transform.SetParent(foothold.transform);
            frog.transform.localPosition = Vector3.zero;
        }

        return(true);
    }
        public void Aggregate(object item)
        {
            // If the value became undefinded at some point then it should stay that way.
            if (this.value == Undefined.Value)
            {
                return;
            }

            if (item == Undefined.Value)
            {
                // If we got an undefined in the pipeline then the whole thing becomes undefined.
                this.value = Undefined.Value;
                return;
            }

            // Check to see if we got the higher precision result
            // and unwrap the object to get the actual item of interest
            JObject jObject = item as JObject;

            if (jObject != null)
            {
                JToken countToken = jObject["count"];
                if (countToken != null)
                {
                    // We know the object looks like: {"min": MIN(c.blah), "count": COUNT(c.blah)}
                    if (countToken.ToObject <long>() == 0)
                    {
                        // Ignore the value since the continuation / partition had no results that matched the filter so min is undefined.
                        return;
                    }

                    JToken min = jObject["min"];
                    JToken max = jObject["max"];

                    // Note that JToken won't equal null as long as a value is there
                    // even if that value is a JSON null.
                    if (min != null)
                    {
                        item = min.ToObject <object>();
                    }
                    else if (max != null)
                    {
                        item = max.ToObject <object>();
                    }
                    else
                    {
                        item = Undefined.Value;
                    }
                }
            }

            if (!this.initialized)
            {
                // If this is the first item then just take it
                this.value       = item;
                this.initialized = true;
                return;
            }

            if (!ItemTypeHelper.IsPrimitive(item) || !ItemTypeHelper.IsPrimitive(this.value))
            {
                // This means we are comparing non primitives with is undefined
                this.value = Undefined.Value;
                return;
            }

            if (this.isMinAggregation)
            {
                if (ItemComparer.Instance.Compare(item, this.value) < 0)
                {
                    this.value = item;
                }
            }
            else
            {
                if (ItemComparer.Instance.Compare(item, this.value) > 0)
                {
                    this.value = item;
                }
            }

            this.initialized = true;
        }