public void AddOptions(IEnumerable units)
        {
            object obj = (object)null;

            foreach (object unit in units)
            {
                TimelineUnit timelineUnit = unit as TimelineUnit;
                if (timelineUnit != null)
                {
                    this.elements.Add(timelineUnit);
                }
                else
                {
                    obj = unit;
                    break;
                }
            }
            if (obj == null)
            {
                return;
            }
            PropertyInfo[] properties    = obj.GetType().GetProperties();
            PropertyInfo   propertyInfo1 = ((IEnumerable <PropertyInfo>)properties).FirstOrDefault <PropertyInfo>((Func <PropertyInfo, bool>)(a => a.Name.ToLower() == "key"));
            PropertyInfo   propertyInfo2 = ((IEnumerable <PropertyInfo>)properties).FirstOrDefault <PropertyInfo>((Func <PropertyInfo, bool>)(a => a.Name.ToLower() == "label"));
            PropertyInfo   propertyInfo3 = ((IEnumerable <PropertyInfo>)properties).FirstOrDefault <PropertyInfo>((Func <PropertyInfo, bool>)(a => a.Name.ToLower() == "open"));
            PropertyInfo   propertyInfo4 = ((IEnumerable <PropertyInfo>)properties).FirstOrDefault <PropertyInfo>((Func <PropertyInfo, bool>)(a => a.Name.ToLower() == "children"));

            if (propertyInfo1 == null && propertyInfo2 == null)
            {
                return;
            }
            foreach (object unit in units)
            {
                IEnumerable <object> objects      = propertyInfo3.GetValue(unit, (object[])null) as IEnumerable <object>;
                TimelineUnit         timelineUnit = this.AddOption(new TimelineUnit(propertyInfo1.GetValue(unit, (object[])null), propertyInfo2.GetValue(unit, (object[])null), propertyInfo3 != null && (bool)propertyInfo3.GetValue(unit, (object[])null)));
                if (propertyInfo4 != null && objects != null)
                {
                    timelineUnit.AddOptions((IEnumerable)objects);
                }
            }
        }
        public TimelineUnit AddOption(object unit)
        {
            PropertyInfo[] properties    = unit.GetType().GetProperties();
            PropertyInfo   propertyInfo1 = ((IEnumerable <PropertyInfo>)properties).FirstOrDefault <PropertyInfo>((Func <PropertyInfo, bool>)(a => a.Name.ToLower() == "key"));
            PropertyInfo   propertyInfo2 = ((IEnumerable <PropertyInfo>)properties).FirstOrDefault <PropertyInfo>((Func <PropertyInfo, bool>)(a => a.Name.ToLower() == "label"));
            PropertyInfo   propertyInfo3 = ((IEnumerable <PropertyInfo>)properties).FirstOrDefault <PropertyInfo>((Func <PropertyInfo, bool>)(a => a.Name.ToLower() == "open"));
            PropertyInfo   propertyInfo4 = ((IEnumerable <PropertyInfo>)properties).FirstOrDefault <PropertyInfo>((Func <PropertyInfo, bool>)(a => a.Name.ToLower() == "children"));

            if (propertyInfo1 == null && propertyInfo2 == null)
            {
                return((TimelineUnit)null);
            }
            TimelineUnit         timelineUnit = this.AddOption(new TimelineUnit(propertyInfo1.GetValue(unit, (object[])null), propertyInfo2.GetValue(unit, (object[])null), propertyInfo3 != null && (bool)propertyInfo3.GetValue(unit, (object[])null)));
            IEnumerable <object> objects      = propertyInfo3.GetValue(unit, (object[])null) as IEnumerable <object>;

            if (propertyInfo4 != null && objects != null)
            {
                timelineUnit.AddOptions((IEnumerable)objects);
            }
            return(timelineUnit);
        }