Пример #1
0
        private static async Task <RootMatch> ParseMatch(string match_id)
        {
            QueryBuilder        builder  = new QueryBuilder();
            QueryExecutor       executor = new QueryExecutor(builder.GetMatchQuery(match_id));
            Tuple <string, int> tuple    = await executor.ExecuteQueryAsync();

            RootMatch match = JsonParser.ParseMatchData(tuple).Item1;

            return(match);
        }
Пример #2
0
        protected BasePath(PathType pathType, bool isFolder, string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }
            if (!isFolder)
            {
                char lastChar = path[path.Length - 1];
                if (lastChar == '\\' || lastChar == '/')
                {
                    throw new Exception("No filename specified: " + path);
                }
            }
            _isFolder = isFolder;

            NameHelper.EnsureValidPathCharacters(path);

            RootMatch rootMatch = RootMatch.FindRoot(path);

            if (rootMatch == null)
            {
                throw new Exception("Unsupported path: " + path);
            }
            if (pathType.IsRelative())
            {
                if (!rootMatch.PathType.IsRelative())
                {
                    throw PathExceptions.NotARelativePath(path);
                }
            }
            else
            {
                if (rootMatch.PathType.IsRelative())
                {
                    throw PathExceptions.NotAnAbsolutePath(path);
                }
            }
            _pathType = rootMatch.PathType;
            _parts    = rootMatch.Parts;
            Segment(rootMatch.ItemPath);
            CleanUpRoute();
        }
Пример #3
0
        public static Tuple <RootMatch, int> ParseMatchData(Tuple <string, int> pair)
        {
            if (pair == null)
            {
                return(null);
            }

            else if (pair.Item1 == null)
            {
                Tuple <RootMatch, int> error = Tuple.Create <RootMatch, int>(null, pair.Item2);
                return(error);
            }
            if (pair != null)
            {
                RootMatch obj = JsonConvert.DeserializeObject <RootMatch>(pair.Item1);
                Tuple <RootMatch, int> response = Tuple.Create(obj, pair.Item2);

                return(response);
            }
            else
            {
                return(null);
            }
        }