Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9159695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:33:26+00:00 2026-06-17T13:33:26+00:00

It is possible to add proxy capabilities to an already generated and not empty

  • 0

It is possible to add proxy capabilities to an already generated and not empty object using Castle Dynamic Proxy?

I’ve tried this:

Dog _myDog=new Dog();
_myDog.Name="Fuffy";

var _proxyDog = generator.CreateClassProxyWithTarget<Dog>(_myDog, ProxyGenerationOptions.Default, new DogInterceptor());

_proxyDog results as a new object.

Now this is only an example, in real world application my object has 30+ properties and I want to know if I can avoid to copy those props one by one!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:33:27+00:00Added an answer on June 17, 2026 at 1:33 pm

    Yes it is. The only problem: ProxyGenerator needs to instantiate an object of that type anyway. This code is actually working correctly in my project:

    public static class MongoExtensions
    {
        static readonly ProxyGenerator pg = new ProxyGenerator();
        public static MongoCollection GetRetryCollection(this MongoDatabase db, string collectionName, int retryCount = 5, int pauseBetweenRetries = 2000)
        {
            var coll = db.GetCollection(collectionName);
            return (MongoCollection)pg.CreateClassProxyWithTarget(typeof(MongoCollection), coll, new object[] { db, collectionName, coll.Settings }, new RetryingInterceptor { RetryCount = retryCount, PauseBetweenCalls = pauseBetweenRetries });
        }
    }
    

    Paramerts of CreateClassProxyWithTarget are:

    • type of the proxied object,
    • proxied instance
    • array of constructor paramers for the proxied type.
    • interceptor for this proxy.

    I can’t really explain, why it need constructor parameters for the object, but this code work correctly for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to build a dynamic proxy object to add certain functionality to an
Is it possible to add or remove slides in runtime using FlexSlider ?
Is it possible to add a form to an email newsletter? I have tried
Possible Duplicate: add “readonly” to <input > (jQuery) This is so weird, I hope
Is it possible to add other else function in my JS like this: ?
My client is using proxy created from WSDL... Is it possible to setup the
Boiling this down to the simplest possible rule: <rule name=Reverse Proxy stopProcessing=true> <match url=^external/(.*)
I am building an application using NHibernate. Because I could not add the DLL's
I am facing a problem. Please explain if this is possible or not. 1)
is it possible to add a Proxy to my URL().openStream()? scanner = new Scanner(new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.