예제 #1
0
        public void ParseQueryString_001()
        {
            var QueryString = new QueryString("abc?a=b");

            Assert.AreEqual(1,   QueryString.Count());
            Assert.AreEqual("a", QueryString.First().Key);
            Assert.AreEqual("b", QueryString.First().Value.First());
        }
예제 #2
0
        public void ParseQueryString_001()
        {
            var QueryString = new QueryString("abc?a=b");

            Assert.AreEqual(1, QueryString.Count());
            Assert.AreEqual("a", QueryString.First().Key);
            Assert.AreEqual("b", QueryString.First().Value.First());
        }
예제 #3
0
        public void ParseQueryString_002()
        {
            var QueryString = new QueryString("?a=b&a=c");

            Assert.AreEqual(1, QueryString.Count());
            Assert.AreEqual("a", QueryString.First().Key);
            Assert.AreEqual("b", QueryString.First().Value.First());
            Assert.AreEqual("c", QueryString.First().Value.Skip(1).First());
        }
예제 #4
0
        public void ParseQueryString_002()
        {
            var QueryString = new QueryString("?a=b&a=c");

            Assert.AreEqual(1, QueryString.Count());
            Assert.AreEqual("a", QueryString.First().Key);
            Assert.AreEqual("b", QueryString.First().Value.First());
            Assert.AreEqual("c", QueryString.First().Value.Skip(1).First());
        }
예제 #5
0
        public void ParseQueryString_003()
        {
            var QueryString = new QueryString("a=b&c=d");

            Assert.AreEqual(2, QueryString.Count());
            Assert.AreEqual("a", QueryString.First().Key);
            Assert.AreEqual("b", QueryString.First().Value.First());
            Assert.AreEqual("c", QueryString.Skip(1).First().Key);
            Assert.AreEqual("d", QueryString.Skip(1).First().Value.First());
        }
예제 #6
0
        public void ParseQueryString_003()
        {
            var QueryString = new QueryString("a=b&c=d");

            Assert.AreEqual(2, QueryString.Count());
            Assert.AreEqual("a", QueryString.First().Key);
            Assert.AreEqual("b", QueryString.First().Value.First());
            Assert.AreEqual("c", QueryString.Skip(1).First().Key);
            Assert.AreEqual("d", QueryString.Skip(1).First().Value.First());
        }
