Design pattern for C# and JavaScript