Chorn Sokun's Weblog

Conquer inner fear, push it to the limit!

Posts Tagged ‘C#

Joljet mobile client

leave a comment »

A few years ago, I built a music portal to experience ExtJS and of cause to create my own music listening experience. It was fun and I have learnt a lot from this exercise from hand craft the app, built script and caching optimization. As always with great power come great responsibility. Due to the size of ExtJS core, the page load is not satisfy by most. However, the site hosted on cheap server and not using any CDN therefore I can’t push it too far.

Moving on, I have done with ExtJS and I know the site works perfectly on desktop platform. However, on mobile it is kind of suck. But well, as a pet project I’m not too worry about that until I’m need to listen to my favorite song on the go then mobile client is needed. So, I decided to built one for myself AGAIN! :D. Yeah, again. Why not after all I’m a craftman I love builting stuffs.

Now here is the plan


I’m going to built mobile client which reuse all functionality from the portal and at the same time extending the functionalities to support offline, favorite & playlist customization or by the way I don’t want to be responsible for username & password so I am going to offload that task to Facebook.

Sound interesting right ;) to make it more interesting I shall say that I have no clue how to built a mobile app at this point. But, let see how long it will take for me to built one :D


Written by Chorn Sokun

May 12, 2014 at 8:07 am

LINQ 101 .NET Reflection

leave a comment »

In this post I am going over three points listed bellow:

What is .NET Reflection? Cut short it refer to a set of API built-in .NET Framework, which give you a greate power to load and manipulate type within assembly (.dll) one of the most favor use is to support late binding. There a whole lot of explaination available through google! but that all I care for now.

How about LINQ? stand for .NET Language-Integrated Query,

 a set of general purpose standard query operators that allow traversal, filter, and projection operations to be expressed in a direct yet declarative way in any .NET-based programming language. The standard query operators allow queries to be applied to any IEnumerable<T>-based information source.

What it mean to me?
Assume that I had ITrap interface and a bunch of Trap implementation as show in the code bellow:

interface ITrap{
  void Setup();
  int OrderNr { get; };

class LevelOneTrap: ITrap{
  public void Setup(){
    Console.WriteLine("LevelOne Setup First");
  public int OrderNr {
    get { return 1; }

class LevelTwoTrap: ITrap{
  public void Setup(){
    Console.WriteLine("LevelTwo Setup Next");
  public int OrderNr {
    get { return 2; }

Now I want to Setup all trap by respecting it OrderNr which mean LevelOneTrap.Setup() must execute before LevelTwoTrap.Setup() so far so good? Let see how many lines of code needed:

var trapInterface = typeof(ITrap);

var trapImplementations = ( from t in trapInterface.Assembly.GetTypes()
                      where t.IsClass && t.GetInterfaces().Any(x => x == trapInterface)
                      select (ITrap)Activator.CreateInstance(t)

// time to play ;)
foreach( var trap in trapImplementations ) {

//   LevelOne Setup First
//   LevelTwo Setup Next

Cool isn’t it? Life is short so our code!

Written by Chorn Sokun

May 7, 2011 at 12:39 pm

Posted in Programming, Tips & Tricks

Tagged with , ,