Created
July 12, 2013 07:13
-
-
Save avanderhoorn/5982516 to your computer and use it in GitHub Desktop.
Your code, Your Plugins - Simple Tab to expose custom configuration settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void LoadConfiguration() | |
{ | |
var connectionString = ConfigurationManager.ConnectionStrings["MusicStoreEntities"]; | |
var factory = DbProviderFactories.GetFactory(connectionString.ProviderName); | |
using (var connection = factory.CreateConnection()) | |
{ | |
connection.ConnectionString = connectionString.ConnectionString; | |
connection.Open(); | |
MvcMusicStore.Framework.Configuration.Current = connection.Query<ConfigurationModel>("SELECT * FROM Configuration").First(); | |
} | |
} | |
protected void Application_Start() | |
{ | |
//... | |
LoadConfiguration(); | |
//... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Configuration | |
{ | |
public static ConfigurationModel Current { get; set; } | |
} | |
public class ConfigurationModel | |
{ | |
public string Currency { get; set; } | |
public double TaxRate { get; set; } | |
public int DefaultCategory { get; set; } | |
public double MarkupRate { get; set; } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TabConfiguration : AspNetTab | |
{ | |
public override string Name | |
{ | |
get { return "Setup"; } | |
} | |
public override object GetData(Glimpse.Core.Extensibility.ITabContext context) | |
{ | |
return MvcMusicStore.Framework.Configuration.Current; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment