Skip to content

Instantly share code, notes, and snippets.

View mgroves's full-sized avatar

Matthew D. Groves mgroves

View GitHub Profile
@mgroves
mgroves / console
Created March 28, 2012 21:37
Intor to FireWeaver
C:\zproj\CCC\FireWeaverExample\FireWeaverExample\bin\Debug>FireWeaver.Bootstrapper.exe FireWeaverExample.exe FireWeaverExample.exe
@mgroves
mgroves / PEVerify output
Created March 29, 2012 13:59
fireweaver IL
C:\zproj\CCC\FireWeaverExample\FireWeaverExample\bin\Debug>PEVerify.exe "FireWeaverExample - After.exe"
Microsoft (R) .NET Framework PE Verifier. Version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.
[IL]: Error: [C:\zproj\CCC\FireWeaverExample\FireWeaverExample\bin\Debug\FireWeaverExample - After.exe : FireWeaverExample.Program::Main][offset 0x00000006][found ref 'FireWeaverExample.Cat'][expected ref 'FireWeaverExample.Dog'] Unexpected type on the stack.
[IL]: Error: [C:\zproj\CCC\FireWeaverExample\FireWeaverExample\bin\Debug\FireWeaverExample - After.exe : FireWeaverExample.Program::Main][offset 0x00000017][found ref 'FireWeaverExample.Dog'][expected ref 'FireWeaverExample.Cat'] Unexpected type on the stack.
failed to load resource string
FireWeaverExample - After.exe
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace WeavingExample
{
public class MyService
{
[DebuggerNonUserCode, CompilerGenerated]
internal sealed class <>z__Aspects
{
@mgroves
mgroves / gist:2287299
Created April 2, 2012 21:18
jquery AOP example
<html>
<head>
<title>AOP with jQuery 1</title>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="aop.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.aop.before( {target: window, method: 'DisplayUserAgent'},
function(args) {
alert("About to execute DisplayUserAgent on element with id '" + args[0] + "'");
public interface IMyService
{
string GetSomeLongRunningResult(string input);
}
using System.Web.Mvc;
using AopBlog.Models.Repositories;
using AopBlog.Models.Services;
namespace AopBlog.Areas.Manage.Controllers
{
public class AccountController : Controller
{
readonly IAuthorizationService _authService;
readonly IAuthorRepository _authorRepo;
public class MyAttribute : Attribute
{
public MyAttribute(string something) { }
public MyAttribute(string[] something) { }
}
public class AttributeUsage
{
[MyAttribute("this works")]
public void Method1() {}
public class ParsedSqlSelectQuery
{
public IList<string> SelectElements { get; private set; }
public string WhereClause { get; private set; }
public string FromClause { get; private set; }
public ParsedSqlSelectQuery(string sqlQuery)
{
var parser = new TSql100Parser(false);
IList<ParseError> errors;
@mgroves
mgroves / gist:2925880
Created June 13, 2012 19:14
postsharp with MVC
using System;
using System.Web.Mvc;
using PostSharp.Aspects;
namespace MvcApplication1WithPostSharp.Controllers
{
public class HomeController : Controller
{
[MyExitAspect]
public ActionResult Index()
@mgroves
mgroves / gist:3265408
Created August 5, 2012 15:31
Using C#'s dynamic to create a DynamicProxy
// from: http://weblogs.asp.net/lichen/archive/2012/08/03/gave-a-presentation-on-c-dynamic-and-dynamic-language-runtime-dlr-at-socal-net-user-group-meeting.aspx
// pros: no requirement for members to be virtual, no need for a 3rd party framework
// cons: loss of static typing benefits (i.e. intellisense & compile time checking), not practical for IoC
class Program
{
static void Main(string[] args)
{
dynamic myObj = new DynamicProxy(new MyClass());