// Summary:
// Projects each element of a sequence into a new form.
//项目的每个元素序列进入一种新形式。
// Parameters:
// source:来源
// A sequence of values to invoke a transform function on.
//一个序列值来调用转换函数。
// selector:选择器
// A transform function to apply to each element.
//转换函数适用于每个元素。
// Type parameters:输入参数:
// TSource:
// The type of the elements of source.
//源的元素的类型。
// TResult:
// The type of the value returned by selector.
//选择器返回的值的类型。
// Returns:
// An System.Collections.Generic.IEnumerable<T> whose elements are the result
// of invoking the transform function on each element of source.
//
// Exceptions:
// System.ArgumentNullException:
// source or selector is null.
public static IEnumerable<TResult> Select<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector);
使用:
Enumerable.Range(0, (count <= 0) ? 1 : count)
.Select(i =>
{
var queue = new MessageQueue(queuePath, QueueAccessMode.Receive)
{
Formatter = new XmlMessageFormatter(new Type[] { typeof(EnrollJob) })
};
queue.MessageReadPropertyFilter.SetAll();
return queue;
})
.ToArray();
详解:
产生一系列的积分数量在规定的范围内
IEnumerable<int> Range
Enumerable.Range(0, (count <= 0) ? 1 : count) 返回的是一个数字的enumerable记录。
enumerable.Select(i =>
{
var queue = new MessageQueue(queuePath, QueueAccessMode.Receive);
return queue;
})
.ToArray();
TSource=int;TResult=MessageQueue;
Func<TSource, TResult> selector lamda表达式,传入的参数int,返回的结果 MessageQuequ;
this IEnumerable<TSource> source 就是enumrable的数据;最后生成的数据就是 IEnumerable<MessageQqueue>的数据列;
也就是里面定义的queue组合而成的数据源