Example #1
0
        private static string _Translate(string token, string format)
        {
            if (String.IsNullOrEmpty(token))
            {
                return(token);
            }

            switch (token)
            {
            case ApplicationName:
                return(ChoObject.Format(ChoAppSettings.Me.ApplicationId, format));

            case MachineName:
                return(ChoObject.Format(Environment.MachineName, format));

            case ProcessId:
                return(ChoObject.Format(ChoSystemInfo.ProcessId, format));

            case ThreadId:
                return(ChoObject.Format(ChoSystemInfo.GetThreadId(), format));

            case ThreadName:
                return(ChoObject.Format(ChoSystemInfo.GetThreadName(), format));

            case RandomNo:
                return(ChoObject.Format(ChoRandom.NextRandom().ToString(), format));

            case DateTime:
                return(ChoObject.Format(System.DateTime.Now, format));

            case Date:
                if (String.IsNullOrEmpty(format))
                {
                    return(System.DateTime.Today.ToShortDateString());
                }
                else
                {
                    return(ChoObject.Format(System.DateTime.Today, format));
                }

            case Time:
                if (String.IsNullOrEmpty(format))
                {
                    return(System.DateTime.Now.ToShortTimeString());
                }
                else
                {
                    return(ChoObject.Format(System.DateTime.Now, format));
                }

            default:
                return(ChoObject.Format(token, format));
            }
        }
Example #2
0
        public string Replace(string propertyName, string format)
        {
            if (String.IsNullOrEmpty(propertyName))
            {
                return(propertyName);
            }

            switch (propertyName)
            {
            case ApplicationName:
                return(ChoObject.Format(ChoAppSettings.Me.ApplicationId, format));

            case MachineName:
                return(ChoObject.Format(Environment.MachineName, format));

            case ProcessId:
                return(ChoObject.Format(ChoApplicationInfo.ProcessId, format));

            case ThreadId:
                return(ChoObject.Format(ChoApplicationInfo.GetThreadId(), format));

            case ThreadName:
                return(ChoObject.Format(ChoApplicationInfo.GetThreadName(), format));

            case RandomNo:
                return(ChoObject.Format(ChoRandom.NextRandom().ToString(), format));

            case DateTime:
                return(ChoObject.Format(System.DateTime.Now, format));

            case Date:
                if (String.IsNullOrEmpty(format))
                {
                    return(System.DateTime.Today.ToShortDateString());
                }
                else
                {
                    return(ChoObject.Format(System.DateTime.Today, format));
                }

            case Time:
                if (String.IsNullOrEmpty(format))
                {
                    return(System.DateTime.Now.ToShortTimeString());
                }
                else
                {
                    return(ChoObject.Format(System.DateTime.Now, format));
                }

            default:
                return(ChoObject.Format(propertyName, format));
            }
        }