GetByName() public static method

public static GetByName ( string name ) : string
name string
return string
Esempio n. 1
0
        private static string GetDateGroupName(DateTime date)
        {
            DateTime todayDate = DateTime.Today;

            if (date > todayDate)
            {
                return(Translation.Future);
            }

            if (date == todayDate)
            {
                return(Translation.Today);
            }
            if (date == todayDate.AddDays(-1))
            {
                return(Translation.Yesterday);
            }

            if (date >= GetStartOfWeek(todayDate))
            {
                return(Translation.GetByName(date.DayOfWeek.ToString()));
            }


            if (date >= GetStartOfWeek(todayDate.AddDays(-7)))
            {
                return(Translation.LastWeek);
            }
            if (date >= GetStartOfWeek(todayDate.AddDays(-14)))
            {
                return(Translation.TwoWeeksAgo);
            }
            if (date >= GetStartOfWeek(todayDate.AddDays(-21)))
            {
                return(Translation.ThreeWeeksAgo);
            }

            if (date >= GetStartOfMonth(todayDate).AddMonths(-1))
            {
                return(Translation.LastMonth);
            }
            if (date >= GetStartOfMonth(todayDate).AddMonths(-2))
            {
                return(Translation.TwoMonthsAgo);
            }
            if (date >= GetStartOfMonth(todayDate).AddMonths(-3))
            {
                return(Translation.ThreeMonthsAgo);
            }
            if (date >= GetStartOfYear(todayDate))
            {
                return(Translation.EarlierThisYear);
            }
            if (date >= GetStartOfYear(todayDate).AddYears(-1))
            {
                return(Translation.LastYear);
            }

            return(Translation.Older);
        }
Esempio n. 2
0
        private static string DetermineGroupName(DBMovieInfo movie)
        {
            switch (Browser.CurrentSortField)
            {
            case SortingFields.Title:
                // Either the first character of the title, or the word "Numeric"
                // should we have a category for special characters like numeric has?
                string groupName = "";
                if (movie.SortBy.Trim().Length > 0)
                {
                    groupName = movie.SortBy.Trim().Substring(0, 1).ToUpper();
                }

                // group all non-word characters together
                if (!Regex.Match(groupName, @"\w").Success)
                {
                    groupName = "#";
                }

                // numeric group
                int iTemp;
                if (int.TryParse(groupName, out iTemp))
                {
                    groupName = "0-9";
                }

                return(groupName);

            case SortingFields.DateAdded:
                return(GetDateGroupName(movie.DateAdded.Date));

            case SortingFields.ReleaseDate:
                return(Translation.GetByName("MonthName" + movie.ReleaseDate.Month.ToString()) + ", " + movie.ReleaseDate.Year.ToString());

            case SortingFields.Year:
                return(movie.Year.ToString());

            case SortingFields.Certification:
                return(movie.Certification.Trim().ToUpper());

            case SortingFields.Language:
                return(movie.Language.Trim().ToUpper());

            case SortingFields.Score:
                return(Math.Round(movie.Score).ToString());

            case SortingFields.Runtime:
                return("");

            case SortingFields.FileSize:
                string size = movie.LocalMedia[0].FileSize.ToFormattedByteString();
                // split the string to get size and unit
                string[] splits = size.Split(' ');
                // round the size to the nearest unit
                int roundedSize = (int)Math.Round(double.Parse(splits[0]), MidpointRounding.ToEven);
                // group by rounded size
                return(roundedSize.ToString() + " " + splits[1]);

            case SortingFields.FilePath:
                if (movie.LocalMedia.Count > 0)
                {
                    return(movie.LocalMedia[0].File.Directory.ToString());
                }
                else
                {
                    return("");
                }

            default:
                return("");
            }
        }