# Accessor Providers

{% hint style="danger" %}
This section is reserved for experienced developers
{% endhint %}

Accessor providers are reserved for more experienced users but offer greater flexibility when extending the system. They provide a way to supply custom values and paths for bindings.

By default the system will use highly optimized reflection and methods generation to provide binding paths and values. There is, however, another way to provide bindings: `IAccessorProvider`. All classes implementing this interface will be automatically registered by the system and offered to users as alternative binding methods.

Here is a sample implementation of `IAccessorProvider` interface:

```csharp
    public class MyProvider : IAccessorProvider
    {
        public string Id => "Texture Data Provider";

        public IAccessor GetAccessor(Type sourceType, string pathId)
        {
            return pathId switch
            {
                "Width" => new ObjectAccessor<Texture2D, int>(t => ((Texture2D)t).width, null),
                "Height" => new ObjectAccessor<Texture2D, int>(t => ((Texture2D)t).height, null),
                _ => throw new ArgumentException(nameof(pathId)),
            };
        }

        public IEnumerable<AccessorPath> GetAvailablePaths(object source)
        {
            if(source is not Texture2D)
            {
                return Enumerable.Empty<AccessorPath>();
            }
            return new AccessorPath[]
            {
                new AccessorPath(this, "Width", BindMode.Read, typeof(int)),
                new AccessorPath(this, "Height", BindMode.Read, typeof(int)),
            };
        }

        public bool TryConvertIdToPath(string id, string separator, out string path)
        {
            path = id;
            return true;
        }
    }
```

The system will automatically register this new provider and here is what the user will be able to do:



<figure><img src="https://2360058278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3rw9jjjjlPycieM3U3MU%2Fuploads%2FnARiOXIKTGmiiZ4M2qbw%2FProviders_Example.png?alt=media&#x26;token=bae555f6-414d-40d0-a680-85effdd65692" alt=""><figcaption><p>New provider is available in the menu</p></figcaption></figure>

<figure><img src="https://2360058278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3rw9jjjjlPycieM3U3MU%2Fuploads%2FlDPvVlmxBb5wowMPhdVq%2FProviders_Example_Fields.png?alt=media&#x26;token=83cc0042-531d-4433-91de-5b7f9a15b3a7" alt=""><figcaption><p>... with its defined paths</p></figcaption></figure>

<figure><img src="https://2360058278-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3rw9jjjjlPycieM3U3MU%2Fuploads%2FZugLoE2l32a81IJAUlSa%2FProviders_Example_Path.png?alt=media&#x26;token=67f637a0-04bf-43f1-ab01-5868caa2e47e" alt=""><figcaption><p>... and binding path set correctly</p></figcaption></figure>
