BlueSky.Model.VirtualListDynamic.this C# (CSharp) Method

this() private method

private this ( int fIndex ) : objectIList.System
fIndex int
return objectIList.System
        object IList.this[int fIndex]
        {
            get
            {
                if (dictIndex.ContainsKey(fIndex))
                    return dictIndex[fIndex];

                // Now we have our type. Let's create an instance from it:
                object generetedObject = Activator.CreateInstance(type);

                // Loop over all the generated properties, and assign the values from our XML:
                PropertyInfo[] properties = type.GetProperties();

                int propertiesCounter = 0;

                bool rowatonce = true; // false means cell be cell, true means row at once
                string[] rowdata = null;
                if (rowatonce)
                    rowdata = GetRowData(fIndex); //fetched row
                if (rowdata == null)
                    return null;
                long celldata = 0;
                bool isparsed = false;
                DateTime dt = new DateTime(1970,1,1); 
                for (int i = 0; i < _dataSource.Variables.Count; ++i)//A. for a row, each col is assigned value
                {
                    if ((_dataSource.Variables[i].DataClass.Equals("POSIXct") ||
                        _dataSource.Variables[i].DataClass.Equals("POSIXlt")))
                    {
                        if (rowdata[i] == "<NA>" || rowdata[i] == "NA")
                        {
                            dt = new DateTime(0001, 01, 01).ToLocalTime();
                            properties[propertiesCounter].SetValue(generetedObject, dt, null);
                        }
                        else if (rowdata[i].Contains("AM") || rowdata[i].Contains("PM"))//Date string
                        {
                            dt = DateTime.Parse(rowdata[i]).ToLocalTime();
                            properties[propertiesCounter].SetValue(generetedObject, dt, null);
                        }
                        else // Total number of signed seconds
                        {
                            celldata = Convert.ToInt64(rowdata[i]);//, celldata);
                            try
                            {
                                dt = new DateTime(1970, 1, 1).AddSeconds(celldata).ToLocalTime();
                                //dt = DateTime.Parse(celldata);
                                properties[propertiesCounter].SetValue(generetedObject, dt, null);
                            }
                            catch (Exception ex)
                            {
                                if (ex != null)
                                { }
                            }
                        }
                    }
                    else if ((_dataSource.Variables[i].DataClass.Equals("Date"))) //For Date type show only Date part and not the time part
                    {
                        if (rowdata[i] == "<NA>" || rowdata[i] == "NA")
                        {
                            dt = new DateTime(0001, 01, 01).ToLocalTime();
                            properties[propertiesCounter].SetValue(generetedObject, dt.Date, null);
                        }
                        else if (rowdata[i].Contains("AM") || rowdata[i].Contains("PM"))//Date string
                        {
                            dt = DateTime.Parse(rowdata[i]).ToLocalTime();
                            properties[propertiesCounter].SetValue(generetedObject, dt.Date, null);
                        }
                        else // Total number of signed seconds
                        {
                            celldata = Convert.ToInt64(rowdata[i]);//, celldata);
                            try
                            {
                                dt = new DateTime(1970, 1, 1).AddSeconds(celldata).ToLocalTime();
                                //dt = DateTime.Parse(celldata);
                                properties[propertiesCounter].SetValue(generetedObject, dt.Date, null);
                            }
                            catch (Exception ex)
                            {
                                if (ex != null)
                                { }
                            }
                        }
                    }
                    else
                    {
                        if (rowatonce)
                            properties[propertiesCounter].SetValue(generetedObject, rowdata[i], null); // cell by cell from row fetched above
                        else
                            properties[propertiesCounter].SetValue(generetedObject, GetCellValue(fIndex, i), null);// Cell by cell from dataset
                    }
                        propertiesCounter++;
                }
                dictIndex.Add(fIndex, generetedObject);//A. row(object) is added to dictionary. Key is index    
                dict.Add(generetedObject, fIndex);//A. row is added to dictionary. Key is row(object)
                return generetedObject;
            }
            set { }
        }