purr
purr

Reputation: 53

Dependency Service Xamarin.Forms

i have a silly question regarding DependencyService. I am developing a mobile application in Xamarin Forms. I have just been reading about Dependency Service. If I am correct which i am most likely not and please correct if I am not, Dependency service is a class that is responsible for "translating" difference between droid and ios and its used for custom rendereds? So do i have to implement it in my solution?

My situation is that I am currently already connected to SQLite and I followed some tutorial which did not inform me about dependency service and this is how i initiate the SQL connection in my class.

 public UserService()
        {
            _conn = DependencyService.Get<ISQLiteInterface>().GetSQLiteConnection();
            _conn.CreateTable<User>();

        }

If I implement interface dependencyservice will that somehow affect my sql connection?

Upvotes: 0

Views: 346

Answers (1)

Nithin joy
Nithin joy

Reputation: 336

All dependency service will not have implementation on android and ios. Dependency service is a way to hold single memory location. In this scenario all the functions related to sql connection is implemented in forms .net standard library. So it hold a single memory location, you can call the function anywhere from your project without creating the object. But the key thing is that you should register the dependency service

Upvotes: 1

Related Questions