Created
August 15, 2014 01:35
-
-
Save urasandesu/e1b2ba40c5a39cb1aaef to your computer and use it in GitHub Desktop.
Idea for intercepting an indirection.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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