Ejemplo n.º 1
0
        public List <DocObject> ConvertEnumToList(Type enumType)
        {
            if (enumType == null)
            {
                return(new List <DocObject>());
            }
            var numArray  = (int[])Enum.GetValues(enumType);
            var names     = Enum.GetNames(enumType);
            var arrayList = new List <DocObject>();

            try
            {
                for (int index = 0; index < numArray.GetLength(0); ++index)
                {
                    var doc = new DocObject
                    {
                        DocId = numArray[index]
                    };
                    if (names[index].IndexOf("_", StringComparison.Ordinal) > -1)
                    {
                        names[index] = names[index].Replace("_", " ");
                    }
                    doc.DocName = names[index];
                    arrayList.Add(doc);
                }
            }
            catch (Exception ex)
            {
                return(new List <DocObject>());
            }
            return(arrayList);
        }
Ejemplo n.º 2
0
        public List <DocObject> GeneratYearList(int startYear, int stopYear)
        {
            try
            {
                if (startYear < 1 || stopYear < 1 || (stopYear < startYear))
                {
                    return(new List <DocObject>());
                }

                var yearList = new List <DocObject>();

                for (long i = startYear; i < stopYear + 1; i++)
                {
                    var doc = new DocObject
                    {
                        DocId   = i,
                        DocName = i.ToString(CultureInfo.InvariantCulture)
                    };
                    yearList.Add(doc);
                }
                return(yearList);
            }
            catch (Exception ex)
            {
                return(new List <DocObject>());
            }
        }