# Modify Recycle bin items

*Recycle* bin items are created using the relevant `IRecycleBinService` methods that occur every time a `MoveToRecycleBin` data event is raised from the item's manager.\
Start with implementing your custom recycle bin adapter:

```C#
using Telerik.Sitefinity.RecycleBin.Adapters;

namespace SitefinityWebApp
{
   public class MyCustomPageNodeAdapter : PageNodeAdapter
   {
       //Your custom adapter implementation
   }
}
```

Then, here are two ways to modify this default behavior.

## Register custom IRecycleBinItemAdapters

All *Recycle bin* Item factories that implement `DataItemRecycleBinFactory` use a list of `IRecycleBinItemAdapters` to populate the desired properties of a `RecycleBinDataItem`. Each adapter casts the specified `IDataItem` to the required type and transfers some of its properties to the resulting `RecycleBinDataItem`.\
To change the existing implementation of a specific adapter, you must first find the adapter that is responsible for the specific data item type and then register an inheriting adapter type:

```C#
using System;
using Telerik.Microsoft.Practices.Unity;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.RecycleBin.Adapters;
using Telerik.Sitefinity.Services;

namespace SitefinityWebApp
{
   public class Global : System.Web.HttpApplication
   {
       protected void Application_Start(object sender, EventArgs e)
       {
           SystemManager.ApplicationStart += new EventHandler<EventArgs>(ApplicationStartHandler);
       }

       private void ApplicationStartHandler(object sender, EventArgs e)
       {
           ObjectFactory.Container.RegisterType<PageNodeAdapter, MyCustomPageNodeAdapter>();
       }
   }
}
```

## Implement custom Recycle bin factory

Another way to add or alter information in a *Recycle bin* item about a deleted data item is to implement and register a custom `IRecycleBinItemFactory` for populating the properties of every *Recycle bin* item created using the `IRecycleBinService`.

You implement the factory and then register the type. After this registration, every time a *Recycle bin* item is created from the `IRecycleBinService`, the specified `MyCustomPageNodeRecycleBinFactory` is used.

To implement the `MyCustomPageNodeRecycleBinFactory` class, you inherit the existing `PageNodeRecycleBinFactory` overriding its `GetRecycleBinItemAdapters()` method to add your own adapter(s):

```C#
using System.Collections.Generic;
using Telerik.Sitefinity.Model;
using Telerik.Sitefinity.Pages.Model;
using Telerik.Sitefinity.RecycleBin;
using Telerik.Sitefinity.RecycleBin.Adapters;
using Telerik.Sitefinity.RecycleBin.ItemFactories;

namespace SitefinityWebApp
{
   public class MyCustomPageNodeRecycleBinFactory : PageNodeRecycleBinFactory
   {
       protected override IList<IRecycleBinItemAdapter> GetRecycleBinItemAdapters(IDataItem item)
       {
           var baseAdapters = base.GetRecycleBinItemAdapters(item);
           if (item is PageNode)
           {
               baseAdapters.Add(new MyCustomPageNodeAdapter());
           }

           return baseAdapters;
       }
   }
}
```

### Register the factory

To register a custom *Recycle bin* item factory, you must create a named registration in the ObjectFactory using the name of the manager that is responsible for the data items used to populate the *Recycle bin* item:

```C#
using System;
using Telerik.Microsoft.Practices.Unity;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.RecycleBin.Adapters;

namespace SitefinityWebApp
{
   public class Global : System.Web.HttpApplication
   {
       protected void Application_Start(object sender, EventArgs e)
       {
           Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped; ;
       }

       private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
       {
           ObjectFactory.Container.RegisterType<PageNodeAdapter, MyCustomPageNodeAdapter>();
       }
   }
}
```
