public static void AddRange(this IBaseCollection collection, IEnumerable <object> objects) { foreach (var item in objects) { collection.Add(item); } }
public static void AddRange(this IBaseCollection IColl, IEnumerable <object> objects) { foreach (var item in objects) { IColl.Add(item); Console.WriteLine("!!!"); } }
/// <summary> /// A generic test, regardless of the item type. Works by the following steps: /// 1. Adding the items in the list to the collection (show times if required) /// 2. Removing all items and test correctness by verifying that every item removed is smaller or /// equals to the one that was removed before it. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="col">The collection to test</param> /// <param name="list">A list of items of corresponded type</param> /// <param name="timeTrace">Determines whether to display the time elapsed for every operation</param> private void TestCollection <T>(IBaseCollection <T> col, List <T> list, bool timeTrace = true) where T : IComparable <T> { Stopwatch sw = new Stopwatch(); foreach (T item in list) { sw.Start(); col.Add(item); sw.Stop(); if (timeTrace) { _output.WriteLine($"Add time: {sw.Elapsed.TotalMilliseconds.ToString(CultureInfo.InvariantCulture)}ms"); } } sw.Start(); T item1 = col.Remove(); sw.Stop(); if (timeTrace) { _output.WriteLine($"Remove time: {sw.Elapsed.TotalMilliseconds.ToString(CultureInfo.InvariantCulture)}ms"); } while (col.Count > 0) { sw.Start(); T item2 = col.Remove(); sw.Stop(); if (timeTrace) { _output.WriteLine($"Remove time: {sw.Elapsed.TotalMilliseconds.ToString(CultureInfo.InvariantCulture)}ms"); } // TEST CORRECTNESS // Verify that the previous item removed is not smaller than the current one. // If the test fails we display the item values and the current state. Assert.True(item1.CompareTo(item2) >= 0, $"{item1}, {item2}: cmp={item1.CompareTo(item2)} ({col.GetType().Name}, {col.Count} items left)"); item1 = item2; } }
private void ApplyFieldsRow(IBaseCollection<IHPatternInstanceElement> ret, RowElement row) { foreach (ColumnElement col in row.Columns) { foreach (IHPatternInstanceElement i in col.Items) { if (i is AttributeElement || i is VariableElement || i is TextElement) { ret.Add(i); } else { if (i is GroupElement) { GroupElement grp = (GroupElement)i; foreach (RowElement row2 in grp.Rows) { ApplyFieldsRow(ret, row2); } } } } } }
private void AddRow(FRowElement row, IBaseCollection<FilterAttributeElement> lista) { foreach (FColElement col in row.Columns) { foreach (IHPatternInstanceElement item in col.Items) { if (item is FilterAttributeElement) lista.Add((item as FilterAttributeElement)); if (item is FGroupElement) { FGroupElement group = item as FGroupElement; foreach (FRowElement grow in group.Rows) { AddRow(grow, lista); } } } } }
private void AddParameter(IBaseCollection<ParameterElement> parametersElement, string parValue, bool nullAttri) { ParameterElement parm = new ParameterElement(parValue); parm.Null = nullAttri; parametersElement.Add(parm); }
private static void GetRowsGridPP(IBaseCollection<RowElement> rows, IBaseCollection<AttributeElement> atts, RowElement baserow, ColumnElement basecol,IHPatternInstanceElement trni) { RowElement row = baserow.Clone(); row.Parent = trni; row.Columns.Clear(); ColumnElement col = basecol.Clone(); col.Items.Clear(); foreach (AttributeElement att in atts) { col.Items.Add(att); } row.Columns.Add(col); rows.Add(row); }
private static void GetRowsAllTabsPP(IBaseCollection<RowElement> rows, RowElement row, bool GridFreeStyle, bool GridStandard, IHPatternInstanceElement trni) { // GetRowsAllTabs++ a revolta das Rows, a continuação :D rows.Add(row); foreach (ColumnElement col in row.Columns) { foreach (GroupElement grp in col.Groups) { foreach (RowElement row2 in grp.Rows) { GetRowsAllTabsPP(rows, row2,GridFreeStyle, GridStandard,trni); } } if (GridFreeStyle) { foreach (GridFreeStyleElement grid in col.GridFreeStyles) { GetRowsGridFreeStylePP(rows, grid, row, col, grid); } } if (GridStandard) { foreach (GridStandardElement grid in col.GridStandards) { GetRowsGridPP(rows, grid.Attributes.Attributes, row, col, grid); } } } }