public void Selects_ok() { var input = new[] { "1", "2", "3" }; var output = GenericCollectionUtils.Select(input, x => Int32.Parse(x)); Assert.AreElementsEqual(new[] { 1, 2, 3 }, output); }
private static bool ParseImpl(string value, out ReportArchive reportArchive, bool throwOnFailure) { if (String.IsNullOrEmpty(value)) { reportArchive = Normal; return(true); } foreach (ReportArchive item in All) { if (item.Value.ToString().Equals(value, StringComparison.OrdinalIgnoreCase)) { reportArchive = item; return(true); } } if (throwOnFailure) { string[] names = GenericCollectionUtils.ToArray(GenericCollectionUtils.Select(All, x => x.Value.ToString())); throw new ArgumentException(String.Format("Invalid report archive mode '{0}'. It must be one of the following values: {1}.", value, String.Join(", ", names))); } reportArchive = Normal; return(false); }
private void InitializeAvailableReportTypes() { IReportManager reportManager = RuntimeAccessor.ServiceLocator.Resolve <IReportManager>(); types = new List <ReportFormatterTraits>(GenericCollectionUtils.Select(reportManager.FormatterHandles, x => x.GetTraits())); typeNames = new List <string>(GenericCollectionUtils.Select(types, x => x.Name)); comboBoxOutputReportType.Items.AddRange(GenericCollectionUtils.ToArray(types)); }
private HashStoreResult GetResult() { if (result == null) { var store = new HashStore(GenericCollectionUtils.Select(DistinctInstances, o => o.GetHashCode())); result = store.Result; } return(result); }
private static TAttribute[] ToAttributeArray <TAttribute>(Attribute[] attributes) where TAttribute : Attribute { return(GenericCollectionUtils.ToArray(GenericCollectionUtils.Select(attributes, x => (TAttribute)x))); }
public void Selects_from_null_filter_should_throw_exception() { var enumerator = GenericCollectionUtils.Select <string, int>(EmptyArray <string> .Instance, null).GetEnumerator(); enumerator.MoveNext(); }
public void Selects_from_null_enumeration_should_throw_exception() { var enumerator = GenericCollectionUtils.Select <string, int>(null, x => 0).GetEnumerator(); enumerator.MoveNext(); }