Replace invalid characters with empty strings by using Regular expression

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using System.IO;

namespace Billing
{
    public class StringUtils
    {
        public static String CleanInput(string str)
        {
            // Replace invalid characters with empty strings.
            return Regex.Replace(str, @"[^\w ]", "");
        }
    }
}

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

Advertisements

What is REST?

It is rather style or pattern of development resource-oriented web applications. Beauty of REST is that its really easy to understand and basically you are using REST everyday but may not noticing that. REST works on top of HTTP protocol, but is is not protocol itself. It seems to me that it actually appears with HTTP/1.1 but only with Roy Fieldingwork it became well understood, defined and attractive.

REST popularized by such applications as twitter, flickr, bloglines, technorati etc. And of cause, by Ruby On Railsframework.

REST vs. SOAP

Sure, REST is not first who approaches issue of using recourses in Web, it rather trendier new kind in a block. We know bunch of web technologies, SOAP, WSDL, ATOM, WS-*, WCF, ODATA and many many more.. So, what are the difference?

Major difference is that all above are protocols, but REST is style. This has pros and cons. Protocol’s are more strict and heavyweight, with a number of rules, formats etc. SOAP is using XML as data exchange format, REST could work any format depending on client needs. SOAP is using its own security model, REST relies on HTTP and web server security. SOAP requires tools, REST learning curve is small and less less reliance on tools. SOAP designed to handle distributed computing environments, REST assumes a point-to-point communication model.

But my opinion is simplicity always win against complexity. Key popularity of REST is because is simple, easy understand by developers and as a result – implemented in applications. My believe that SOAP and other heavyweight protocols will slightly die more and applications will be using REST.

 ASP.net MVC and REST

Developers of ASP.net MVC framework designed it to be REST compatible. In the level of framework, there is an URL routing system (System.Web.Routing) that allows you easily follow REST design principles. It gives you total control over your URL schema and its mapping to your controllers and actions, with no need to conform to any predefined pattern.

So, basically ASP.net MVC web applications development is: create a controller class (LoginController for instance), implement number of actions (Index, CheckCredentials) and map those actions to particular URL. For instance http://mysite.com/login mapped to LoginController.Index method, that handles GET request from server and return View, containing Login form. http://mysite.com/login/check mapped toLoginController.CheckCredentialsmethod, that handles POST and checks users credentials.

It is much more easier to create web applications API’s with MVC framework. TheActionResult is polymorphic, so it could return HTML, JSON, XML results (and you are free to implement own ActionResult, for any format you might need).

Performance tests

Performance tests focused on determining or validating performance characteristics of the product under test when subjected to workload models, and load volumes beyond those anticipated during production operations.

  • How many users can the application handle before “bad stuff” happens
  • How much data can my database/file server handle?
  • Are the network components adequate?

Stress test

These tests are all about determining under what conditions an application will fail how it will fail and what indicators can be monitored to warn of an impending failure.

What are the benefits?

  • Determining if data can be corrupted by over stressing the system
  • Estimating how far beyond the target load an application can go before causing failures and errors in addition to slowness
  • Establishing application monitoring triggers to warn of impending failures
  • Ensuring that security holes are not opened up by stressful conditions.
  • Determining the side effects of common hardware or supporting application failures.
  • What risks does it address?
  • What happens if we underestimated the peak load?
  • What kind of failures should we plan for?
  • What indicators should we be looking for to intervene prior to failure?

Endurance test

A performance test focused on determining or validating performance characteristics of the product under test when subjected to workload models and load volumes anticipated during production operations over an extended period of time.

What are the benefits?

  • Slow memory leaks
  • Insufficient file storage capacity
  • Performance degradation as a result of an increased in stored data
  • Overnight, automatic virus definition updates on a server causing performance degradation
  • What risks does it address?
  • Will performance be consistent over time?
  • Are there slow growing problems that we haven’t detected?
  • Is there external interference that we didn’t account for?

Spike test

A performance test focused on determining or validating performance characteristics of the product under test when subjected to workload models and load volumes that repeatedly increase beyond anticipated production operations for short periods of time.

What are the benefits?

  • Memory leaks
  • Disk I/O (thrashing)
  • Slow return to steady – state
  • What risks does it address?
  • What happens if we underestimated the peak load?
  • What kind of failures should we plan for?
  • What indicators should we be looking for to intervene prior to failure?

Capacity testing

Capacity testing is related to stress testing .It determines your server’s ultimate failure point. You perform capacity testing in conjunction with capacity planning.

You use capacity planning to plan for future growth, such as an increased user base or increased volume of data. For example, to accommodate future loads you need to know how many additional resources (such as CPU, RAM, disk space, or network bandwidth) are necessary to support future usage levels.

Capacity testing helps you identify a scaling strategy to determine whether you should scale up or scale out.

