Interface out T vs T

The out keyword in generics is used to denote that the type T in the interface is covariant.

check following code.

        class Fruit { }
        class Banana : Fruit { }
        interface ICovariantSkinned<out T> { }
        interface ISkinned<T> { }
        class A<T> : ISkinned<T> { }
        class B<T> : ICovariantSkinned<T> { }
        public static void Main()
            ISkinned<Banana> a1 = new A<Banana>();
            ISkinned<Fruit> a = a1;    // compiling error happens here
            ICovariantSkinned<Banana> b1 = new B<Banana>();
            ICovariantSkinned<Fruit> b = b1; // compiling passed
Posted in Uncategorized | Comments Off on Interface out T vs T

How to set Visual Studio support C# 7 features.

  • open visual studio and click on project and choose ‘Properties’
  • in ‘Build’ tab, choose ‘Advanced…’, check screen dump
  • in language version, in dropdown list showing in screen dump, there is not ‘C#7’ and ‘C# 7.2’ for visual studio 2015
  • in visual studio 2017, same dropdown list has ‘C# 7.x’ options

Although some ways could update visual studio 2015 to support C# 7, I higly recommand to use visual studio 2017.

wp_check C# version number


Posted in Uncategorized | Comments Off on How to set Visual Studio support C# 7 features.

Typescript – tsc didn’t copy .html .css .txt to destination folder

tsc would translate .ts file to js and keep folder struction.
however, for some special file for tsc, such as .txt, .html, .css, tsc command chooses to ignore them.

we have to copy manually

for cross-platform, we are using node.js copyfiles package to do it.

but ‘copyfiles ./src/**/*.txt ./dist’ won’t work, the final result of that command is all text file would go under ‘./dist/src/path/to/file.txt’

but luckily copyfiles has options to handle and it is key reason why we uses it beside cross-platform.

in package.json add

  "scripts": {
    "copy-template": "copyfiles -u 1 ./src/**/*.txt ./dist"

another way to is to use gulpfiles.js and gulp command line.

gulp.task('copy-template', function() {
     return gulp.src('./src/**/*.txt', {base: './src'})

later on, add package.json to invoke this gulpfiles.js

Posted in Typescript | Comments Off on Typescript – tsc didn’t copy .html .css .txt to destination folder

Orchard 2 – Microsoft open source CMS using core

Here we assume that %Orchard% is Orchard Source code workspace folder

Orchard 2 uses autofac as DI library as well as NHibernate.

%Orchard%\src\Orchard.Web\Global.asax.cs is entry of whole website.



after filling at required field, ‘finish setup’ is clicked.
it would invoke following code

[HttpPost, ActionName("Index")]
public ActionResult IndexPOST(SetupViewModel model)

Orchard Init Stage Steps.
– Orchard use lots of Plugin and Module. It has complex loading and caching mechanism.
– I would write a new post for init stage source code of Orchard.

Posted in Orchard | Comments Off on Orchard 2 – Microsoft open source CMS using core Core publish on Ubuntu

1. Download core sdk 2 from Microsoft website
2. link ‘dotnet’ command line to ‘/usr/bin/dotnet’
3. publish project and zip all binary files including dlls, scp zip to ubuntu vps
4. export ASPNETCORE_URLS=”http://*:80″
This step is very important, because by default ‘dotnet’ command only create port for ‘localhost:5000’.
without this command, public network interface ‘eth0’ may not get listen any port.

5. run ‘dotnet Target-Project.dll’

Posted in Uncategorized | Comments Off on Core publish on Ubuntu

.net core – create project and adding reference by command line only

dotnet new sln # new solution file
mkdir webapi
cd webapi
dotnet new webapi # new project named webapi
dotnet add package Autofac # try to add Autofac
dotnet add package Autofac.Extensions.DependencyInjection
dotnet add package MongoDB.Driver

cd ..
mkdir webapi_test ###important: dont’ name folder to be ‘xunit’, command has bugs for it
dotnet new xunit
dotnet add reference ../webapi/webapi.csproj
dotnet add package Microsoft.AspNetCore.Mvc
dotnet restore # download all references

Posted in .net core | Comments Off on .net core – create project and adding reference by command line only

Code-First EntityFramework – step by step

This is first post for code-first entity framework and how to use it.

1. add entity framework, open project, in VS Package Management
PM> Install-Package EntityFramework

2. Don’t enable migrations, if you enable migrations then, add
Enable migrations only after database is created.

3. create class inherits from DbContext

    public class SchoolContext : DbContext {
        public DbSet<Course> Courses { get; set; }
        public DbSet<Department> Departments { get; set; }

add connection string in web.config with same name ‘SchoolContext’

4. enable migrations
check screen dump, it will create ‘Migrations’ folder and configuration.cs

5. Add-Migration
PM> Add-Migration

VS will ask you to input name and generate cs with today’s Date, check screen dump above.

Posted in entityframework | Comments Off on Code-First EntityFramework – step by step

IIS subdomain configuration

1. open ‘IIS manager’
2. right click on ‘site’ to create a new site
3.leave ip as ‘unsigned’, put all ‘host name’ to subdomain name
for example ‘’
4. go to godaddy to add ‘core’ as subdomain

Posted in IIS | Comments Off on IIS subdomain configuration

WPF – simple wpf calculator

Here is example of WPF calculator, will add more function such as scientific calculator


Visual Studio 2017 enhanced the symbols token searching function which originally VS2010 has and disappear in VS2013 and VS2015.

Posted in WPF | Comments Off on WPF – simple wpf calculator

Azure – creating app service talking with sql server

‘app service’ and ‘sql server’ are excellent combination for creating a small website.

creating sql server on azure following step by step guide.
Even on local visual studio, it talk with sql server on azure as well.

1. open microsoft azure portal
2. select app service.
3. create app service following step by step guiding
4. one local visual studio project, click on ‘publish’
5. select microsoft azure click on publish

some excellent feature such as Api Management will be a new post to make API GATE Way talking to AZure virtual machine.

Posted in azure | Comments Off on Azure – creating app service talking with sql server