1

Does someone know library, that reduces amounts of boilerplate code when writing object proxies?

My proxies right now look the following way and I think it's a nasty approach :)

public class SampleTenantProxy : Tenant
{
    public override int? Id
    {
        get { return tenant.Id; }
        set { tenant.Id = value; }
    }
    public override String Code
    {
        get { return tenant.Code; }
        set { tenant.Code = value; }
    }

    public override String Name
    {
        get { return tenant.Name; }
        set { tenant.Name = value; }
    }

    public override Decimal Price
    {
        get { return tenant.Price; }
        set { tenant.Price = value; }
    }

    private readonly Tenant tenant;

    public TenantListBoxProxy(Tenant tenant)
    {
        this.tenant = tenant;
    }

}

Yippie-Ki-Yay
  • 22,026
  • 26
  • 90
  • 148

2 Answers2

2

Most Dependency Injection tools (such as Windsor Castle - have a look here) can do it.

Aliostad
  • 80,612
  • 21
  • 160
  • 208
0

Castle Dynamic Proxy -> http://www.castleproject.org/dynamicproxy/index.html

MattDavey
  • 8,897
  • 3
  • 31
  • 54