Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Wrapper libraries >

.NET Core Dependency Injection container and the AccountingAPI

Started by David Craig -   in Wrapper libraries

Hi there,

I'm using the Xero-NetStandard API wrapper and was wondering if someone can please provide guidance on whether we can use .NET Core DI container to register the different types of APIs e.g. is it safe to register the `AccountingApi` or the `AssetApi` as a Scoped instance?

For example, I have lots of services which all will need an instance of the `AccountingApi` but I'd prefer to inject the instance through the constructor in each of these services rather than new one up each time.

I've had a look through the Xero documentation and in the samples provided but it seems like everywhere the `AccountingApi` is referenced it just gets new'd up every time. Is this really how we should be using this?

Thanks in advance