>>306 別にいいけど、97%パクリソースだよ。(藁
元ネタは、Don Box先生の「UnwindScope Service」ね。
http://www.develop.com/dbox/dotnet/unwind/ // ForceGC.cs
using System;
using System.Runtime.Remoting;
namespace ForceGC
{
[ AttributeUsage(AttributeTargets.Class) ]
public class ForceGCAttribute : ContextAttribute
{
public ForceGCAttribute() : base("ForceGCAttribute") {
}
public override void GetPropertiesForNewContext(IConstructionCallMessage ctorMsg) {
ctorMsg.ContextProperties.Add(new ForceGCProperty());
}
public override bool IsContextOK(Context ctx, IConstructionCallMessage ctorMsg) {
return false;
}
}
class ForceGCProperty : IContextProperty, IContributeObjectSink
{
public ForceGCProperty() {
}
public string Name {
get { return "ForceGC"; }
}
public void Freeze(Context newCtx) {
}
public bool IsNewContextOK(Context newCtx) {
return true;
}
public IMessageSink GetObjectSink(MarshalByRefObject obj, IMessageSink nextSink) {
return new ForceGCObjectSink(nextSink, this);
}
}