Hi, I'm try to supplement the logic of external type, that I do not 
instantiate.
I create a proxy like this:
var pg = new ProxyGenerator();
var coll = db.GetCollection(collectionName);
return 
(MongoCollection)pg.CreateClassProxyWithTarget(typeof(MongoCollection), 
coll, new object[] { db, collectionName, coll.Settings }, new 
RetryingInterceptor { RetryCount = retryCount, PauseBetweenCalls = 
pauseBetweenRetries });

But it will return a new instance instead of supplied. Actually, you can 
test this with any simple type:
var pg = new ProxyGenerator();
            var d = new List<int> { 1, 2, 3 };
            var d2 = pg.CreateInterfaceProxyWithTarget((IList<int>)d, new 
TestInterceptor());
            var d3 = pg.CreateClassProxyWithTarget(d, new 
TestInterceptor());

            Console.WriteLine(d.Count); // write 3
            Console.WriteLine(d2.Count); // write 3
            Console.WriteLine(d3.Count); // This will write 0, because new 
instance have been created, instead of supplied one.
While with the list, I can use approach with interface, in my real code, 
external class does not have any interfaces, so I can't proxy it by 
interface.

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
Visit this group at http://groups.google.com/group/castle-project-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to