Skip to content

Instantly share code, notes, and snippets.

View xtrmstep's full-sized avatar
🏠
Working from home

Alexander Goida xtrmstep

🏠
Working from home
View GitHub Profile
@xtrmstep
xtrmstep / AppConfigChanger.cs
Created October 1, 2015 13:27
The hack for substitution of standard configuration file
/// <summary>
/// The hack for substitution of standard configuration file
/// question at StackOweflow: http://stackoverflow.com/questions/6150644/change-default-app-config-at-runtime
/// a solution: http://stackoverflow.com/a/6151688/2833774
/// </summary>
public abstract class AppConfigChanger : IDisposable
{
public static AppConfigChanger Change(string path)
{
return new AppConfigSubstitutor(path);
@xtrmstep
xtrmstep / WriteObjectToStringWriter.cs
Created September 28, 2015 08:47
Write an object using StringWriter to StringBuilder
using System;
using System.IO;
using System.Text;
namespace ConsoleApplication2
{
internal class Program
{
private static void Main(string[] args)
{
@xtrmstep
xtrmstep / ExtractEmbeddedResourcesToFiles
Last active August 29, 2015 14:27
Extract text files embedded as resources to an assembly to files on disk
public void ExtractEmbeddedResourcesToFiles()
{
Assembly a = typeof (SomeTypeFromAssemblyWithResources).Assembly;
string d = Path.GetDirectoryName(a.Location);
string outputDir = Path.Combine(d, subFolder);
if (Directory.Exists(outputDir) == false)
{
Directory.CreateDirectory(outputDir);
}
List<string> rs = a.GetManifestResourceNames().Where(n => n.Contains(prefix)).ToList();