Dev2.DataList.Contract.Binary_Objects.Structs.SBinaryDataListEntry.Init C# (CSharp) Method

Init() public method

Inits this instance.
public Init ( int colCnt, bool createNewStorage = true ) : void
colCnt int
createNewStorage bool
return void
        public void Init(int colCnt, bool createNewStorage = true)
        {
            if(createNewStorage)
            {
                _itemStorage = new BinaryDataListStorageLayer();
            }

            // Construct the alias map for this entry ;)
            _keyToAliasMap = new Dictionary<string, BinaryDataListAlias>();

            _myKeys = new IndexList(null, 1);

            _isEmpty = true;
            _internalReturnValue = new List<IBinaryDataListItem>(colCnt); // build the object we require to return data in ;)

            for(int i = 0; i < colCnt; i++)
            {
                _internalReturnValue.Add(new BinaryDataListItem(null, string.Empty));

                if(Columns != null)
                {
                    // Handle recordset
                    _internalReturnValue[i].UpdateRecordset(Namespace); // always the same namespace ;)
                    _internalReturnValue[i].UpdateField(Columns[i].ColumnName); // always the same column for this entry ;)
                }
                else
                {
                    // Handle scalars
                    _internalReturnValue[i].UpdateField(Namespace); // always the same namespace ;)
                }
            }

            // boot strap column cache ;)
            short cnt = 1;
            if(Columns != null)
            {
                cnt = (short)Columns.Count;
            }
            _strToColIdx = new Dictionary<string, int>(cnt);

        }

Usage Example

        public void SBinaryDataListEntry_MoveIndexDataForClone_MinMaxAndGapsMove_SameDataBothSides()
        {
            //------------Setup for test--------------------------
            var sBinaryDataListEntry = new SBinaryDataListEntry();
            sBinaryDataListEntry.Init(1);
            sBinaryDataListEntry.ReInstateMinValue(2);
            sBinaryDataListEntry.ReInstateMaxValue(5);
            sBinaryDataListEntry.AddGap(1);
            var targetEntry = new SBinaryDataListEntry();
            targetEntry.Init(1);
            
            //------------Execute Test---------------------------
            targetEntry.MoveIndexDataForClone(sBinaryDataListEntry.Keys.MinIndex(), sBinaryDataListEntry.Keys.MaxIndex(), sBinaryDataListEntry.FetchGaps());

            //------------Assert Results-------------------------

            var targetKeys = targetEntry.Keys;
            var parentKeys = sBinaryDataListEntry.Keys;

            var targetMin = targetKeys.MinIndex();
            var targetMax = targetKeys.MaxIndex();
            var targetCount = targetKeys.Count;

            var parentMin = parentKeys.MinIndex();
            var parentMax = parentKeys.MaxIndex();
            var parentCount = parentKeys.Count;

            // found count we can tell if gaps moved ;)
            Assert.AreEqual(3, parentCount);
            Assert.AreEqual(parentCount, targetCount);

            Assert.AreEqual(parentMin, targetMin);
            Assert.AreEqual(parentMax, targetMax);
            

        }