Hello everyone!
After quite some time I finally got time to write.
So I am going to tell you guys how to use FireSharp.
FireSharp is a wrapper written for Firebase to use with .Net. Because Firebase doesn’t provide any support for .Net that’s why FireSharp is used to get the job done.
Lets get started!

Open Visual Studio and then New Project and create a Windows 8.1 Blank App.

Click on Tools -> NuGet Package Manager -> Manage NuGet Package for Solution

NuGet Package Manager for Solution will open up, then in the search type ‘FireSharp’ press enter, and install the wrapper.

After that open your MainPage.xaml file.
Now add a ListView, a Button, a Textbox, and an Appbar with two buttons(an Edit and a Remove).
I have named the components as “listView”, “send”, and “textBox”. You can do any way you like it.
Your MainPage.xaml might look something like this:
xaml

Here’s the MainPage.xaml code:

 

Now its time to open the MainPage.xaml.cs file.
First of all where we need to create a reference to our Firebase by providing our BasePath and AuthSecret to IFirebaseConfig class’s object.

 

Now we are going to write an event for Send button. (Send button turns into an Update button when )

As we proceed we’re going to use this Send button work as an Update button as well.
Since we’re finished pushing data to Firebase, we need to do some manipulation on our data i.e Updating and Removing. For that we need the unique ids on which our data is saved. To achieve that purpose we will create a dictionary that will contain all the unique ids and values, and a function that will continuously listen to Firebase and will automatically invoke if there is any change of value on Firebase.

 

You need to place your ListenToStream function in your MainPage’s class constructor, so that it fetches all the values as soon as the application loads.

We have the Unique Ids for each of our value in our keyHolder dictionary, Now we can manipulate our data easily.

For deleting, FireSharp uses a DeleteAsync function.

 

In the event of your Appbar’s Remove button write the following snippet:

 

Its time for some Updating. First of all update your Send button event to this:

 

For Updating, FireSharp uses an UpdateAsync function. In which we need to pass the Unique Id and the value that we want to update.

 

In your Appbar’s Edit button you’ll need to do:

At last you need to update your AddToListView function, with the functionality of updating the listView instead of just appending it.

 

For now we are done, and good to go.
Now run and test it.
And here is the link to this project on Github.
Ciao!

Share:

administrator

4 Comments

  • kiquenet, May 26, 2016 @ 8:10 pm Reply

    Hi mister, thanks !

    How can I install Firebase in Windows 8.1 ? Any Getting Started step by step that you recommended ?

    Thanks a lot.

    This blog is the newest ?

    • Aaqib Hussain, May 28, 2016 @ 12:13 pm Reply

      There is no official support to Firebase for Microsoft the only way was to connect to Firebase is by using FireSharp, and now Google has taken over it there is highly unlikely that there would be any support in the future and probably they will kill the Legacy support too so no more FireSharp. 🙂
      As far as Windows 8.1 is concerned the above mentioned tutorial is the only way to use Firebase.
      And Yes it is.

  • Hamza Niazi, January 1, 2018 @ 12:42 pm Reply

    Can we use this library with WPF applications?

    • Aaqib Hussain, January 1, 2018 @ 2:46 pm Reply

      I think yes, but you’ll have to try it to now. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *