Esempio n. 1
0
        public IEnumerable <MonthVm> GetMonthData()
        {
            var monthData = DateTimeFormatInfo.CurrentInfo.MonthNames.AsEnumerable();

            List <MonthVm> result    = new List <MonthVm>();
            MonthVm        monthVm   = null;
            Int16          LoopCount = 0;

            foreach (var month in monthData)
            {
                if (string.IsNullOrWhiteSpace(month))
                {
                    continue;
                }

                monthVm = new MonthVm
                {
                    Name  = month,
                    Value = LoopCount++
                };

                result.Add(monthVm);
            }

            return(result.AsEnumerable <MonthVm>());
        }
Esempio n. 2
0
        /// <summary>
        /// The get or create.
        /// </summary>
        /// <param name="dateInfo">
        /// The date info.
        /// </param>
        /// <returns>
        /// The <see cref="DateVm"/>.
        /// </returns>
        public DateVm GetOrCreate(DateInfoModel dateInfo)
        {
            DateVm result = this.dateVmCollection.FirstOrDefault(dateVm => dateVm.IsDateEqual(dateInfo));

            if (this.dateVmCollection.Count > CacheSize)
            {
                this.dateVmCollection.RemoveRange(0, this.dateVmCollection.Count - CacheSize);
            }

            if (result != null)
            {
                return(result);
            }

            switch (dateInfo.DateType)
            {
            case DateRepresentationType.Year:
            {
                result = new YearVm(dateInfo, this, this.taskMediator);
                break;
            }

            case DateRepresentationType.Month:
            {
                result = new MonthVm(dateInfo, this, this.taskMediator);
                break;
            }

            case DateRepresentationType.Week:
            {
                result = new WeekVm(dateInfo, this, this.taskMediator);
                break;
            }

            case DateRepresentationType.Day:
            {
                result = new DayVm(dateInfo, this, this.taskMediator);
                break;
            }

            case DateRepresentationType.Hour:
            {
                result = new HourVm(dateInfo, this, this.taskMediator);
                break;
            }

            default:
            {
                return(null);
            }
            }

            this.dateVmCollection.Add(result);
            return(result);
        }