Beispiel #1
0
        /// <summary>
        /// Parses a string that was generated using ToastArguments into a <see cref="ToastArguments"/> object.
        /// </summary>
        /// <param name="toastArgumentsStr">The toast arguments string to deserialize.</param>
        /// <returns>The parsed toast arguments.</returns>
        public static ToastArguments Parse(string toastArgumentsStr)
        {
            if (string.IsNullOrWhiteSpace(toastArgumentsStr))
            {
                return(new ToastArguments());
            }

            string[] pairs = toastArgumentsStr.Split(';');

            ToastArguments answer = new ToastArguments();

            foreach (string pair in pairs)
            {
                string name;
                string value;

                int indexOfEquals = pair.IndexOf('=');

                if (indexOfEquals == -1)
                {
                    name  = Decode(pair);
                    value = null;
                }
                else
                {
                    name  = Decode(pair.Substring(0, indexOfEquals));
                    value = Decode(pair.Substring(indexOfEquals + 1));
                }

                answer.Add(name, value);
            }

            return(answer);
        }
Beispiel #2
0
        private string SerializeArgumentsHelper(IDictionary <string, string> arguments)
        {
            var args = new ToastArguments();

            foreach (var a in arguments)
            {
                args.Add(a.Key, a.Value);
            }

            return(args.ToString());
        }
Beispiel #3
0
        private string AddArgumentHelper(string existing, string key, string value)
        {
            string pair = ToastArguments.EncodePair(key, value);

            if (string.IsNullOrEmpty(existing))
            {
                return(pair);
            }
            else
            {
                return(existing + ToastArguments.Separator + pair);
            }
        }
        private string SerializeArgumentsIncludingGeneric(ToastArguments arguments)
        {
            if (_genericArguments.Count == 0)
            {
                return(arguments.ToString());
            }

            foreach (var genericArg in _genericArguments)
            {
                if (!arguments.Contains(genericArg.Key))
                {
                    arguments.Add(genericArg.Key, genericArg.Value);
                }
            }

            return(arguments.ToString());
        }