Exemple #1
0
            public static int GetNumericArgument(string arg)
            {
                int result = 0;

                if (DTC.IsNumeric(arg))
                {
                    result = Convert.ToInt32(arg);
                }

                return(result);
            }
Exemple #2
0
            public static GoalGroupInfo Get(Dictionary <int, GoalGroupInfo> dict, object key)
            {
                int id = 0;

                if (DTC.IsNumeric(key))
                {
                    id = Convert.ToInt32(key);
                }

                if (dict.ContainsKey(id))
                {
                    return(dict[id]);
                }
                else
                {
                    return(new GoalGroupInfo());
                }
            }
Exemple #3
0
            public static PragmaInstanceInfo Get(Dictionary <int, PragmaInstanceInfo> dict, object key)
            {
                int id = 0;

                if (DTC.IsNumeric(key))
                {
                    id = Convert.ToInt32(key);
                }

                if (dict.ContainsKey(id))
                {
                    return(dict[id]);
                }
                else
                {
                    return(new PragmaInstanceInfo(new PragmaInfo()));
                }
            }
Exemple #4
0
            /// <summary>
            /// Extracts date from a sring in this format
            /// dd.mm.yyyy
            /// </summary>
            /// <param name="strDate">Date string in format dd.mm.yyyy</param>
            /// <returns>Date</returns>
            public static DateTime GetDateFromString(string strDate, DateStyleEnum dateStyle)
            {
                DateTime result = DateTime.MinValue;

                char[] sepAM  = { '/' };
                char[] sepEU  = { '.' };
                char[] sepUNI = { '-' };

                string[] str = { "" };

                if (dateStyle == DateStyleEnum.American)
                {
                    str = strDate.Split(sepAM, StringSplitOptions.None);
                }
                else if (dateStyle == DateStyleEnum.European)
                {
                    str = strDate.Split(sepEU, StringSplitOptions.None);
                }
                else if (dateStyle == DateStyleEnum.Universal)
                {
                    str = strDate.Split(sepUNI, StringSplitOptions.None);
                }

                if (str.Length == 3)
                {
                    int day   = 0;
                    int month = 0;
                    int year  = 0;
                    if (DTC.IsNumeric(str[0]))
                    {
                        if (dateStyle == DateStyleEnum.American)
                        {
                            month = Convert.ToInt16(str[0]);
                        }
                        else if (dateStyle == DateStyleEnum.European)
                        {
                            day = Convert.ToInt16(str[0]);
                        }
                        else if (dateStyle == DateStyleEnum.Universal)
                        {
                            year = Convert.ToInt16(str[0]);
                        }
                    }
                    if (DTC.IsNumeric(str[1]))
                    {
                        if (dateStyle == DateStyleEnum.American)
                        {
                            day = Convert.ToInt16(str[1]);
                        }
                        if (dateStyle == DateStyleEnum.European)
                        {
                            month = Convert.ToInt16(str[1]);
                        }
                        if (dateStyle == DateStyleEnum.Universal)
                        {
                            month = Convert.ToInt16(str[1]);
                        }
                    }
                    if (DTC.IsNumeric(str[2]))
                    {
                        if (dateStyle == DateStyleEnum.American)
                        {
                            year = Convert.ToInt16(str[2]);
                        }
                        else if (dateStyle == DateStyleEnum.European)
                        {
                            year = Convert.ToInt16(str[2]);
                        }
                        else if (dateStyle == DateStyleEnum.Universal)
                        {
                            day = Convert.ToInt16(str[2]);
                        }
                    }

                    if (day > 0 && month > 0 && year > 0)
                    {
                        result = new DateTime(year, month, day);
                    }
                }

                return(result);
            }