In most of the present day code development, Application Localization is being achieved using RESX files. As time progress, we might not be able to keep track of which key-value pairs of a RESX file are being consumed by the application and which are orphaned. At present, it is very difficult to remove the orphan entries through automation and most of us stick to manual clean up. There are some tools which are capable of cleaning RESX files, but they come with price tag. In this quick tutorial, I am going to show how to clean a resource file through regular C# code.
Articles and concepts related to C# language
JumpStart # 20– Do not include config data in class libraries, instead inject from invoking application
Most of the Junior developers tend to put up there configuration sections of class libraries (DLL’s) along with them. The typical class libraries (for example – Data Access Layer, Business Layer etc) should be configured from the executing assembly. Having config in the same DLL’s would hinder their purpose of re-usability.
From C# 4.0, .Net Framework supports Lazy initialization of instances. Lazy initialization helps in loading instances (especially useful for costly properties of objects) only when they are accessed at runtime. That means lazy properties are not loaded when actual object initialization is done.
1. Use Parallel.For (introduced in .Net 4.0) for parallel processing on multiple threads.
2. When a iterative long running operation needs to be performed, then using Parallel.For will help in spanning these iterations on multiple threads and on final stage combining all successive inputs.
3. There is also a provision for breaking/stopping these iteration by setting up LoopState.
4. We can also set the initial value (as a param) for all threads which are spanning across.
ASP.NET 4.5 provides an ability to declare the data type of the data that a control is bound to throught ItemType property. When we set this property, two new typed variables are available in the scope of data-binding expressions: Item (One Way binding) and BindItem (Two Way Binding).
In previous versions, Data binding expressions are evaluated at runtime using reflection and bind data, which is not only developer nightmare but also encourages more data shaping problems.
ASP.NEt 4.5 introduces Async processing of Asynchronous HttpHandler using “HttpTaskAsyncHandler” abstract class and then override “ProcessRequestAsync”. HttpTaskAsyncHandler implements both IHttpAsyncHandler, IHttpHandler. In this new way, ASP.Net takes most of the overload of managing threads in continuing async tasks by itself.
In earlier versions of ASP.Net, there is no flexibility for uploading multiple files using FileUpload Control. But ASP.Net 4.5 enhanced traditional FileUpload Control now, through which multiple file uploads is possible with an extra attribute -AllowMultiple=”true”.
Often we write lot of extension methods which helps us in consolidating logic and performing operations on objects in a easy way. In this tutorial I m going to narrate on how to implement...
In this short tutorial, I am going to show how to validate a Dropdownlist in MVC3 using Razor Syntax. Our Model Class – using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel.DataAnnotations; using...
Documentation of code, arrrgh!!! Most of us hate it, but believe me its an important part in SDLC. Especially when it comes to maintenance of legacy code, Documentation is a life savior.
Writing Xml Comments in Visual Studio is not going to be a easy going task (for large projects it’s a nightmare too). So I started using GhostDoc, an extension of Visual Studio, which helps and makes Xml commenting comparatively easier. There are many other extensions available which give the same functionality in writing comments, but in this small JumpStart I would like to show how to get started with GhostDoc.
The intended application got some secured products in the Sql DB (here the table is Products). Users can login to the DB and can only retrieve products thorough MVC Application. So User first needs to Register to the application, then he can login to the application to retrieves the secured information of the products.
The main attention of the complete process flow is “Registration”, especially Password field. Storing Password as a string into DB is considered as not a good practice, so first we generate a Password Salt using Cryptography, then we use the original Password String along with Password Salt to hash it into a more secured format using a Hashing algorithm. and finally it is stored in the Users table of Sql DB.
While Authenticating User, we get the Password String from User login, then check the DB for Username, get the User Entity from the DB, fetch the Password Salt associated with the User, Combine the Password string and Password Salt to generate the Password Hash, then finally cross check the generated Hash with that of the DB version. If both matches, Authenticate the user or else notify him as Invalid Login.
Implementing MVP Pattern using UserControls with WCF Database Operations in Entity Framework and LINQ – Part III
In this part of the tutorial, we carry on with the construction of MVP Pattern. First we start with the creation of View interfaces for the UserControls (which we created in PART II). Then we create the presenter classes, which will take the corresponding instances of views and then manipulate the view using Model classes (there by achieving code portability). Once we are done with the presenter classes, we implement the View interfaces in the codebehind of the UserControls. Finally we create a sample ASP.Net web page (typically webform), and use the UserControls for database transactions.
Implementing MVP Pattern using UserControls with WCF Database Operations in Entity Framework and LINQ – Part II
In this part of the tutorial – We first code for the CustomerService.cs by implementing ICustomerService.cs interface. We use LINQ queries to code database transactions. Then we create a host application (here it is a Console application) which operates the WCF service. Then we create a sample website for implementing MVP Pattern to access WCF. In the website, we implement some UserControls for fetching/updating/deleting records from the database.