Skip to content

Instantly share code, notes, and snippets.

@maxfridbe
maxfridbe / file.cs
Created November 1, 2012 22:56
Modify Running App Config
var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings.Remove("CurrentUICulture");
config.AppSettings.Settings.Add("CurrentUICulture", name);
config.Save(ConfigurationSaveMode.Modified, true);
// Force a reload of a changed section.
ConfigurationManager.RefreshSection("appSettings");
@maxfridbe
maxfridbe / file.cs
Created November 1, 2012 22:55
Reading File From Resource Stream
using (var stream = Assembly.GetExecutingAssembly() .GetManifestResourceStream("SalesForce.Tests.Required_AccountNames.txt"))
{
using (var reader = new StreamReader(stream))
{
embededFile = reader.ReadToEnd();
}
}
@maxfridbe
maxfridbe / file.cs
Created November 1, 2012 22:54
Autofac Bootstrap and logging
public class LogInjectionModule : Module
{
protected override void Load(ContainerBuilder builder)
{
//log4net added by extension
log4net.Config.XmlConfigurator.Configure();
builder.Register<ILogger>((c, p) => new Log4NetLog(p.TypedAs<Type>()));
}
protected override void AttachToComponentRegistration(IComponentRegistry registry, IComponentRegistration registration)
{