예제 #1
0
        /// <summary>Get the current day time saudation</summary>
        /// <param name="eLanguage">Text language</param>
        /// <returns>Current day time saudation</returns>
        //public String GetCurrentDayTimeSaudation(Language eLanguage)
        //{
        //    try
        //    {
        //        String sSaudation = null;
        //        DateTime dtNowTime = DateTime.Now;
        //        String sGoodMorningText = "";
        //        String sGoodAfternoonText = "";
        //        String sGoodNightText = "";
        //        switch (eLanguage)
        //        {
        //            case Language.PT:
        //                sGoodMorningText = "Bom dia";
        //                sGoodAfternoonText = "Boa tarde";
        //                sGoodNightText = "Boa noite";
        //                break;
        //            case Language.EN:
        //                sGoodMorningText = "Good morning";
        //                sGoodAfternoonText = "Good afternoon";
        //                sGoodNightText = "Good night";
        //                break;
        //        }
        //        if (dtNowTime.Hour >= 0 && dtNowTime.Hour < 12)
        //            sSaudation += sGoodMorningText;
        //        else if (dtNowTime.Hour >= 12 && dtNowTime.Hour < 20)
        //            sSaudation += sGoodAfternoonText;
        //        else
        //            sSaudation += sGoodNightText;
        //        return sSaudation;
        //    }
        //    catch { return null; }
        //}

        #endregion Public Methods

        #region Private Methods

        /// <summary>Split the elements of a TimeSpan object and add it to a text tring</summary>
        /// <param name="sTimeSpan">Time span object</param>
        /// <param name="iTimeSpanElementValue">Time span element</param>
        /// <param name="objTimeLanguageString">Language definition</param>
        /// <param name="sTimeSpanElementSeparation">String separation character</param>
        /// <returns>Time text string</returns>
        private String AddTimeSpanElementString(String sTimeSpan, Int32 iTimeSpanElementValue, TimeLanguageString objTimeLanguageString, String sTimeSpanElementSeparation)
        {
            try
            {
                if (iTimeSpanElementValue > 0)
                {
                    if (!String.IsNullOrEmpty(sTimeSpan))
                    {
                        sTimeSpan += sTimeSpanElementSeparation;
                    }
                    sTimeSpan += iTimeSpanElementValue.ToString() + " ";
                    if (iTimeSpanElementValue == 1)
                    {
                        sTimeSpan += objTimeLanguageString.SingularDescription;
                    }
                    else
                    {
                        sTimeSpan += objTimeLanguageString.PluralDescription;
                    }
                }
                return(sTimeSpan);
            }
            catch { return(""); }
        }
예제 #2
0
 public void Add(TimeLanguageString objTimeLanguageString)
 {
     this.ListStrings.Add(objTimeLanguageString);
 }