예제 #7
0
        protected async override void OnActivated(IActivatedEventArgs e)
        {
            try
            {
                // Get the root frame
                Frame rootFrame = Window.Current.Content as Frame;

                if (rootFrame == null)
                {
                    rootFrame = await Launch(false, e.PreviousExecutionState, string.Empty);
                }

                // Handle toast activation
                if (e is ToastNotificationActivatedEventArgs)
                {
                    var toastActivationArgs = e as ToastNotificationActivatedEventArgs;

                    // Parse the query string
                    QueryString args = QueryString.Parse(toastActivationArgs.Argument);
                    if (args.Count() > 0)
                    {
                        // See what action is being requested
                        switch (args[ToastAssistant.LaunchAction])
                        {
                        // Open the image
                        case ToastAssistant.GoToTrello:
                        {
                            Windows.System.Launcher.LaunchUriAsync(new Uri("https://trello.com/b/HgHREOjb"));
                        }
                        break;

                        case ToastAssistant.GoToDonationPage:
                        {
                            if (rootFrame != null)
                            {
                                rootFrame.Navigate(typeof(TipPage));
                            }
                        }
                        break;
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                LogUnhandledError(exception);
            }
        }
예제 #8
0
        private void TagGridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            var         item  = e.ClickedItem as BangumiStyle;
            string      param = item.url.Split("?").Last().TrimStart('?');
            QueryString args  = QueryString.Parse(param);
            var         list  = new List <KeyValueModel>();

            if (args.Count() > 0)
            {
                foreach (var query in args)
                {
                    list.Add(new KeyValueModel(query.Name, query.Value));
                }
                list.Add(new KeyValueModel("season_type", _detail.type.ToString()));
            }
            if (list.Count > 0)
            {
                App.AppViewModel.NavigateToSubPage(typeof(Pages_Share.Sub.Anime.IndexPage), list);
            }
        }
예제 #9
0
        public UriTemplate(string template)
        {
            _templateUri = ParseTemplate(template);
            _segments    = ParsePathSegments(_templateUri);

            _pathSegmentVariables = _segments.Where(segment => segment.Type == SegmentType.Variable)
                                    .ToDictionary(segment => segment.Text.ToUpperInvariant(), StringComparer.OrdinalIgnoreCase);

            QueryString = ParseQueryStringSegments(_templateUri.Query).ToList();
            _cachedQsLiteralSegments = QueryString.Count(qs => qs.Type == SegmentType.Literal);
            Fragment                   = ParseFragment(_templateUri.Fragment).ToList();
            _queryStringSegments       = ParseQueryStringSegments(QueryString);
            _cachedQueryStringKeyNames = new ReadOnlyCollection <string>(_queryStringSegments.Keys.ToCollection());

            PathSegmentVariableNames = new ReadOnlyCollection <string>(new List <string>(_pathSegmentVariables.Keys));
            QueryStringVariableNames =
                new ReadOnlyCollection <string>(new List <string>(GetQueryStringVariableNames(_queryStringSegments)));
            FragmentVariableNames =
                new ReadOnlyCollection <string>(Fragment.Where(f => f.Type == SegmentType.Variable).Select(f => f.Text)
                                                .ToList());
        }
예제 #10
0
        public void TestCount()
        {
            QueryString qs = new QueryString();

            Assert.AreEqual(0, qs.Count());

            qs.Add("name", "Andrew");

            Assert.AreEqual(1, qs.Count());

            qs.Add("age", "22");

            Assert.AreEqual(2, qs.Count());

            qs.Add("name", "Lei");

            Assert.AreEqual(3, qs.Count());

            qs.Set("name", "Thomas");

            Assert.AreEqual(2, qs.Count());

            qs.Add("name", "Matt");

            Assert.AreEqual(3, qs.Count());

            qs.Remove("name", "Matt");

            Assert.AreEqual(2, qs.Count());

            qs.Remove("name", "Thomas");

            Assert.AreEqual(1, qs.Count());

            qs.Remove("age");

            Assert.AreEqual(0, qs.Count());

            qs.Add("name", "Andrew");
            qs.Add("name", "Lei");

            Assert.AreEqual(2, qs.Count());

            qs.RemoveAll("name");

            Assert.AreEqual(0, qs.Count());
        }
예제 #11
0
        public void ParseQueryString_009()
        {
            var QueryString = new QueryString("=b");

            Assert.AreEqual(0, QueryString.Count());
        }
예제 #12
0
        public void ParseQueryString_007()
        {
            var QueryString = new QueryString("a=b&");

            Assert.AreEqual(1, QueryString.Count());
        }
        public void TestCount()
        {
            QueryString qs = new QueryString();
            
            Assert.AreEqual(0, qs.Count());

            qs.Add("name", "Andrew");

            Assert.AreEqual(1, qs.Count());

            qs.Add("age", "22");

            Assert.AreEqual(2, qs.Count());

            qs.Add("name", "Lei");

            Assert.AreEqual(3, qs.Count());

            qs.Set("name", "Thomas");

            Assert.AreEqual(2, qs.Count());

            qs.Add("name", "Matt");

            Assert.AreEqual(3, qs.Count());

            qs.Remove("name", "Matt");

            Assert.AreEqual(2, qs.Count());

            qs.Remove("name", "Thomas");

            Assert.AreEqual(1, qs.Count());

            qs.Remove("age");

            Assert.AreEqual(0, qs.Count());

            qs.Add("name", "Andrew");
            qs.Add("name", "Lei");

            Assert.AreEqual(2, qs.Count());

            qs.RemoveAll("name");

            Assert.AreEqual(0, qs.Count());
        }
예제 #14
0
        public void ParseQueryString_007()
        {
            var QueryString = new QueryString("a=b&");

            Assert.AreEqual(1, QueryString.Count());
        }
예제 #15
0
        public void ParseQueryString_006()
        {
            var QueryString = new QueryString("&");

            Assert.AreEqual(0, QueryString.Count());
        }