Skip to content

Instantly share code, notes, and snippets.

@jmangelo
jmangelo / gist:3173109
Created July 24, 2012 22:30 — forked from davidfowl/gist:3172990
MethodInfo.Invoke is slow... open instance delegate to the rescue
using System;
using System.Diagnostics;
using System.Linq.Expressions;
using System.Reflection;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
@jmangelo
jmangelo / CallerInfo.cs
Created June 9, 2012 14:51
Extended Logging Sample with .NET 4.5 Caller Info Attributes and NLog
using System;
using System.IO;
using System.Runtime.CompilerServices;
using NLog;
public sealed class CallerInfo
{
private CallerInfo(string filePath, string memberName, int lineNumber)
{
this.FilePath = filePath;
@jmangelo
jmangelo / AppConfig.Transformation.targets
Created February 25, 2011 22:40
VS 2010 SP1 BETA - MSBuild Project file for App.config XML transformations.
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- 20110225 : João Angelo : Compatibility fix for Visual Studio SP1 Beta -->
<!-- 20110224 : Ryan Milligan : Created OverrideAppConfigWithTargetPath target to fix ClickOnce deploy bug -->
<!-- 20100827 : João Angelo : Fixed bug when using Publish command within Visual Studio -->
<PropertyGroup>
<!-- Prevent circular dependency on Build target -->
<PipelineDependsOnBuild>false</PipelineDependsOnBuild>
<!-- Override project config file name (By default is set to Web.config) -->
<ProjectConfigFileName>App.Config</ProjectConfigFileName>
@jmangelo
jmangelo / AppConfig.Transformation.targets
Created June 21, 2010 21:37
VS 2010 RTM - MSBuild Project file for App.config XML transformations.
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- 20110224 : Ryan Milligan : Created OverrideAppConfigWithTargetPath target to fix ClickOnce deploy bug -->
<!-- 20100827 : João Angelo : Fixed bug when using Publish command within Visual Studio -->
<PropertyGroup>
<!-- Prevent circular dependency on Build target -->
<PipelineDependsOnBuild>false</PipelineDependsOnBuild>
<!-- Override project config file name (By default is set to Web.config) -->
<ProjectConfigFileName>App.Config</ProjectConfigFileName>
</PropertyGroup>
@jmangelo
jmangelo / Helpers.Events.UnitTests.cs
Created May 17, 2010 22:21
Helper Classes for creation of Weak Event Handlers
using System;
using NUnit.Framework;
namespace Helpers.Events.UnitTests
{
using Wrapper = WeakEventHandlerWrapper;
[TestFixture]
public class WeakEventHandlerWrapperTest
{
@jmangelo
jmangelo / VstoAopExceptionHandling.cs
Created February 17, 2010 21:25
Helpers classes for centralized exception handling in a VSTO add-in using PostSharp.
using System;
using log4net;
using PostSharp.Laos;
// http://exceptionalcode.wordpress.com/2010/02/17/centralizing-vsto-add-in-exception-management-with-postsharp/
namespace Helpers.Vsto.ErrorHandling
{
[Serializable]
public sealed class ExecutionEntryPointAttribute : OnExceptionAspect
@jmangelo
jmangelo / WorkbookClosedMonitor.cs
Created February 11, 2010 20:00
Helper class to provide a Excel Workbook Closed event.
using System;
using Excel = Microsoft.Office.Interop.Excel;
namespace Helpers.Vsto
{
public sealed class WorkbookClosedMonitor
{
internal class CloseRequestInfo
{
public CloseRequestInfo(string name, int count)
@jmangelo
jmangelo / UnitTest.snippet
Created October 9, 2009 21:29
Visual Studio 2008 Code Snippet for creating a NUnit test method.
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2008/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Unit Test</Title>
<Author>João Angelo</Author>
<Description>Inserts a NUnit test method.</Description>
<Shortcut>ut</Shortcut>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>