Example #1
0
        /// <summary>
        /// Converts a list of one type into an array of another type based on delegates.
        /// </summary>
        /// <returns>The converted array.</returns>
        /// <param name="list">The source list to convert.</param>
        /// <param name="op">The operation to perform on each element in order to convert it into the target type..</param>
        /// <typeparam name="TSource">The source type.</typeparam>
        /// <typeparam name="TTarget">The target type.</typeparam>
        public static TTarget[] ToArray <TSource, TTarget>(IList <TSource> list, ProxyList <TSource, TTarget> .RevertOperation op)
        {
            var ary = new TTarget[list.Count];

            for (int i = 0; i < list.Count; i++)
            {
                ary[i] = op.Invoke(list[i]);
            }
            return(ary);
        }
Example #2
0
 public ProxyListEnumerator(ProxyList <TSource, TTarget> list)
 {
     ProxyList = list;
 }
Example #3
0
 /// <summary>
 /// Converts a list of one type into a <see cref="Semi.ProxyList`2"/> providing a proxy of the same type into an array of a target type.
 /// </summary>
 /// <returns>The <c>ProxyList</c> backed by the converted array.</returns>
 /// <param name="list">The source list to convert.</param>
 /// <param name="cop">Convert (source to target) operation for the <c>ProxyList</c>.</param>
 /// <param name="rop">Revert (target to source) operation for the <c>ProxyList</c>.</param>
 /// <typeparam name="TSource">The source type.</typeparam>
 /// <typeparam name="TTarget">The target type.</typeparam>
 public static ProxyList <TSource, TTarget> ToArrayProxyList <TSource, TTarget>(IList <TSource> list, ProxyList <TSource, TTarget> .ConvertOperation cop, ProxyList <TSource, TTarget> .RevertOperation rop)
 {
     return(new ProxyList <TSource, TTarget>(
                ToArray(list, rop),
                cop,
                rop
                ));
 }