Пример #1
0
 public virtual void Check(Hero request, IMonster monster)
 {
     if (nextCheck != null)
     {
         nextCheck.Check(request, monster);
     }
 }
Пример #2
0
    public static void ItemCheck(AssetFilter filter)
    {
        ICheck checkTypd = (ICheck)Activator.CreateInstance(Type.GetType(filter.CheckTagString));

        string[]      guids   = AssetDatabase.FindAssets(checkTypd.SearchTag, new string[] { filter.path });
        float         count   = guids.Length;
        float         index   = 1;
        List <string> fixList = new List <string>();

        foreach (string guid in guids)
        {
            string assetPath = AssetDatabase.GUIDToAssetPath(guid);
            string info      = String.Format("{0}/{1} {2}", index, count, assetPath);
            ICheck _check    = (ICheck)Activator.CreateInstance(Type.GetType(filter.CheckTagString));
            EditorUtility.DisplayProgressBar(_check.GetType().Name + " Check", info, (float)(index / count));

            if (!string.IsNullOrEmpty(assetPath))
            {
                if (!_check.Check(AssetDatabase.GUIDToAssetPath(guid)))
                {
                    fixList.Add(assetPath);
                    mDictionaryCheck[filter.CheckTagString].Add(_check);
                    if (!_check.CanFix)
                    {
                        Debug.LogError(info + " can not auto fix");
                    }
                }
            }
            else
            {
                Debug.LogError(info + " error" + _check.GetType().Name);
            }

            index++;
        }
        List <ICheck> list = mDictionaryCheck[filter.CheckTagString];

        if (checkTypd.CanFix)
        {
            index = 1;
            count = fixList.Count;
            foreach (var assetPath in fixList)
            {
                string info = String.Format("{0}/{1} {2}", index, count, assetPath);
                EditorUtility.DisplayProgressBar(checkTypd.GetType().Name + " Fix", info, (float)(index / count));
                if (checkTypd.Fix(assetPath))
                {
                    Debug.Log(info + " Fixed");
                }
                else
                {
                    Debug.LogError(info + "auto fix fail");
                }
                index++;
            }
        }
        EditorUtility.ClearProgressBar();
    }
Пример #3
0
        public List <int> Search(ICheck check, Func <int, bool> callback)
        {
            if (m_position != m_indices.Length)
            {
                throw new Exception("Data not yet indexed - call RTree::finish().");
            }

            var node_index = m_indices.Length - 1;
            var level      = m_level_bounds.Count - 1;
            var queue      = new Queue <int>();
            var results    = new List <int>();

            while (node_index > -1)
            {
                var end = Math.Min(node_index + m_node_size, m_level_bounds[level]);

                for (var pos = node_index; pos < end; pos++)
                {
                    int index = m_indices[pos];

                    var node_min = m_boxes_min[pos];
                    var node_max = m_boxes_max[pos];

                    if (!check.Check(node_min, node_max))
                    {
                        continue;
                    }

                    if (node_index < m_nb_items)
                    {
                        if (callback == null || callback(index))
                        {
                            results.Add(index);
                        }
                    }
                    else
                    {
                        queue.Enqueue(index);
                        queue.Enqueue(level - 1);
                    }
                }

                if (queue.Count == 0)
                {
                    node_index = -1;
                    level      = -1;
                }
                else
                {
                    level      = queue.Dequeue();
                    node_index = queue.Dequeue();
                }
            }

            return(results);
        }
Пример #4
0
 protected override void CheckResponse(Response response)
 {
     if (_responseCheck != null)
     {
         if (!_responseCheck.Check(response, _request, null))
         {
             AppendReason(_responseCheck.Reason);
         }
     }
 }
Пример #5
0
        public Boolean Go(ITestContext context, String serverURI, TestCaseItem tcItem, int value)
        {
            Request  request  = context.RequestQueue.Poll(1000);
            Response response = context.ResponseQueue.Poll(2000);

            if (response == null)
            {
                context.Verbose.Append("           \t          \t            ");
                _summeries = new String[] { "Timeout" };

                StepItem stepItem = new StepItem();
                //stepItem.RowItemList = new List<RowItem>();
                stepItem.IsPassed  = false;
                stepItem.IsRequest = false;
                //stepItem.Name = response.Type.ToString() + " Response Code=" + response.Code.ToString();
                stepItem.Name        = this.ToString();
                stepItem.RowItemList = new List <RowItem>();
                RowItem rowItem = new RowItem();
                rowItem.ErrorInfo = "Time out";
                rowItem.IsPassed  = false;
                rowItem.Name      = this.ToString();
                stepItem.RowItemList.Add(rowItem);
                tcItem.StepItemList.Add(stepItem);
                tcItem.stepOperation("Time out", value);

                return(false);
            }
            else
            {
                context.Verbose.AppendFormat("           \t<---------\t{0}(code={1})", response.Type, response.Code);
                StepItem stepItem = new StepItem();
                stepItem.RowItemList = new List <RowItem>();
                stepItem.IsRequest   = false;
                stepItem.Name        = response.Type.ToString() + " Response";
                tcItem.StepItemList.Add(stepItem);
                tcItem.stepOperation(response.Type.ToString() + " Response", value);
                if (ResponseCheck != null)
                {
                    return(ResponseCheck.Check(response, request, stepItem));
                }
                else
                {
                    return(true);
                }
            }
        }