private string ResolveNGetPropetyValue(string format, string propertyName) { string configValue = null; string cmdLineArgValue = ChoEnvironment.GetCmdLineArgValue(propertyName); if (!cmdLineArgValue.IsNullOrWhiteSpace()) { return(cmdLineArgValue); } configValue = ChoETLFramework.GetConfigValue(propertyName); if (!configValue.IsNullOrWhiteSpace()) { try { if (format.IsNullOrWhiteSpace()) { return(configValue); } else { return(ChoUtility.Format(format, configValue)); } } catch { } } return(propertyName); }
public string ReplaceProperty(string propertyName, string format) { if (String.IsNullOrEmpty(propertyName)) { return(propertyName); } switch (propertyName) { case "CURRENT_DIRECTORY": return(ChoUtility.Format(format, Environment.CurrentDirectory)); case "MACHINE_NAME": return(ChoUtility.Format(format, Environment.MachineName)); case "OS_VERSION": return(ChoUtility.Format(format, Environment.OSVersion)); case "PROCESSOR_COUNT": return(ChoUtility.Format(format, Environment.ProcessorCount)); case "SYSTEM_DIRECTORY": return(ChoUtility.Format(format, Environment.SystemDirectory)); case "SYSTEM_PAGE_SIZE": return(ChoUtility.Format(format, Environment.SystemPageSize)); case "TICK_COUNT": return(ChoUtility.Format(format, Environment.TickCount)); case "USER_DOMAIN_NAME": return(ChoUtility.Format(format, Environment.UserDomainName)); case "USER_NAME": return(ChoUtility.Format(format, Environment.UserName)); case "VERSION": return(ChoUtility.Format(format, Environment.Version)); case "WORKING_SET": return(ChoUtility.Format(format, Environment.WorkingSet)); default: { Environment.SpecialFolder specialFolder; if (Enum.TryParse <Environment.SpecialFolder>(propertyName, out specialFolder)) { return(ChoUtility.Format(format, Environment.GetFolderPath(specialFolder))); } else { return(ChoUtility.Format(format, Environment.GetEnvironmentVariable(propertyName))); } } } }
public string ReplaceProperty(string propertyName, string format) { if (String.IsNullOrEmpty(propertyName)) { return(propertyName); } switch (propertyName) { case "APPLICATION_NAME": return(ChoUtility.Format(format, Process.GetCurrentProcess().ProcessName)); case "PROCESS_ID": return(ChoUtility.Format(format, Process.GetCurrentProcess().Id)); case "THREAD_ID": return(ChoUtility.Format(format, Thread.CurrentThread.ManagedThreadId)); case "THREAD_NAME": return(ChoUtility.Format(format, Thread.CurrentThread.Name)); case "RANDOM_NO": ChoCryptoRandom rnd = new ChoCryptoRandom(); return(ChoUtility.Format(format, rnd.Next())); case "TODAY": if (String.IsNullOrEmpty(format)) { return(GetTodaysDate().ToShortDateString()); } else { return(ChoUtility.Format(format, GetTodaysDate())); } case "NOW": if (String.IsNullOrEmpty(format)) { return(GetNowTime().ToShortTimeString()); } else { return(ChoUtility.Format(format, GetNowTime())); } default: return(ResolveNGetPropetyValue(format, propertyName)); } }