NotifyPropertyChange on Nativescript

If you like me are developing apps with nativescript core with typescript, probably know the PropertyChange event behind the MVVM (Yes, I love NativeScript core with TS because reminds me to my love for WPF/UWP development on Windows).

How on Windows, your class must implement the INotifyPropertyChange interface, in Nativescript specific case you just need to extends the Observable class.

Here how you can notify that a property is changed (we are assuming that we have a ViewModel with the property “Clicked” ad “ClickedTitle” in it.

public Clicked: number = 0;
public ClickedTitle: string = "";
// note that this is an attribute, not a property
public UpdateUI()
{
   this.Clicked = this.Clicked++;
   this.ClickedTitle = "You have clicked " + this.Clicked + " times";
   this.notifyPropertyChange("Clicked", this.Clicked);
   this.notifyPropertyChange("ClickedTitle", this.ClickedTitle);
}
Continue reading “NotifyPropertyChange on Nativescript”

Typescript object VS javascript object

The use of Typescript is amazing for web/app development, however we must remember that Typescript is a javascript’s superset and it will be transpiled in pure js with all limitation of the case.

Let’s see a courios case I’ve faced today.

export class User
{
   // class attributes
   public name: string = "";
   public surname: string = "";
   // class properties
   public get FullName(): string
   {
     return this.name + " " + this.surname;
   }
   public SayHello()
   {
     console.log("Hello " + this.FullName);
   }
}

How you can see on the code block above, we have a class named User with two attributes, Name and Surname, and a readonly property, FullName.

function ConvertObject<T>(arg: any): T
{
    const result: T = {} as T;
    return Object.assign(result, arg) as T;
}
Continue reading “Typescript object VS javascript object”

Vue js with aspnet core

What is this?

Honestly, I’m a software engineer, a backend man… however, someone that can’t do frontends, grahpics, etc.

I’ve always been fashinating by the UI world but my skills and my patience in the new javascript-wtf-hell-packages-environment aren’t the best.

I love .net core, working with asp net core for websites and web api, but for UI until now I always used the classic approach: Razor pages + jquery.

One day I’ve met Vue.js. How you can imagine for a MVVM lover like me, with Vue has been love at first seen.

So I’ve tried to integrate it with aspnet core via Microsoft SPA Templates but Vue was no present in it. My first approach was to check the code on github JavscriptServices and create a VueDeveloperServer like for react, but after I’ve choose to use another approach to this scenario.

Continue reading “Vue js with aspnet core”

Localize your Xamarin Forms App with shared project.

When I’ve started with Xamarin.Forms, my first problem was about app’s localization. All tutorials and also Xamarin documentation that I found regard only about PCL’s projects (that now are deprecated in favor of .net standard).

However, my scenario was better with shared project so I started the project in this way, saying to myself: “It’s time to face off the problem”.

I’ve thinked about a solution about app’s localization and I’ve developed the DewXamarinLocalization library, a .net standard library for xamarin forms.

So, let’s see how we can localize a Xamarin.Form shared project.

Continue reading “Localize your Xamarin Forms App with shared project.”

How to connect to a MySQL server with .net core

We already know that asp .net core works great with Microsoft technologies, but many times we need to work with other stuff.

Just think about the EF with SQL Server, the Identity or whatever things like these.
In my scenario,  I needed to interface the website with a MySQL database. In this case I’ve been lucky, because I’ve found the a first implementation of a connector for MySQL (info here).

However my needs, I’ve wrote a new .net standard library based on MySQLConnector that use also ORM features in a very clearly way.

You can find it here with all docs for how to use.

Pills of C#: strings

In many times people have asked me some question about strings in C#. The much quoted question is about: “What is the @ before the string?”

So, now I want try to give some pills about those strings in C#.

Just to be clear, I’m assuming that you already know a base of C# and strings operations (concats, escaping, etc.)

Continue reading “Pills of C#: strings”