示例#1
0
        /// <summary>
        /// Parse all semicolon separated parameters.
        /// </summary>
        /// <param name="parameters">String containing all parameters to parse</param>
        /// <param name="delimiter">Delimiter separating parameters.</param>
        /// <example>
        /// <code>
        /// KeyValueCollection parameters = new KeyValueCollection();
        /// UriParser.ParseParameters(parameters, "hej=hello,welcome=now", ',');
        /// </code>
        /// </example>
        /// <remarks>
        /// Parameter names are converted to lower case.
        /// </remarks>
        public static void ParseParameters(IKeyValueCollection <string, string> parameters, ITextReader reader,
                                           char delimiter)
        {
            reader.Consume(' ', '\t');
            while (!reader.EOF)
            {
                if (reader.Current == delimiter)
                {
                    reader.Consume();
                }
                if (reader.EOF)
                {
                    return;
                }

                reader.Consume(' ', '\t');
                string name = reader.ReadToEnd("=" + delimiter);
                if (name == null)
                {
                    break;
                }
                name = name.ToLower();

                // No semicolon after last parameter.
                if (reader.EOF)
                {
                    parameters.Add(name, string.Empty);
                    return;
                }

                if (reader.Current == delimiter)
                {
                    parameters.Add(name, string.Empty);
                    continue;
                }

                reader.Consume(' ', '\t', '=');
                string value = reader.Current == '"' ? reader.ReadQuotedString() : reader.ReadToEnd(" \t" + delimiter);

                // no value
                if (value == null)
                {
                    parameters.Add(name, string.Empty);
                    continue;
                }
                parameters.Add(name, value);
                reader.Consume(' ', '\t');

                if (reader.Current != delimiter)
                {
                    break;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Stores <paramref name="payload"/> properties to the <paramref name="storage"/>.
        /// </summary>
        /// <param name="storage">The storage to save values to.</param>
        /// <param name="payload">The event payload to store.</param>
        public void Store(IKeyValueCollection storage, object input)
        {
            Event payload = input as Event;

            if (payload != null)
            {
                storage.Add(Name.Key, payload.Key);
                storage.Add(Name.AggregateKey, payload.AggregateKey);
                storage.Add(Name.AggregateVersion, payload.Version);
            }
        }
示例#3
0
 public void Store(IKeyValueCollection storage, object input)
 {
     // TODO: Not null check, UserKey is required!
     if (input is UserEvent payload && payload.UserKey != null)
     {
         storage.Add(Name.UserKey, payload.UserKey);
     }
 }
示例#4
0
        /// <summary>
        /// Stores <paramref name="payload"/> properties to the <paramref name="storage"/>.
        /// </summary>
        /// <param name="storage">The storage to save values to.</param>
        /// <param name="payload">The command payload to store.</param>
        public void Store(IKeyValueCollection storage, object input)
        {
            Command payload = input as Command;

            if (payload != null)
            {
                storage.Add(Name.Key, payload.Key);
            }
        }
            public IKeyValueCollection Add(string key, object value)
            {
                Ensure.NotNullOrEmpty(key, "key");

                if (isTypeIgnored && key == "Type")
                {
                    return(this);
                }

                if (prefix != null)
                {
                    key = prefix + key;
                }

                inner.Add(key, value);
                return(this);
            }
 /// <summary>
 /// Stores <paramref name="payload"/> properties to the <paramref name="storage"/>.
 /// </summary>
 /// <param name="storage">The storage to save values to.</param>
 /// <param name="payload">The event payload to store.</param>
 public void Store(IKeyValueCollection storage, Event payload)
 {
     storage.Add(Name.Key, payload.Key);
     storage.Add(Name.AggregateKey, payload.AggregateKey);
     storage.Add(Name.AggregateVersion, payload.Version);
 }
示例#7
0
 /// <summary>
 /// Stores <paramref name="payload"/> properties to the <paramref name="storage"/>.
 /// </summary>
 /// <param name="storage">The storage to save values to.</param>
 /// <param name="payload">The command payload to store.</param>
 public void Store(IKeyValueCollection storage, Command payload)
 {
     storage.Add(Name.Key, payload.Key);
 }
示例#8
0
        /// <summary>
        /// Parse all semicolon separated parameters.
        /// </summary>
        /// <param name="parameters">String containing all parameters to parse</param>
        /// <param name="delimiter">Delimiter separating parameters.</param>
        /// <example>
        /// <code>
        /// KeyValueCollection parameters = new KeyValueCollection();
        /// UriParser.ParseParameters(parameters, "hej=hello,welcome=now", ',');
        /// </code>
        /// </example>
        /// <remarks>
        /// Parameter names are converted to lower case.
        /// </remarks>
        public static void ParseParameters(IKeyValueCollection<string, string> parameters, ITextReader reader,
            char delimiter)
        {
            reader.Consume(' ', '\t');
            while (!reader.EOF)
            {
                if (reader.Current == delimiter)
                    reader.Consume();
                if (reader.EOF)
                    return;

                reader.Consume(' ', '\t');
                string name = reader.ReadToEnd("=" + delimiter);
                if (name == null)
                    break;
                name = name.ToLower();

                // No semicolon after last parameter.
                if (reader.EOF)
                {
                    parameters.Add(name, string.Empty);
                    return;
                }

                if (reader.Current == delimiter)
                {
                    parameters.Add(name, string.Empty);
                    continue;
                }

                reader.Consume(' ', '\t', '=');
                string value = reader.Current == '"' ? reader.ReadQuotedString() : reader.ReadToEnd(" \t" + delimiter);

                // no value
                if (value == null)
                {
                    parameters.Add(name, string.Empty);
                    continue;
                }
                parameters.Add(name, value);
                reader.Consume(' ', '\t');

                if (reader.Current != delimiter)
                    break;
            }
        }