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”

Create a config file in asp .net core

With asp .net core we have another concept of website.

There is not a scripting language with an interpreter, but we have a software that is listening on a port.

This mean that, the code in Program.cs and Startup.cs files will be executed just the fist time, at program launch. In fact, the Startup.cs file contains the Startup class, that built the middleware pipeline and it will be executed at any request.

So, a big problem that we can have with a config file is this: to any request, we need to read it from the disk, and this can be very expansive with an huge number of users.

A first way to fix this is to use AddJsonFile in the Program class when you build the configuration, and to use like explained here.
However, I use another way to do this, because I prefer access data via dot notation.

Lets see the alternative way to use a config file.

Continue reading “Create a config file in asp .net core”