Example #1
0
 /// <summary>
 /// Add a given value into the selected list type
 /// Other entries may already be present in the list
 /// </summary>
 /// <param name="builder">
 /// A <see cref="ITypedBuilder<TList>"/>
 /// </param>
 /// <param name="value">
 /// A <see cref="TElement"/>
 /// </param>
 /// <returns>
 /// A <see cref="ITypedBuilder<TList>"/>
 /// </returns>
 public static ITypedBuilder <TList> AddEntry <TList, TElement>(this ITypedBuilder <TList> builder,
                                                                TElement value)
     where TList : IList <TElement>
 {
     return(builder.Do(x =>
     {
         var list = (IList <TElement>)x;
         list.Add(value);
     }));
 }
Example #2
0
        /// <summary>
        /// Add a given key / value pair into the selected member's dictionary
        /// Other key and value pairs may already exist
        /// </summary>
        /// <param name="builder">
        /// A <see cref="ITypedBuilder<TType>"/>
        /// </param>
        /// <param name="expression">
        /// A <see cref="Expression<Func<TType, TDictType>>"/>
        /// </param>
        /// <param name="key">
        /// A <see cref="TKey"/>
        /// </param>
        /// <param name="value">
        /// A <see cref="TElement"/>
        /// </param>
        /// <returns>
        /// A <see cref="ITypedBuilder<TType>"/>
        /// </returns>
        public static ITypedBuilder <TType> AddEntry <TType, TDictType, TKey, TElement>(this ITypedBuilder <TType> builder,
                                                                                        Expression <Func <TType, TDictType> > expression, TKey key, TElement value)
            where TDictType : IDictionary <TKey, TElement>
        {
            var getter = expression.Compile();

            return(builder.Do(x =>
            {
                var dict = (IDictionary <TKey, TElement>)getter(x);
                dict[key] = value;
            }));
        }
Example #3
0
        /// <summary>
        /// Add a given value into the selected member's list
        /// Other entries may already be present in the list
        /// </summary>
        /// <param name="builder">
        /// A <see cref="ITypedBuilder<TType>"/>
        /// </param>
        /// <param name="expression">
        /// A <see cref="Expression<Func<TType, TList>>"/>
        /// </param>
        /// <param name="value">
        /// A <see cref="TElement"/>
        /// </param>
        /// <returns>
        /// A <see cref="ITypedBuilder<TType>"/>
        /// </returns>
        public static ITypedBuilder <TType> AddEntry <TType, TList, TElement>(this ITypedBuilder <TType> builder,
                                                                              Expression <Func <TType, TList> > expression,
                                                                              TElement value)
            where TList : IList <TElement>
        {
            var getter = expression.Compile();

            return(builder.Do(x =>
            {
                var list = (IList <TElement>)getter(x);
                list.Add(value);
            }));
        }
Example #4
0
 /// <summary>
 /// Add a given key / value pair into the selected dictionary type
 /// Other key and value pairs may already exist
 /// </summary>
 /// <param name="builder">
 /// A <see cref="ITypedBuilder<TDictType>"/>
 /// </param>
 /// <param name="key">
 /// A <see cref="TKey"/>
 /// </param>
 /// <param name="value">
 /// A <see cref="TElement"/>
 /// </param>
 /// <returns>
 /// A <see cref="ITypedBuilder<TDictType>"/>
 /// </returns>
 public static ITypedBuilder <TDictType> AddEntry <TDictType, TKey, TElement>(this ITypedBuilder <TDictType> builder, TKey key, TElement value)
     where TDictType : IDictionary <TKey, TElement>
 {
     return(builder.Do(x => x[key] = value));
 }