Skip to content

Instantly share code, notes, and snippets.

@urasandesu
Created August 15, 2014 01:35
Show Gist options
  • Save urasandesu/e1b2ba40c5a39cb1aaef to your computer and use it in GitHub Desktop.
Save urasandesu/e1b2ba40c5a39cb1aaef to your computer and use it in GitHub Desktop.
Idea for intercepting an indirection.
using System.ComponentModel;
using Urasandesu.Prig.Framework;
namespace System.Collections.Generic.Prig
{
public class PList<T> : PListBase
{
public static zzAdd Add()
{
return new zzAdd();
}
[EditorBrowsable(EditorBrowsableState.Never)]
public class zzAdd
{
public IndirectionAction<List<T>, T> Body
{
set
{
var info = new IndirectionInfo();
info.AssemblyName = "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
info.Token = TokenOfAdd_T;
var indirections = LooseCrossDomainAccessor.GetOrRegister<IndirectionHolder<IndirectionAction<List<T>, T>>>();
var _value = value;
_value = (List<T> arg1, T arg2) =>
{
var interceptions = default(InterceptionHolder<IndirectionAction<List<T>, T>>);
if (LooseCrossDomainAccessor.TryGet(out interceptions))
{
var intercepted = default(IndirectionAction<List<T>, T>);
if (interceptions.TryGet(info, out intercepted))
{
intercepted(arg1, arg2);
return;
}
}
value(arg1, arg2);
};
indirections.AddOrUpdate(info, _value);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment