Question:
How to perform Perform Dependent SDK initialization?

Solution:


Packages written in.NET are usable for software development. Every SDK has an AddSdk extension method that registers the services of that SDK and any dependencies.


SDK2 would provide the following:


public static class Sdk2ServiceCollectionExtensions

{

    public static void AddSdk2(this IServiceCollection services)

    {

        services.AddTransient<SDK1Interface3, SDK1Class3>();

        services.AddTransient<SDK1Interface4, SDK1Class4>();

    }

}


SDK1, which depends on SDK2, would provide the following:


public static class Sdk1ServiceCollectionExtensions

{

    public static void AddSdk1(this IServiceCollection services)

    {

        services.AddSdk2();

        services.AddTransient<SDK1Interface1, SDK1Class1>();

        services.AddTransient<SDK1Interface2, SDK1Class2>();

    }

}


Furthermore, ProductService would simply call AddSdk1 at startup if SDK2 is an internal implementation detail of SDK1 and not used directly by ProductService.


public class Program

{

    public void ConfigureServices(IServiceCollection services)

    {

        services.AddSdk1();

    }

}


Suggested blogs:

>How to create a line animation in Python?

>How to create a new/simple PHP script/function with cURL to upload simple file (video.mp4)?

>How to route between different components in React.js?

>How to save python yaml and load a nested class?-Python

>How to send multiple HTML form fields to PHP arrays via Ajax?

>What is data binding in Angular?

>How to create a One Page App with Angular.js, Node.js and MongoDB?




Nisha Patel

Nisha Patel

Submit
0 Answers