예제 #3
0
        /// <summary>Convert a TimeSpan into a string</summary>
        /// <param name="objTimeSpan">Time span</param>
        /// <param name="eLanguage">Language definition</param>
        /// <returns>Time string text</returns>
        public String ConvertTimeSpanIntoString(TimeSpan objTimeSpan, TimeSpanLanguageCollection.Language eLanguage)
        {
            try
            {
                String sTimeSpan = "";
                TimeSpanLanguageCollection objTimeSpanLanguageCollection = new TimeSpanLanguageCollection();
                objTimeSpanLanguageCollection.LanguageType = eLanguage;
                #region Set TimeSpan Language Strings
                switch (eLanguage)
                {
                    #region Portuguese TimeSpan Language Strings
                case TimeSpanLanguageCollection.Language.PT:
                    TimeLanguageStrings objTimeLanguageStringsPT = new TimeLanguageStrings();
                    #region Days
                    TimeLanguageString objTimeLanguageStringDaysPT = new TimeLanguageString();
                    objTimeLanguageStringDaysPT.TimeElement         = TimeLanguageString.TimeSpanElement.DAYS;
                    objTimeLanguageStringDaysPT.SingularDescription = "dia";
                    objTimeLanguageStringDaysPT.PluralDescription   = "dias";
                    objTimeLanguageStringsPT.ListStrings.Add(objTimeLanguageStringDaysPT);
                    #endregion Days
                    #region Hours
                    TimeLanguageString objTimeLanguageStringHoursPT = new TimeLanguageString();
                    objTimeLanguageStringHoursPT.TimeElement         = TimeLanguageString.TimeSpanElement.HOURS;
                    objTimeLanguageStringHoursPT.SingularDescription = "hora";
                    objTimeLanguageStringHoursPT.PluralDescription   = "horas";
                    objTimeLanguageStringsPT.ListStrings.Add(objTimeLanguageStringHoursPT);
                    #endregion Hours
                    #region Minuts
                    TimeLanguageString objTimeLanguageStringMinutsPT = new TimeLanguageString();
                    objTimeLanguageStringMinutsPT.TimeElement         = TimeLanguageString.TimeSpanElement.MINUTS;
                    objTimeLanguageStringMinutsPT.SingularDescription = "minuto";
                    objTimeLanguageStringMinutsPT.PluralDescription   = "minutos";
                    objTimeLanguageStringsPT.ListStrings.Add(objTimeLanguageStringMinutsPT);
                    #endregion Minuts
                    #region Seconds
                    TimeLanguageString objTimeLanguageStringSecondsPT = new TimeLanguageString();
                    objTimeLanguageStringSecondsPT.TimeElement         = TimeLanguageString.TimeSpanElement.SECONDS;
                    objTimeLanguageStringSecondsPT.SingularDescription = "segundo";
                    objTimeLanguageStringSecondsPT.PluralDescription   = "segundos";
                    objTimeLanguageStringsPT.ListStrings.Add(objTimeLanguageStringSecondsPT);
                    #endregion Seconds
                    #region Miliseconds
                    TimeLanguageString objTimeLanguageStringMilisecondsPT = new TimeLanguageString();
                    objTimeLanguageStringMilisecondsPT.TimeElement         = TimeLanguageString.TimeSpanElement.MILISECONDS;
                    objTimeLanguageStringMilisecondsPT.SingularDescription = "dia";
                    objTimeLanguageStringMilisecondsPT.PluralDescription   = "dias";
                    objTimeLanguageStringsPT.ListStrings.Add(objTimeLanguageStringMilisecondsPT);
                    #endregion Miliseconds
                    objTimeSpanLanguageCollection.Add(objTimeLanguageStringsPT);
                    break;

                    #endregion Portuguese TimeSpan Language Strings
                    #region English TimeSpan Language Strings
                case TimeSpanLanguageCollection.Language.EN:
                    TimeLanguageStrings objTimeLanguageStringsEN = new TimeLanguageStrings();
                    #region Days
                    TimeLanguageString objTimeLanguageStringDaysEN = new TimeLanguageString();
                    objTimeLanguageStringDaysEN.TimeElement         = TimeLanguageString.TimeSpanElement.DAYS;
                    objTimeLanguageStringDaysEN.SingularDescription = "day";
                    objTimeLanguageStringDaysEN.PluralDescription   = "days";
                    objTimeLanguageStringsEN.ListStrings.Add(objTimeLanguageStringDaysEN);
                    #endregion Days
                    #region Hours
                    TimeLanguageString objTimeLanguageStringHoursEN = new TimeLanguageString();
                    objTimeLanguageStringHoursEN.TimeElement         = TimeLanguageString.TimeSpanElement.HOURS;
                    objTimeLanguageStringHoursEN.SingularDescription = "hour";
                    objTimeLanguageStringHoursEN.PluralDescription   = "hours";
                    objTimeLanguageStringsEN.ListStrings.Add(objTimeLanguageStringHoursEN);
                    #endregion Hours
                    #region Minuts
                    TimeLanguageString objTimeLanguageStringMinutsEN = new TimeLanguageString();
                    objTimeLanguageStringMinutsEN.TimeElement         = TimeLanguageString.TimeSpanElement.MINUTS;
                    objTimeLanguageStringMinutsEN.SingularDescription = "minute";
                    objTimeLanguageStringMinutsEN.PluralDescription   = "minutes";
                    objTimeLanguageStringsEN.ListStrings.Add(objTimeLanguageStringMinutsEN);
                    #endregion Minuts
                    #region Seconds
                    TimeLanguageString objTimeLanguageStringSecondsEN = new TimeLanguageString();
                    objTimeLanguageStringSecondsEN.TimeElement         = TimeLanguageString.TimeSpanElement.SECONDS;
                    objTimeLanguageStringSecondsEN.SingularDescription = "second";
                    objTimeLanguageStringSecondsEN.PluralDescription   = "seconds";
                    objTimeLanguageStringsEN.ListStrings.Add(objTimeLanguageStringSecondsEN);
                    #endregion Seconds
                    #region Miliseconds
                    TimeLanguageString objTimeLanguageStringMilisecondsEN = new TimeLanguageString();
                    objTimeLanguageStringMilisecondsEN.TimeElement         = TimeLanguageString.TimeSpanElement.MILISECONDS;
                    objTimeLanguageStringMilisecondsEN.SingularDescription = "milisecond";
                    objTimeLanguageStringMilisecondsEN.PluralDescription   = "miliseconds";
                    objTimeLanguageStringsEN.ListStrings.Add(objTimeLanguageStringMilisecondsEN);
                    #endregion Miliseconds
                    objTimeSpanLanguageCollection.Add(objTimeLanguageStringsEN);
                    break;
                    #endregion English TimeSpan Language Strings
                }
                #endregion Set TimeSpan Language Strings
                #region Get TimeSpan String
                foreach (TimeLanguageString objTimeLanguageString in objTimeSpanLanguageCollection.ListTimeStrings[0].ListStrings)
                {
                    switch (objTimeLanguageString.TimeElement)
                    {
                    case TimeLanguageString.TimeSpanElement.DAYS:
                        sTimeSpan = AddTimeSpanElementString(sTimeSpan, objTimeSpan.Days, objTimeLanguageString, ", ");
                        break;

                    case TimeLanguageString.TimeSpanElement.HOURS:
                        sTimeSpan = AddTimeSpanElementString(sTimeSpan, objTimeSpan.Hours, objTimeLanguageString, ", ");
                        break;

                    case TimeLanguageString.TimeSpanElement.MINUTS:
                        sTimeSpan = AddTimeSpanElementString(sTimeSpan, objTimeSpan.Minutes, objTimeLanguageString, ", ");
                        break;

                    case TimeLanguageString.TimeSpanElement.SECONDS:
                        sTimeSpan = AddTimeSpanElementString(sTimeSpan, objTimeSpan.Seconds, objTimeLanguageString, ", ");
                        break;

                    case TimeLanguageString.TimeSpanElement.MILISECONDS:
                        sTimeSpan = AddTimeSpanElementString(sTimeSpan, objTimeSpan.Milliseconds, objTimeLanguageString, ", ");
                        break;
                    }
                }
                #endregion Get TimeSpan String
                return(sTimeSpan);
            }
            catch { return(""); }
        }