1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #region Apache License
- #endregion
- #if !NETCF
- using System;
- using System.IO;
- namespace log4net.Util.PatternStringConverters
- {
-
-
-
-
-
-
-
-
-
-
-
-
- internal sealed class EnvironmentFolderPathPatternConverter : PatternConverter
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
- override protected void Convert(TextWriter writer, object state)
- {
- try
- {
- if (Option != null && Option.Length > 0)
- {
- Environment.SpecialFolder specialFolder =
- (Environment.SpecialFolder)Enum.Parse(typeof(Environment.SpecialFolder), Option, true);
- string envFolderPathValue = Environment.GetFolderPath(specialFolder);
- if (envFolderPathValue != null && envFolderPathValue.Length > 0)
- {
- writer.Write(envFolderPathValue);
- }
- }
- }
- catch (System.Security.SecurityException secEx)
- {
-
-
-
- LogLog.Debug(declaringType, "Security exception while trying to expand environment variables. Error Ignored. No Expansion.", secEx);
- }
- catch (Exception ex)
- {
- LogLog.Error(declaringType, "Error occurred while converting environment variable.", ex);
- }
- }
- #region Private Static Fields
-
-
-
-
-
-
-
- private readonly static Type declaringType = typeof(EnvironmentFolderPathPatternConverter);
- #endregion Private Static Fields
- }
- }
- #endif // !NETCF
|