Esempio n. 1
0
 public static void RemoveLastN(this IBaseCollection collection, int numberOfItems)
 {
     for (int i = 0; i < numberOfItems; i++)
     {
         collection.RemoveLast("something");
     }
 }
Esempio n. 2
0
 public static void AddRange(this IBaseCollection collection, IEnumerable <object> objects)
 {
     foreach (var item in objects)
     {
         collection.Add(item);
     }
 }
Esempio n. 3
0
 public static void AddRange(this IBaseCollection IColl, IEnumerable <object> objects)
 {
     foreach (var item in objects)
     {
         IColl.Add(item);
         Console.WriteLine("!!!");
     }
 }
Esempio n. 4
0
        /// <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;
            }
        }
Esempio n. 5
0
        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);
                            }
                        }
                    }

                }
            }
        }
        public SequenceRepository(IBaseCollection <Sequence> baseCollection)
        {
            Require.Objects.NotNull(baseCollection, nameof(baseCollection));

            _baseCollection = baseCollection;
        }
Esempio n. 7
0
        public static string GetPKSDT(IBaseCollection<TransactionAttribute> atts,string TrnName, string PKDelimiter)
        {
            StringBuilder varpksM = new StringBuilder();

            int contaVM = 0;

            foreach (TransactionAttribute trnAtt in atts)
            {
                if (contaVM == 1) varpksM.AppendFormat("+'{0}'+", PKDelimiter);
                varpksM.AppendFormat("&{0}SDT.{1}", TrnName, trnAtt.Name);
                contaVM = 1;

                if (!(trnAtt.Attribute.Type == eDBType.CHARACTER || trnAtt.Attribute.Type == eDBType.VARCHAR))
                {
                    varpksM.Append(".ToString()");
                }

            }
            return varpksM.ToString();
        }
Esempio n. 8
0
        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);
                        }
                    }
                }
            }
        }
Esempio n. 9
0
 protected BaseModel(IBaseCollection <T> owner)
 {
     SetOwner(owner);
 }
Esempio n. 10
0
 public void SetOwner(IBaseCollection <T> owner)
 {
     Owner = owner;
 }
Esempio n. 11
0
        public static string GetPKLink(IBaseCollection<TransactionAttribute> atts,bool IniciaComVirgula)
        {
            StringBuilder varpks = new StringBuilder();

            int conta = 0;
            if (IniciaComVirgula) conta = 1;

            foreach (TransactionAttribute trnAtt in atts)
            {
                if (conta > 0) varpks.Append(",");
                varpks.AppendFormat("&{0}", trnAtt.Name);
                conta = 1;
            }

            return varpks.ToString();
        }
Esempio n. 12
0
        private void AddParameters(IBaseCollection<ParameterElement> parametersElement, bool addMode, IList<TransactionAttribute> attris, IList<TransactionAttribute> notNullAttris)
        {
            if (addMode)
                AddParameter(parametersElement, "&Mode", true);

            foreach (TransactionAttribute attri in attris)
            {
                bool nullAttri = true;
                if (notNullAttris != null && notNullAttris.Contains(attri))
                    nullAttri = false;

                AddParameter(parametersElement, attri.Name, nullAttri);
            }
        }
Esempio n. 13
0
        public TagRepository(IBaseCollection <Tags> baseCollection)
        {
            Require.Objects.NotNull(baseCollection, nameof(baseCollection));

            _baseCollection = baseCollection;
        }
        public ConfigurationRepository(IBaseCollection <Configuration <Contacts> > baseCollection)
        {
            Require.Objects.NotNull(baseCollection, nameof(baseCollection));

            this.baseCollection = baseCollection;
        }
Esempio n. 15
0
        public static string GetPKVar(IBaseCollection<TransactionAttribute> atts)
        {
            StringBuilder varpksT = new StringBuilder();

            foreach (TransactionAttribute trnAtt in atts)
            {
                varpksT.AppendFormat("+&{0}", trnAtt.Name);

                if (!(trnAtt.Attribute.Type == eDBType.CHARACTER || trnAtt.Attribute.Type == eDBType.VARCHAR))
                {
                    varpksT.Append(".ToString()");
                }

            }
            return varpksT.ToString();
        }
Esempio n. 16
0
        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);
        }
Esempio n. 17
0
 private static void GetRowsGridFreeStylePP(IBaseCollection<RowElement> rows, GridFreeStyleElement grid, RowElement baserow, ColumnElement basecol, IHPatternInstanceElement trni)
 {
     GetRowsGridPP(rows, grid.Attributes, baserow, basecol, grid);
     foreach (GridFreeStyleElement grid2 in grid.GridFreeStyles)
     {
         GetRowsGridFreeStylePP(rows, grid2, baserow, basecol, grid2);
     }
     foreach (GridStandardElement grid2 in grid.GridStandards)
     {
         GetRowsGridPP(rows, grid2.Attributes.Attributes, baserow, basecol, grid2);
     }
 }
Esempio n. 18
0
 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);
             }
         }
     }
 }
Esempio n. 19
0
 private static IBaseCollection<RowElement> GetRowsAllTabs(IBaseCollection<TabFormElement> tabs, TransactionElement trni)
 {
     IBaseCollection<RowElement> rows = new BaseCollection<RowElement>();
     if (tabs != null)
     {
         foreach (TabFormElement tabe in tabs)
         {
             foreach (RowElement row in tabe.Rows)
                 rows.Add(row);
         }
     }
     return rows;
 }
Esempio n. 20
0
 private void AddParameter(IBaseCollection<ParameterElement> parametersElement, string parValue, bool nullAttri)
 {
     ParameterElement parm = new ParameterElement(parValue);
     parm.Null = nullAttri;
     parametersElement.Add(parm);
 }
Esempio n. 21
0
 public static string GetPKLink(IBaseCollection<TransactionAttribute> atts)
 {
     return GetPKLink(atts, true);
 }