示例#1
0
        public void GenerateTimesArray(ProcessInstance pInstance, out ICollection <double> timeArray)
        {
            List <DateTime>      dates = new List <DateTime>();
            ICollection <double> times = new Collection <double>();

            PropertyInfo[] props = pInstance.GetType().GetProperties();
            foreach (PropertyInfo prop in props)
            {
                if ((prop.PropertyType == typeof(DateTime) || prop.PropertyType == typeof(DateTime?)) &&
                    (prop.GetValue(pInstance) as DateTime?).HasValue)
                {
                    dates.Add((DateTime)prop.GetValue(pInstance));
                }
            }

            // pretpostavljam da je poslednji indeks uvek jedna od krajnjih faza
            for (int i = 0; i < dates.Count - 1; ++i)
            {
                times.Add((dates[i + 1].Subtract(dates[i])).TotalDays);
            }

            timeArray = times;
        }