Skip to main content

Posts

Showing posts with the label CodeProject

TypeScript introduction

In newer web application development we are more and more diving into client side scripts. Slowly AJAX calls are completely or at least mostly replacing regular post backs for rich user experience. Somewhere we are dealing HTMLs returns or just interacting with model but with time we are ending up writing lot of JavaScript on pages or dedicated JavaScript files. After starting project, in short of span of time we are ending up with lot of scripts. Writing those script itself is problematic process as we do not get any type safety and on execution only we can know we have missed typed or added some variable in place of some other type. Mostly through comments only we are understanding the code association with pages unless we put JavaScript in respective pages or with naming JS according to respective page names. I know we can use some OOPS concept or JS framework like Backbone, Knockout etc. to manage things through MVC or MVVM approach. Those are really good way to handle JavaScr...

Strongly typed configuration through database

We usually save most of application setting under app.config or web.config with key and value pair under appSetting element. The big problem with those are whenever you need value, typecasting need to be done and also need to be called through key. The other problem I find is with hierarchy of settings like download related setting present should under download element for easy accessing. To solve strongly typed configuration and hierarchy, ConfigurationManager ( http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager(v=vs.110).aspx ) class comes for rescue. You might have seen under web.config where we have sectionGroup and related configuration under elements. To implement it, lot of codes need to written to achieve simplification. To reduce numbers of codes for implementing XML configuration a very good and free tool is available called "Configuration Section Designer" available on http://csd.codeplex.com/ . There we do not have to wri...

Interface based model binding to populate properties value automatically

Interface is great way to make consistency and re-useability of codes. In this tutorial, I am going to show the power of interface to populate view/domain models automatically and interchange values between models. Technologies or techniques used in this approach: - MVC. - Interface for models. - MVC model binder for associated model with interface. Through this model binder we will populate values. - T4 template to generate code to register model binder with all models associated with interface. - Generic extension method to interchange values. It might sounding bit complex to achieve small thing. Just hold on with me and see unfolding. This will result in easier maintenance and less repetitive code. First let's start with creation of Interface that need to be populate automatically. This interface would be implemented on models and values will be auto-populated on binder. /// <summary> /// Interface for storing entry related values /// </summar...

C# Response files

Response files are similar to batch files, having some specific instruction. On execution they perform some predefined task based on instruction. Response file contains instruction to compile programs. If we have to build complex program through command line then response files are really helpful in development process. rsp is an extension for response files. By default, csc.rsp file exists under "Framework" folder Ex: C:\Windows\Microsoft.NET\Framework\v4.0.30319. csc.rsp contains long list of system references (dlls). Some contents under csc.rsp # Reference the common Framework libraries /r:Accessibility.dll /r:Microsoft.CSharp.dll /r:System.Configuration.dll /r:System.Configuration.Install.dll /r:System.Core.dll /r:System.Data.dll /r:System.Data.DataSetExtensions.dll /r:System.Data.Linq.dll .......... In same way we can have our own response file defined which might include some third party dll. Let's see an example. Suppose we have to create an appli...