Skip to content

Instantly share code, notes, and snippets.

@jmangelo
jmangelo / gist:3173109
Created Jul 24, 2012 — forked from davidfowl/gist:3172990
MethodInfo.Invoke is slow... open instance delegate to the rescue
View gist:3173109
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 Jun 9, 2012
Extended Logging Sample with .NET 4.5 Caller Info Attributes and NLog
View CallerInfo.cs
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 Feb 25, 2011
VS 2010 SP1 BETA - MSBuild Project file for App.config XML transformations.
View AppConfig.Transformation.targets
<?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 Jun 21, 2010
VS 2010 RTM - MSBuild Project file for App.config XML transformations.
View AppConfig.Transformation.targets
<?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
Helper Classes for creation of Weak Event Handlers
View Helpers.Events.UnitTests.cs
using System;
using NUnit.Framework;
namespace Helpers.Events.UnitTests
{
using Wrapper = WeakEventHandlerWrapper;
[TestFixture]
public class WeakEventHandlerWrapperTest
{
@jmangelo
jmangelo / VstoAopExceptionHandling.cs
Created Feb 17, 2010
Helpers classes for centralized exception handling in a VSTO add-in using PostSharp.
View VstoAopExceptionHandling.cs
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 Feb 11, 2010
Helper class to provide a Excel Workbook Closed event.
View WorkbookClosedMonitor.cs
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 Oct 9, 2009
Visual Studio 2008 Code Snippet for creating a NUnit test method.
View UnitTest.snippet
<?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>