What are the benefits?

  • Provide actual data to the capacity planners to validate or enhance their models and/or predictions.
  • Conduct various tests to compare capacity planning models and/or predictions.
  • Determine current usage and capacity of existing system to aid in capacity planning.
  • Provide usage and capacity trends of existing system to aid in capacity planning.

What risks does it address?

  • Validate that capacity planning models represent reality.
  • Ensure capacity planning remains in sync with actual system usage and growth patterns

How to: Collect Event Tracing for Windows (ETW) Data

Event Tracing for Windows (ETW) is an efficient kernel-level tracing facility that enables profiler log kernel or application-defined events. The data that is collected from the event provider can be viewed only by using the /Summary:ETW option of the VSPerfReport command-line tool. You can use this report to determine where performance issues occur in the application.

To enable event trace providers
  1. In Performance Explorer, right-click the performance session, and then click Properties.

  2. In the Property Pages, click the Windows Events properties.

  3. In the Select event trace provider to collect data from list, select the event providers that you want to use to profile your application.

Visual Studio 2010 Diagnostic Tool

Visual Studio 2010 add-ins

Productivity Power Tools

  • No More Extension Resets – This version of the Productivity Power Tools will be the last which resets the extensions.
  • Find – Quick find & incremental search now pops up at top right-hand corner of the editor.
  • Enhanced Scrollbar – Icons overlay the scrollbar to show edits, breakpoints, bookmarks, errors, warnings, etc.
  • Middle-Click Scrolling – Use your scroll wheel to quickly scroll through your document.
  • Organize Imports for Visual Basic – Sort the imports logically and remove the ones that aren’t being used.

    Regex Editor

    JScript Editor Extensions

    PowerCommands for Visual Studio 2010

    Microsoft All-In-One Code Framework Sample Browser

    PHP Language Support

  • jQuery Globalization Plugin

    Microsoft released a prototype of a new jQuery Globalization Plugin that enables you to add globalization support to your JavaScript applications.

    jQuery Globalization Plugin includes globalization information for over 350 cultures ranging from Scottish Gaelic, Frisian, Hungarian, Japanese, to Canadian English.  We will be releasing this plugin to the community as open-source.

    You can download our prototype for the jQuery Globalization plugin from our Github repository:

    http://github.com/nje/jquery-glob

    You can also download a set of samples that demonstrate some simple use-cases with ithere.

    ASP.NET error CS0016: Could not write to output file

    If you attempt to run an ASP.NET application hosted on IIS7.0 running on Windows Home Basic or Premium (Vista or Windows 7, x86 or x64), you may receive the following error:

    error CS0016: Could not write to output file 

    The problem occurs because Windows Home Basic and Premium lack Windows Authentication. You can solve this problem with a few mouse clicks:

    1.  Run the Internet Information Services (IIS) Manager program.  It can be found in the Start > Administrative Tools menu.  You may have to edit the Start Menu properties to show the Administrative Tools folder.

    2.  Select the Application Pools item in the Connections pane.

    3.  Right-click on the application pool in which you are running your ASP.NET application.  On my PC, this was the DefaultAppPool.

    4.  Select Advanced Settings from the popup menu.

    5.  In the Process Model section, set the Identity to LocalSystem.  Click the OK button.

    Freely Available .NET Libraries

    Ajax

    • Ajax Control Toolkit – Microsoft
    • AJAXNet Pro
    • ASP.NET MVC Project Awesome – a rich set of helpers (controls) that you can use to build highly responsive and interactive Ajax-enabled Web applications. These helpers include Autocomplete, AjaxDropdown, Lookup, Confirm Dialog, Popup Form and Pager. Thanks Omu (April 20, 2011)

    Build Tools

    • Prebuild – Generate project files for all VS version, including major IDE’s and tools like SharpDevelop, MonoDevelop, NAnt and Autotools
    • Genuilder – Precompiler which lets you transform your source code during the build. Thanks Harry McIntyre (April 13, 2011)

    Charting/Graphics

    Collections/Generics

    • PowerCollections – is a library that provides generic collection classes that are not available in the .NET framework. Some of the collections included are the Deque, MultiDictionary, Bag, OrderedBag, OrderedDictionary, Set, OrderedSet, and OrderedMultiDictionary. Thanks Adam Ralph (April 20, 2011)

    Compression

    Controls

    • Krypton – Free winform controls. Link fixed (April 14, 2011)
    • Source Grid – A Grid control
    • DevExpress – Over 60 Free Controls from DevExpress. Thanks Florian Standhartinger (April 20, 2011)
    • ObjectListView – is a C# wrapper around a .NET ListView. It makes the ListView much easier to use and provides some neat extra functionality. Thanks Florian Standhartinger (April 20, 2011)

    Data Mapper

    Dependency Injection/Inversion of Control

    Design by Contract

    IDE

    • SharpDevelop – is a free IDE for C#, VB.NET and Boo projects. Thanks Florian Standhartinger (April 20, 2011).

    Logging

    ORM

    PDF Creators/Generators

    Automated Web Testing

    Misc Testing/Qualitysupport/Behavoir Driven Development (BDD)

    URL Rewriting

    MS Word/Excel Documents Manipulation

    • DocX to create, read, manipulate formatted word documents. Easy syntax, working nicely, actively developed. No Microsoft Office necessary.
    • Excel XML Writer allows creation of .XLS (Excel) files. No Microsoft Office necessary. Been a while since it has been updated. It also provides code generator to create code from already created XLS file (saved as xml). Haven’t tested this but looks very promising. Too bad author is long time gone.
    • Excel Reader allows creation/reading of .XLS (Excel) files. No Microsoft Office necessary. Been a while since it has been updated.
    • Excel Package allows creation/reading of .XLSX (Excel 2007) files. No Microsoft Office necessary. Author is gone so it’s out of date.
    • EPPlus is based on Excel Package and allows creation/reading of .XLSX (Excel 2007). It is actually the most advanced even comparing to NPOI.
    • NPOI is the .NET version of POI Java project at http://poi.apache.org/. POI is an open source project which can help you read/write xls, doc, ppt files.
    • sharp2word – a Word 2003 XML Documents Generator from C# code without any components or libraries. Thanks dublicator (April 20, 2011)
    • ClosedXML – an actively developed library for generating OpenXML Excel files. Thanks Joseph Robichaud (April 26, 2011)

    Serialization

    • sharpserializer – xml/binary serializer for wpf, asp.net and silverlight
    • Protobuf.NET – fastest serialization port protobuf format into .NET platform. Thanks slava pocheptsov (April 26, 2011)

    Silverlight

    Social Media

    • LinqToTwitter – Linq-based wrapper for all Twitter API functionality in C#
    • Facebook C# SDK – A toolkit for creating facebook applications / integrating websites with Facebook using the new Graph API or the old rest API.

    Package managers for external libraries

    • NuGet (formerly known as NuPack) – Microsoft (developer-focused package management system for the .NET platform intent on simplifying the process of incorporating third party libraries into a .NET application during development)
    • OpenWrap – Sebastien Lambla – Open Source Dependency Manager for .net applications

    Unit Testing/Mocking

    Validation

    Threading

    • Smart Thread Pool – Thread Pool management library
    • Retlang – a high performance C# threading library. Thanks MarcBot (April 13, 2011)
    • bbv.Common – an open source library of software components that makes building multi-threaded, event-based and loosely coupled systems easy. Thanks Urs Enzler (April 14, 2011)
    • PowerThreading – a llibrary (DLL) containing many classes to help with threading and asynchronous programming. Thanks Adam Ralph (April 20, 2011)

    Unclassified

    • CSLA Framework – Business Objects Framework
    • AForge.net – AI, computer vision, genetic algorithms, machine learning
    • Prism – Composit UI application block for WPF, Silverlight and WP7 – Microsoft patterns & practices
    • Enterprise Library 5.0 – Logging, Exception Management, Caching, Cryptography, Data Access, Validation, Security, Policy Injection – Microsoft patterns & practices
    • File helpers library
    • C5 Collections – Collections for .NET
    • Quartz.NET – Enterprise Job Scheduler for .NET Platform
    • MiscUtil – Utilities by Jon Skeet
    • Noda Time – DateTime replacement (idomatic port of Joda Time from Java)
    • Lucene.net – Text indexing and searching
    • Json.NET – Linq over JSON
    • Flee – expression evaluator
    • PostSharp – AOP
    • IKVM – brings the extensive world of Java libraries to .NET.
    • C# Webserver – Embeddable webserver
    • Long Path – Microsoft
    • .NET Engines for the GOLD Parsing System
    • NCQRS – library for event-driven architectures (CQRS).
    • Reactive Extensions for .NET – a library for composing asynchronous and event-based programs using observable collections. Thanks steve (April 14, 2011)
    • Mono.GameMath – a project to develop a highly-performant math library for games, based on XNA APIs. Thanks Alex Rønne Petersen (April 14, 2011)
    • SLSharp – a runtime IL-to-GLSL translation engine, allowing people to write GLSL shaders as C# code. Thanks Alex Rønne Petersen (April 14, 2011)
    • InfusionSoftDotNet – a dll to ease the pain for .Net developers to access the InfusionSoft API. Thanks Michael Gibbs (April 20, 2011)
    • re-mix – provides mixins for C# and Visual Basic .NET. Thanks Stefan Papp(April 20, 2011)
    • Mono.Cecil – a library written by Jb Evain to generate and inspect programs and libraries in the ECMA CIL format. It has full support for generics, and support some debugging symbol format. Thanks Florian Standhartinger(April 20, 2011)
    • ImapX – is an modern .NET 2.0 library for management of IMAP folders, supports SSL Connection and different IMAP formats, such as Gmail IMAP, AOL IMAP (November 30, 2011)