();
+
+ EnvironmentElement Env = ConfigSettings.Settings.Environments[EnvironmentName];
+ KeyValueElementCollection KvColl = Env.Configs;
+
+ foreach (KeyValueElement KeyValue in Env.Configs)
+ {
+ ReturnList.Add(KeyValue);
+ }
+
+ if (IncludeDefaults)
+ {
+ EnvironmentElement EnvDefault = ConfigSettings.Settings.Environments["default"];
+
+ foreach (KeyValueElement KeyValueDef in EnvDefault.Configs)
+ {
+ if (KvColl[KeyValueDef.Key]==null)
+ {
+ ReturnList.Add(KeyValueDef);
+ }
+ }
+ }
+
+ return ReturnList;
+ }
+
+ #endregion
+
+ #region SMTP settings
+ ///
+ /// Get the SMTP Settings for the current domain
+ ///
+ /// Include all ‘default’ smtp configs for properties not specifically defined for the current domain.
+ ///
+ public static SmtpSettingsElement GetSmtpSettings(bool IncludeDefaults = true)
+ {
+ SmtpSettingsElement ReturnValue = null;
+ ReturnValue = GetSmtpSettings(DomainEnvironmentName(), IncludeDefaults);
+
+ return ReturnValue;
+ }
+
+ ///
+ /// Get the SMTP Settings for a given environment
+ ///
+ /// Environment to get smtp config from
+ /// Include all ‘default’ smtp configs for properties not specifically defined for the current domain.
+ ///
+ public static SmtpSettingsElement GetSmtpSettings(string EnvironmentName, bool IncludeDefaults = true)
+ {
+ SmtpSettingsElement ReturnValue = new SmtpSettingsElement();
+
+ EnvironmentElement Env = ConfigSettings.Settings.Environments[EnvironmentName];
+ EnvironmentElement DefaultEnv = ConfigSettings.Settings.Environments["default"];
+
+ // fills the return value with the values from the requested environment
+ if (Env != null)
+ FillUndefinedSmtpSettings(ReturnValue, Env.SmtpSettings);
+ // fills the still undefined properties of the return value with the values from the default environment
+ if (IncludeDefaults && DefaultEnv != null)
+ FillUndefinedSmtpSettings(ReturnValue, DefaultEnv.SmtpSettings);
+
+ return ReturnValue;
+ }
+
+ ///
+ /// Performs a property per property fill of undefined properties of an SmtpSettingsElement based on the values of another one
+ ///
+ /// The SmtpSettingsElement to fill
+ /// The SmtpSettingsElement to get values from
+ private static void FillUndefinedSmtpSettings(SmtpSettingsElement Target, SmtpSettingsElement Source)
+ {
+ if (Target.IsPropertyUndefined(SmtpSettingsElement.DeliveryFormatPropertyName) && !Source.IsPropertyUndefined(SmtpSettingsElement.DeliveryFormatPropertyName))
+ Target.DeliveryFormat= Source.DeliveryFormat;
+
+ if (Target.IsPropertyUndefined(SmtpSettingsElement.DeliveryMethodPropertyName) && !Source.IsPropertyUndefined(SmtpSettingsElement.DeliveryMethodPropertyName))
+ Target.DeliveryMethod= Source.DeliveryMethod;
+
+ if (Target.IsPropertyUndefined(SmtpSettingsElement.FromPropertyName) && !Source.IsPropertyUndefined(SmtpSettingsElement.FromPropertyName))
+ Target.From = Source.From;
+
+ if (Target.Network.IsPropertyUndefined(SmtpNetworkElement.ClientDomainPropertyName) && !Source.Network.IsPropertyUndefined(SmtpNetworkElement.ClientDomainPropertyName))
+ Target.Network.ClientDomain = Source.Network.ClientDomain;
+
+ if (Target.Network.IsPropertyUndefined(SmtpNetworkElement.DefaultCredentialsPropertyName) && !Source.Network.IsPropertyUndefined(SmtpNetworkElement.DefaultCredentialsPropertyName))
+ Target.Network.UseDefaultCredentials = Source.Network.UseDefaultCredentials;
+
+ if (Target.Network.IsPropertyUndefined(SmtpNetworkElement.EnableSslPropertyName) && !Source.Network.IsPropertyUndefined(SmtpNetworkElement.EnableSslPropertyName))
+ Target.Network.EnableSsl = Source.Network.EnableSsl;
+
+ if (Target.Network.IsPropertyUndefined(SmtpNetworkElement.HostPropertyName) && !Source.Network.IsPropertyUndefined(SmtpNetworkElement.HostPropertyName))
+ Target.Network.Host = Source.Network.Host;
+
+ if (Target.Network.IsPropertyUndefined(SmtpNetworkElement.PasswordPropertyName) && !Source.Network.IsPropertyUndefined(SmtpNetworkElement.PasswordPropertyName))
+ Target.Network.Password = Source.Network.Password;
+
+ if (Target.Network.IsPropertyUndefined(SmtpNetworkElement.PortPropertyName) && !Source.Network.IsPropertyUndefined(SmtpNetworkElement.PortPropertyName))
+ Target.Network.Port = Source.Network.Port;
+
+ if (Target.Network.IsPropertyUndefined(SmtpNetworkElement.TargetNamePropertyName) && !Source.Network.IsPropertyUndefined(SmtpNetworkElement.TargetNamePropertyName))
+ Target.Network.TargetName = Source.Network.TargetName;
+
+ if (Target.Network.IsPropertyUndefined(SmtpNetworkElement.UserNamePropertyName) && !Source.Network.IsPropertyUndefined(SmtpNetworkElement.UserNamePropertyName))
+ Target.Network.UserName = Source.Network.UserName;
+
+ if (Target.SpecifiedPickupDirectory.IsPropertyUndefined(SmtpSpecifiedPickupDirectoryElement.PickupDirectoryLocationPropertyName) && !Source.SpecifiedPickupDirectory.IsPropertyUndefined(SmtpSpecifiedPickupDirectoryElement.PickupDirectoryLocationPropertyName))
+ Target.SpecifiedPickupDirectory.PickupDirectoryLocation = Source.SpecifiedPickupDirectory.PickupDirectoryLocation;
+ }
+ #endregion
+ }
+
+ #region *** Custom Exceptions ***
+
+ [Serializable]
+ internal class MissingDomainConfigException : Exception
+ {
+ // Use the default ApplicationException constructors
+ public MissingDomainConfigException() : base()
+ {
+ }
+
+ public MissingDomainConfigException(string s) : base(s)
+ {
+ }
+
+ public MissingDomainConfigException(string s, Exception ex) : base(s, ex)
+ {
+ }
+ }
+
+ [Serializable]
+ internal class MissingEnvironmentConfigException : Exception
+ {
+ // Use the default ApplicationException constructors
+ public MissingEnvironmentConfigException() : base()
+ {
+ }
+
+ public MissingEnvironmentConfigException(string s) : base(s)
+ {
+ }
+
+ public MissingEnvironmentConfigException(string s, Exception ex) : base(s, ex)
+ {
+ }
+ }
+
+ [Serializable]
+ internal class MissingConfigKeyException : Exception
+ {
+ // Use the default ApplicationException constructors
+ public MissingConfigKeyException() : base()
+ {
+ }
+
+ public MissingConfigKeyException(string s) : base(s)
+ {
+ }
+
+ public MissingConfigKeyException(string s, Exception ex) : base(s, ex)
+ {
+ }
+ }
+
+ #endregion
+
+}
+
diff --git a/Source/TestSite/Default.aspx.cs b/Source/TestSite/Default.aspx.cs
index 757965d..e4263d0 100644
--- a/Source/TestSite/Default.aspx.cs
+++ b/Source/TestSite/Default.aspx.cs
@@ -1,268 +1,327 @@
-using System;
-using System.Configuration;
-using System.Configuration.Internal;
-using System.Reflection;
-using HLF.ContextConfig;
-
-namespace TestSite
-{
- public partial class Default : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- Response.Write("Hello!
");
-
- Response.Write("All Configuration Data
");
- Response.Write("(Using the 'ConfigSettings' class)
");
- WriteData();
- Response.Write("
");
-
- Response.Write("Testing Functions
");
- Response.Write("(Using the 'ContextConfig' class)
");
- LookupStuff();
- Response.Write("
");
-
- Response.Write("Testing Web.config Override
");
- Response.Write("(Using the 'ContextConfigOverride' class)
");
- TestConfigOverride();
- Response.Write("
");
- }
-
- private void WriteData()
- {
- string Version = ConfigSettings.Settings.Version;
- Response.Write(string.Format("Version: {0}
", Version));
- Response.Write("
");
-
- int DomainsCount = ConfigSettings.Settings.Domains.Count;
- Response.Write(string.Format("Total Domains: {0}
", DomainsCount));
-
- int d = 0;
- foreach (DomainElement Domain in ConfigSettings.Settings.Domains)
- {
- Response.Write(string.Format("Domain {0} : {1} = {2} ({3})
", d, Domain.Url, Domain.Environment, Domain.SiteName));
- d++;
- }
- Response.Write("
");
-
- int EnvironmentsCount = ConfigSettings.Settings.Environments.Count;
- Response.Write(string.Format("Total Environments: {0}
", EnvironmentsCount));
-
- int e = 0;
- foreach (EnvironmentElement Env in ConfigSettings.Settings.Environments)
- {
- Response.Write(string.Format("Environment {0} : {1}
", e, Env.Name));
- e++;
-
- int ConfigsCount = Env.Configs.Count;
- Response.Write(string.Format("ConfigsCount: {0} ", ConfigsCount));
-
- int c = 0;
- foreach (KeyValueElement KeyValue in Env.Configs)
- {
- Response.Write(string.Format("- {0} = {1}
", KeyValue.Key, KeyValue.Value));
- c++;
- }
- Response.Write("
");
- }
- Response.Write("
");
-
- }
-
- private void LookupStuff()
- {
- try
- {
- string B = ContextConfig.CurrentDomain;
- Response.Write(string.Format("ContextConfig.CurrentDomain = {0}
", B));
- }
- catch (Exception Ex)
- {
- Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
- }
-
- try
- {
- string D = ContextConfig.DomainIsConfigured().ToString();
- Response.Write(string.Format("ContextConfig.DomainIsConfigured() = {0}
", D));
- }
- catch (Exception Ex)
- {
- Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
- }
-
- try
- {
-
- string F = ContextConfig.DomainIsConfigured("xyz.com").ToString();
- Response.Write(string.Format("ContextConfig.DomainIsConfigured(\"xyz.com\") = {0}
", F));
- }
- catch (Exception Ex)
- {
- Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
- }
-
- try
- {
- string G = ContextConfig.DomainIsConfigured("xyz.com", false).ToString();
- Response.Write(string.Format("ContextConfig.DomainIsConfigured(\"xyz.com\", false) = {0}
", G));
- }
- catch (Exception Ex)
- {
- Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
- }
-
- try
- {
- string E = ContextConfig.DomainEnvironmentName();
- Response.Write(string.Format("ContextConfig.DomainEnvironmentName() = {0}
", E));
- }
- catch (Exception Ex)
- {
- Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
- }
-
- try
- {
- string H = ContextConfig.DomainEnvironmentName("xyz.com");
- Response.Write(string.Format("ContextConfig.DomainEnvironmentName(\"xyz.com\") = {0}
", H));
- }
- catch (Exception Ex)
- {
- Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
- }
-
- Response.Write("
");
-
- try
- {
- string E = ContextConfig.DomainSiteName();
- Response.Write(string.Format("ContextConfig.DomainSiteName() = {0}
", E));
- }
- catch (Exception Ex)
- {
- Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
- }
-
- try
- {
- string H = ContextConfig.DomainSiteName("xyz.com");
- Response.Write(string.Format("ContextConfig.DomainSiteName(\"xyz.com\") = {0}
", H));
- }
- catch (Exception Ex)
- {
- Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
- }
-
- Response.Write("
");
-
- try
- {
- string I = ContextConfig.EnvironmentIsConfigured().ToString();
- Response.Write(string.Format("ContextConfig.EnvironmentIsConfigured() = {0}
", I));
- }
- catch (Exception Ex)
- {
- Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
- }
-
- try
- {
- string I = ContextConfig.DomainEnvironmentName().ToString();
- Response.Write(string.Format("ContextConfig.DomainEnvironmentName() = {0}
", I));
- }
- catch (Exception Ex)
- {
- Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
- }
-
- try
- {
- string J = ContextConfig.EnvironmentIsConfigured("testing").ToString();
- Response.Write(string.Format("ContextConfig.EnvironmentIsConfigured(\"testing\") = {0}
", J));
- }
- catch (Exception Ex)
- {
- Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
- }
-
- try
- {
- string K = ContextConfig.EnvironmentIsConfigured("testing", false).ToString();
- Response.Write(string.Format("ContextConfig.EnvironmentIsConfigured(\"testing\", false) = {0}
", K));
- }
- catch (Exception Ex)
- {
- Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
- }
-
- Response.Write("
");
-
- try
- {
- string C = ContextConfig.GetValue("MyAppKey");
- Response.Write(string.Format("ContextConfig.GetValue(\"MyAppKey\") = {0}
", C));
- }
- catch (Exception Ex)
- {
- Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
- }
-
- try
- {
- string A = ContextConfig.GetValue("MyAppKey", "dev");
- Response.Write(string.Format("ContextConfig.GetValue(\"MyAppKey\", \"dev\") = {0}
", A));
- }
- catch (Exception Ex)
- {
- Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
- }
-
- try
- {
- string L = ContextConfig.GetValue("LiveOnlyAppKey", "live");
- Response.Write(string.Format("ContextConfig.GetValue(\"LiveOnlyAppKey\", \"live\") = {0}
", L));
- }
- catch (Exception Ex)
- {
- Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
- }
-
- try
- {
- string M = ContextConfig.GetValue("LiveOnlyAppKey");
- Response.Write(string.Format("ContextConfig.GetValue(\"LiveOnlyAppKey\") = {0}
", M));
- }
- catch (Exception Ex)
- {
- Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
- }
-
- try
- {
- string N = ContextConfig.GetValue("KeyThatDoesntExist");
- Response.Write("Here we throw an error intentionally:");
- Response.Write(string.Format("ContextConfig.GetValue(\"KeyThatDoesntExist\") = {0}
", N));
- }
- catch (Exception Ex)
- {
- Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
- }
-
- }
-
- private void TestConfigOverride()
- {
- Response.Write(string.Format("'OverrideConfigurationManager' value in config = {0}
", ConfigSettings.Settings.OverrideConfigurationManager));
-
- // test it
- string Test = ConfigurationManager.AppSettings["OverrideTest"];
- Response.Write(string.Format("OverrideTest = {0}
", Test));
-
- // test missing value
- string TestNull = ConfigurationManager.AppSettings["NoKey"];
- Response.Write(string.Format("Missing Key = {0}
", TestNull));
-
- }
- }
+using System;
+using System.Configuration;
+using System.Configuration.Internal;
+using System.Reflection;
+using HLF.ContextConfig;
+
+namespace TestSite
+{
+ public partial class Default : System.Web.UI.Page
+ {
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ Response.Write("Hello!
");
+
+ Response.Write("All Configuration Data
");
+ Response.Write("(Using the 'ConfigSettings' class)
");
+ WriteData();
+ Response.Write("
");
+
+ Response.Write("Testing Functions
");
+ Response.Write("(Using the 'ContextConfig' class)
");
+ LookupStuff();
+ Response.Write("
");
+
+ Response.Write("Testing Web.config Override
");
+ Response.Write("(Using the 'ContextConfigOverride' class)
");
+ TestConfigOverride();
+ Response.Write("
");
+
+ }
+
+ private void WriteData()
+ {
+ string Version = ConfigSettings.Settings.Version;
+ Response.Write(string.Format("Version: {0}
", Version));
+ Response.Write("
");
+
+ int DomainsCount = ConfigSettings.Settings.Domains.Count;
+ Response.Write(string.Format("Total Domains: {0}
", DomainsCount));
+
+ int d = 0;
+ foreach (DomainElement Domain in ConfigSettings.Settings.Domains)
+ {
+ Response.Write(string.Format("Domain {0} : {1} = {2} ({3})
", d, Domain.Url, Domain.Environment, Domain.SiteName));
+ d++;
+ }
+ Response.Write("
");
+
+ int EnvironmentsCount = ConfigSettings.Settings.Environments.Count;
+ Response.Write(string.Format("Total Environments: {0}
", EnvironmentsCount));
+
+ int e = 0;
+ foreach (EnvironmentElement Env in ConfigSettings.Settings.Environments)
+ {
+ Response.Write(string.Format("Environment {0} : {1}
", e, Env.Name));
+ e++;
+
+ int ConfigsCount = Env.Configs.Count;
+ Response.Write(string.Format("ConfigsCount: {0} ", ConfigsCount));
+
+ int c = 0;
+ foreach (KeyValueElement KeyValue in Env.Configs)
+ {
+ Response.Write(string.Format("- {0} = {1}
", KeyValue.Key, KeyValue.Value));
+ c++;
+ }
+ Response.Write("
");
+
+ Response.Write("SMTP Settings");
+ var smtpSettings = Env.SmtpSettings;
+ Response.Write(string.Format("- From = {0}
", smtpSettings.From));
+ Response.Write(string.Format("- Delivery Method = {0}
", smtpSettings.DeliveryMethod));
+ Response.Write(string.Format("- Delivery Format = {0}
", smtpSettings.DeliveryFormat));
+ Response.Write(string.Format("- Use Default Credentials = {0}
", smtpSettings.Network.UseDefaultCredentials));
+ Response.Write(string.Format("- Enable SSL = {0}
", smtpSettings.Network.EnableSsl));
+ Response.Write(string.Format("- Host = {0}
", smtpSettings.Network.Host));
+ Response.Write(string.Format("- Port = {0}
", smtpSettings.Network.Port));
+ Response.Write(string.Format("- Client Domain = {0}
", smtpSettings.Network.ClientDomain));
+ Response.Write(string.Format("- User Name = {0}
", smtpSettings.Network.UserName));
+ Response.Write(string.Format("- Password = {0}
", smtpSettings.Network.Password));
+ Response.Write(string.Format("- Target Name = {0}
", smtpSettings.Network.TargetName));
+ Response.Write(string.Format("- Pickup Directory Location = {0}
", smtpSettings.SpecifiedPickupDirectory.PickupDirectoryLocation));
+ Response.Write("
");
+
+ }
+ Response.Write("
");
+ }
+
+ private void LookupStuff()
+ {
+ try
+ {
+ string B = ContextConfig.CurrentDomain;
+ Response.Write(string.Format("ContextConfig.CurrentDomain = {0}
", B));
+ }
+ catch (Exception Ex)
+ {
+ Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
+ }
+
+ try
+ {
+ string D = ContextConfig.DomainIsConfigured().ToString();
+ Response.Write(string.Format("ContextConfig.DomainIsConfigured() = {0}
", D));
+ }
+ catch (Exception Ex)
+ {
+ Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
+ }
+
+ try
+ {
+
+ string F = ContextConfig.DomainIsConfigured("xyz.com").ToString();
+ Response.Write(string.Format("ContextConfig.DomainIsConfigured(\"xyz.com\") = {0}
", F));
+ }
+ catch (Exception Ex)
+ {
+ Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
+ }
+
+ try
+ {
+ string G = ContextConfig.DomainIsConfigured("xyz.com", false).ToString();
+ Response.Write(string.Format("ContextConfig.DomainIsConfigured(\"xyz.com\", false) = {0}
", G));
+ }
+ catch (Exception Ex)
+ {
+ Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
+ }
+
+ try
+ {
+ string E = ContextConfig.DomainEnvironmentName();
+ Response.Write(string.Format("ContextConfig.DomainEnvironmentName() = {0}
", E));
+ }
+ catch (Exception Ex)
+ {
+ Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
+ }
+
+ try
+ {
+ string H = ContextConfig.DomainEnvironmentName("xyz.com");
+ Response.Write(string.Format("ContextConfig.DomainEnvironmentName(\"xyz.com\") = {0}
", H));
+ }
+ catch (Exception Ex)
+ {
+ Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
+ }
+
+ Response.Write("
");
+
+ try
+ {
+ string E = ContextConfig.DomainSiteName();
+ Response.Write(string.Format("ContextConfig.DomainSiteName() = {0}
", E));
+ }
+ catch (Exception Ex)
+ {
+ Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
+ }
+
+ try
+ {
+ string H = ContextConfig.DomainSiteName("xyz.com");
+ Response.Write(string.Format("ContextConfig.DomainSiteName(\"xyz.com\") = {0}
", H));
+ }
+ catch (Exception Ex)
+ {
+ Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
+ }
+
+ Response.Write("
");
+
+ try
+ {
+ string I = ContextConfig.EnvironmentIsConfigured().ToString();
+ Response.Write(string.Format("ContextConfig.EnvironmentIsConfigured() = {0}
", I));
+ }
+ catch (Exception Ex)
+ {
+ Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
+ }
+
+ try
+ {
+ string I = ContextConfig.DomainEnvironmentName().ToString();
+ Response.Write(string.Format("ContextConfig.DomainEnvironmentName() = {0}
", I));
+ }
+ catch (Exception Ex)
+ {
+ Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
+ }
+
+ try
+ {
+ string J = ContextConfig.EnvironmentIsConfigured("testing").ToString();
+ Response.Write(string.Format("ContextConfig.EnvironmentIsConfigured(\"testing\") = {0}
", J));
+ }
+ catch (Exception Ex)
+ {
+ Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
+ }
+
+ try
+ {
+ string K = ContextConfig.EnvironmentIsConfigured("testing", false).ToString();
+ Response.Write(string.Format("ContextConfig.EnvironmentIsConfigured(\"testing\", false) = {0}
", K));
+ }
+ catch (Exception Ex)
+ {
+ Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
+ }
+
+ Response.Write("
");
+
+ try
+ {
+ string C = ContextConfig.GetValue("MyAppKey");
+ Response.Write(string.Format("ContextConfig.GetValue(\"MyAppKey\") = {0}
", C));
+ }
+ catch (Exception Ex)
+ {
+ Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
+ }
+
+ try
+ {
+ string A = ContextConfig.GetValue("MyAppKey", "dev");
+ Response.Write(string.Format("ContextConfig.GetValue(\"MyAppKey\", \"dev\") = {0}
", A));
+ }
+ catch (Exception Ex)
+ {
+ Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
+ }
+
+ try
+ {
+ string L = ContextConfig.GetValue("LiveOnlyAppKey", "live");
+ Response.Write(string.Format("ContextConfig.GetValue(\"LiveOnlyAppKey\", \"live\") = {0}
", L));
+ }
+ catch (Exception Ex)
+ {
+ Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
+ }
+
+ try
+ {
+ string M = ContextConfig.GetValue("LiveOnlyAppKey");
+ Response.Write(string.Format("ContextConfig.GetValue(\"LiveOnlyAppKey\") = {0}
", M));
+ }
+ catch (Exception Ex)
+ {
+ Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
+ }
+
+ try
+ {
+ string N = ContextConfig.GetValue("KeyThatDoesntExist");
+ Response.Write("Here we throw an error intentionally:");
+ Response.Write(string.Format("ContextConfig.GetValue(\"KeyThatDoesntExist\") = {0}
", N));
+ }
+ catch (Exception Ex)
+ {
+ Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
+ }
+
+ Response.Write("
");
+
+ try
+ {
+ SmtpSettingsElement smtpSettings = ContextConfig.GetSmtpSettings();
+
+ Response.Write("SMTP Settings with default");
+ Response.Write(string.Format("- From = {0}
", smtpSettings.From));
+ Response.Write(string.Format("- Delivery Method = {0}
", smtpSettings.DeliveryMethod));
+ Response.Write(string.Format("- Delivery Format = {0}
", smtpSettings.DeliveryFormat));
+ Response.Write(string.Format("- Use Default Credentials = {0}
", smtpSettings.Network.UseDefaultCredentials));
+ Response.Write(string.Format("- Enable SSL = {0}
", smtpSettings.Network.EnableSsl));
+ Response.Write(string.Format("- Host = {0}
", smtpSettings.Network.Host));
+ Response.Write(string.Format("- Port = {0}
", smtpSettings.Network.Port));
+ Response.Write(string.Format("- Client Domain = {0}
", smtpSettings.Network.ClientDomain));
+ Response.Write(string.Format("- User Name = {0}
", smtpSettings.Network.UserName));
+ Response.Write(string.Format("- Password = {0}
", smtpSettings.Network.Password));
+ Response.Write(string.Format("- Target Name = {0}
", smtpSettings.Network.TargetName));
+ Response.Write(string.Format("- Pickup Directory Location = {0}
", smtpSettings.SpecifiedPickupDirectory.PickupDirectoryLocation));
+ Response.Write("
");
+
+ smtpSettings = ContextConfig.GetSmtpSettings(false);
+
+ Response.Write("SMTP Settings without default");
+ Response.Write(string.Format("- From = {0}
", smtpSettings.From));
+ Response.Write(string.Format("- Delivery Method = {0}
", smtpSettings.DeliveryMethod));
+ Response.Write(string.Format("- Delivery Format = {0}
", smtpSettings.DeliveryFormat));
+ Response.Write(string.Format("- Use Default Credentials = {0}
", smtpSettings.Network.UseDefaultCredentials));
+ Response.Write(string.Format("- Enable SSL = {0}
", smtpSettings.Network.EnableSsl));
+ Response.Write(string.Format("- Host = {0}
", smtpSettings.Network.Host));
+ Response.Write(string.Format("- Port = {0}
", smtpSettings.Network.Port));
+ Response.Write(string.Format("- Client Domain = {0}
", smtpSettings.Network.ClientDomain));
+ Response.Write(string.Format("- User Name = {0}
", smtpSettings.Network.UserName));
+ Response.Write(string.Format("- Password = {0}
", smtpSettings.Network.Password));
+ Response.Write(string.Format("- Target Name = {0}
", smtpSettings.Network.TargetName));
+ Response.Write(string.Format("- Pickup Directory Location = {0}
", smtpSettings.SpecifiedPickupDirectory.PickupDirectoryLocation));
+ Response.Write("
");
+ }
+ catch (Exception Ex)
+ {
+ Response.Write(string.Format("ERROR: {0} : {1}
", Ex.GetType().ToString(), Ex.Message));
+ }
+ }
+
+ private void TestConfigOverride()
+ {
+ Response.Write(string.Format("'OverrideConfigurationManager' value in config = {0}
", ConfigSettings.Settings.OverrideConfigurationManager));
+
+ // test it
+ string Test = ConfigurationManager.AppSettings["OverrideTest"];
+ Response.Write(string.Format("OverrideTest = {0}
", Test));
+
+ // test missing value
+ string TestNull = ConfigurationManager.AppSettings["NoKey"];
+ Response.Write(string.Format("Missing Key = {0}
", TestNull));
+
+ }
+ }
}
\ No newline at end of file
diff --git a/Source/TestSite/Web.config b/Source/TestSite/Web.config
index 0b3265e..dcdcbdd 100644
--- a/Source/TestSite/Web.config
+++ b/Source/TestSite/Web.config
@@ -16,12 +16,18 @@
-
+
+
+
+
+
+
+