2 // This file is part of the LWES .NET Binding (LWES.net)
4 // COPYRIGHT (C) 2009, Phillip Clark (cerebralkungfu[at*g mail[dot*com)
5 // original .NET implementation
7 // LWES.net is free software: you can redistribute it and/or modify
8 // it under the terms of the Lesser GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
12 // LWES.net is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the Lesser GNU General Public License
18 // along with LWES.net. If not, see <http://www.gnu.org/licenses/>.
20 namespace Org
.Lwes
.Config
23 using System
.Collections
.Generic
;
24 using System
.Configuration
;
30 /// Configuration section for an event template DB.
32 public class TemplateDBConfigurationSection
: ConfigurationSection
37 /// Property name for includeSubdirectories
39 public const string PropertyName_includeSubdirectories
= "includeSubdirectories";
42 /// Property name for the tempate DB's name.
44 public const string PropertyName_name
= "name";
47 /// Property name for the path.
49 public const string PropertyName_path
= "path";
51 private static readonly string AppPathToken
= "$(AppPath)";
52 private static readonly int AppPathTokenLength
= AppPathToken
.Length
;
59 /// Path where the template DB should look for '.esf' files.
61 [ConfigurationProperty(PropertyName_includeSubdirectories
63 , DefaultValue
= false)]
64 public bool IncludeSubdirectories
66 get { return (bool)this[PropertyName_includeSubdirectories]; }
69 this[PropertyName_includeSubdirectories
] = value;
74 /// The name of the configured template DB.
76 [ConfigurationProperty(PropertyName_name
, IsRequired
= true)]
79 get { return (string)this[PropertyName_name]; }
80 set { this[PropertyName_name] = value; }
84 /// Path where the template DB should look for '.esf' files.
86 [ConfigurationProperty(PropertyName_path
90 get { return (string)this[PropertyName_path]; }
93 this[PropertyName_path
] = (!String
.IsNullOrEmpty(value) && value.Contains("$"))
94 ? ReplacePathTokens(value)
103 private string ReplacePathTokens(string value)
105 // The only token supported right now is the app-path, which must appear
106 // at the beginning of the string...
107 if (value.StartsWith(AppPathToken
, StringComparison
.InvariantCultureIgnoreCase
))
109 return String
.Concat(AppDomain
.CurrentDomain
.SetupInformation
.ApplicationBase
,
110 value.Substring(AppPathTokenLength
- 1));