示例#1
0
        public Task <IHttpActionResult> Get(string expr = null, string action = null)
        {
            if (action != null)
            {
                switch (action)
                {
                case "purge":
                    AnalyzerFactory.PurgeCache();
                    break;

                default:
                    throw new ArgumentException("无效的操作。", nameof(action));
                }
            }
            if (expr != null)
            {
                long[] idPair;
                try
                {
                    idPair = JsonConvert.DeserializeObject <long[]>(expr);
                }
                catch (Exception ex) when(ex is JsonSerializationException ||
                                          ex is JsonReaderException)
                {
                    throw new ArgumentException(ex.Message, nameof(expr));
                }
                if (idPair.Length != 2)
                {
                    throw new ArgumentException("无效的节点对。节点对有且仅有两个元素。", nameof(expr));
                }
                return(Get(idPair[0], idPair[1]));
            }
            return(Task.FromResult((IHttpActionResult)Ok()));
        }