Pages

Casting or Parsing a variable in generic type member variable in C#

Wednesday, December 18, 2013

Microsoft .Net already has a bunch of great string conversion routines you can use! A TypeConverter can do most of the heavy lifting for you. Then you don't have to worry providing your own parsing implementations for built-in types. Note that there are locale-aware versions of the APIs on TypeConverter that could be used if you need to handle parsing values expressed in different cultures. The following code will parse values using the default culture:

public object Convert(string member, string value)
{
    Type type = typeof(T).GetProperty(member).PropertyType;
    var converter = TypeDescriptor.GetConverter(type);
    return converter.ConvertFromString(value);
}

The best way to compare two objects by value in C#

To compare to object by value we can use the following code snippet.

private static bool CompareValue(object o1, object o2)
{
    return o1.GetType() == o2.GetType() && Object.Equals(o1, o2);
}

This method compare the types of two object and then check their value.


Whats New in ASP.NET and Web Tools for Visual Studio 2013

Tuesday, December 10, 2013

Microsoft recently released the new version of Visual Studio 2013 and web tools. Here are the summary of the new features for the web developers in Visual Studio 2013.
  • New release focuses on One ASP.NET, which steps toward to unifying the ASP.NET technologies so core features can and web tools work the same  across the platforms (e.g. adding ASP.NET MVC controllers to a Web Forms application).
  • Enhance Authentication and Identity feature.
  • New version of ASP.NET, which includes ASP.NET MVC 5, Web API 2, Razor 3, Entity Framework 6 and SignalR 2.0
  • New Browser link feature that lets you to connect multiple browsers to Visual Studio and refresh them all by clicking a button in the toolbar.
  • New core features include new templates based on Bootstrap, a new scaffolding system.
  • Awesome editor for web tools, including HTML5, CSS3, JavaScript,  jQuery, AngularJS, Ember, LESS, CofeeScript etc.
  • New Project Readme.html page.
  • New and enhance Web publish features like easily automate Web.config file encryption, automate taking an application offline during deployment.
  • Visual Studio 2013 released with a new NuGet 2.7 for package management.

SPDY: Let's make the web faster

Introduction

SPDY (Pronounced as "SPeeDY") is an open networking protocol similar to HTTP, with particular goals of reducing web page load latency and improving web security. SPDY achieves reduced latency through compression, multiplexing, and prioritization. 

Background: web protocols and web latency

Today, HTTP and TCP are the protocols of the web. TCP is the generic, reliable transport protocol, providing guaranteed delivery, duplicate suppression, in-order delivery, flow control, congestion avoidance and other transport features. On the other hand, HTTP is the application level protocol providing basic request/response semantics.

Get property value from C# dynamic object by string using reflection

In Generic Class, it is quite common to get the value for a specific property dynamically. C# refection provides ways to get the Property value dynamically. If the IDynamicMetaObjectProvider can provide the dynamic member names, you can get them. See GetMemberNames implementation in the apache licensed ImpromptuInterface (which can be found in nuget), it works for ExpandoObjects and DynamicObjects that implement GetDynamicMemberNames and any other IDynamicMetaObjectProvider who provides a meta object with an implementation of GetDynamicMemberNames without custom testing beyond is IDynamicMetaObjectProvider.

Resolve the Visual Studio 2012 issue after updating or installing Visual Studio 2013

Sunday, November 17, 2013

If you have already installed VS2012 and at a later Update to new a Service Pack or Installing VS2013, when you load any project, you may get the following error:
---------------------------
Microsoft Visual Studio
---------------------------
The 'ProviderPackage' package did not load correctly.

The problem may have been caused by a configuration change or by the installation of another extension. You can get more information by examining the file 'C:\Users\username\AppData\Roaming\Microsoft\VisualStudio\11.0\ActivityLog.xml'.

Continue to show this error message?
---------------------------
Yes   No   
---------------------------

Change Local Path after download files from Source Control

If you want to change the local path for the working directory of the Team Foundation Server (TFS), you should follow the following steps:
  1. Go to File -> Source Control -> Advanced->Workspaces

Attach a Database File to The SQL Server

Wednesday, November 13, 2013

You can attach a database file to an instance of SQL Server by using the SQL Server Management Studio tool. For example, if you have existing database files from an old installation of SQL Server, you can attach these files to a new installation or another instance of SQL Server. Likewise, if you want to restore a corrupt database from a backed-up copy, you can attach the backed-up database file.This topic describes how to attach a database in SQL Server 2012 by using SQL Server Management Studio or Transact-SQL. You can use this feature to copy, move, or upgrade a SQL Server database.

Prerequisites 

  • When you attach a database, all data files (MDF and NDF files) must be available. If any data file has a different path from when the database was first created or last attached, you must specify the current path of the file.

Add Custom Message to Unit Test Result

If you are using MS test for the Unit test of your code you may need to print some output on the Output window. You can use


System.Diagnostics.Trace.WriteLine("Hello World!!!!!");

To output whatever you'd like. It will show up in the full results of the test runner.


What is the difference between a Library and a Framework?

Tuesday, November 12, 2013

It is quite a common question in all of the software developers mind, what is the difference between a Library and a Framework? The two concepts are important but sometimes confusing.

Key Difference and Definition of Library and Framework

The most important difference, and in fact the defining difference between a library and a framework is Inversion of Control(IoC). When you call a method in a library, you are in control. But with a framework, the control is inverted: the framework calls you. This is pretty much the difference and definition of a framework. In the framework, all the control flow is already there, and there’s just a bunch of predefined white spots that you should fill out with your code.

A library is just a collection of class definitions. The reason behind is simple, i.e. get the code that has already been written by other developers. The classes and methods normally define specific operations in a certain area. Your code is in charge and it calls into the library when it sees fit. E.g., jQuery.

A framework is normally more complex. It defines a skeleton where the application defines its own features to fill out the skeleton. In this way, your code will be called by the framework when appropriately. The benefit is that developers do not need to worry about if a design is good or not, but just about implementing domain specific functions.

Awesome Code Syntax Highlighting in Blogger Post

If you want to share your code in the blog, you need to format the code snippet with proper syntax and highlighting. Blogger and Wordpress does not support code syntax highlighting by default. Fortunately an excellent open source and free code syntax highlighter tool called SyntaxHighlighter available in the web.

This is 100% JavaScript based SyntaxHighlighter tool to use in the web pages with out any dependency on other frameworks or third party tools. SyntaxHighlighter can be either downloaded & used on your own webserver or if you have a blog on Blogger, this can be directly used as well.

C#: Detect Windows OS Version Info

Friday, March 29, 2013

Currently, several versions of Windows OS are available in the market from Windows XP to latest Windows 8. For one my application, I was looking for a way to determine the OS version of the installed Windows at my workstation using C#. I have googled for the answer but no answer give me a clear idea and full functional way to determine the OS version. So, I find out a way to determine the OS version of Windows in my application using C# and in this tutorial I would like to describe the ways to do that.

Concept:


Every released windows operating system has a version number.  The version number has two main part formatted as "x.x", first digit is referred as Major Version Number and second digit is referred as Minor Version number.

Cocos2d-x: Coordinate System

Thursday, March 28, 2013

To understand the coordinate system of a game engine is a fundamental topic. In this tutorial I would like to describe the coordinate system of Cocos2d-x. The same concept is also applicable for Cocos2d game engine. You can also visit the Cocos2d-x Official Wiki Page which describes Cocos2d-x coordinate system briefly.

2D World Coordinate System


As cocos2d-x is a 2d game engine, we only use x-axis and y-axis to represent our coordinate system. Again, cocos2d-x uses OpenGL API to draw and manipulate objects. OpenGL use "right handed coordinate system" :

Debug Android NDK Project in Eclipse

Wednesday, March 27, 2013

Debugging Android NDK Application in Eclipse is cumbersome. There are some GDB agent to debug Android application there but the best GDB agent is NVidia Debug Manager Plugin from NVidia. To install the NVidia Debug Manager Plugin, at first you need to join in the Tegra Registered Developers Program. To do this go to this page and create an account. Next, a verification and approval process will be gone through. After NVidia approves your account you can download the Tegra Developers Pack.When you install the Tegra Developer pack, it gives you the option to select what you want to install and at this point, you can opt to install just the plugin.

Cocos2dx: Combine iOS and Android Project Files

In the previous two tutorials I have discussed on setting up Cocos2d-x environment for both iOS and Android.  So, now we have two project structure, one for iOS and another fore Android. In this tutorial I will discuss on how to combine this two project and develop the game in Cocos2d-x using the same code base and structure.

Both iOS and Android project source directory consists of C++ files and these files are located under the "Classes" directory. Open the project explorer and you will find this two identical folder.



So, we can use the same files for developing two different game application by linking the files. To do so, open up your SampleGame project in Xcode. Select the Classes group, click Delete, and select “Move to Trash” when the popup appears.

Setting up Cocos2d-x for Android Game Development

Tuesday, March 26, 2013

As cocos2d-x is ported to C++, now you can develop game for both iOS and Android platform. In the previous tutorial I have discussed on how to setting up cocos2d-x game engine in OSX for iOS game development. Now, in this tutorial I will discuss on Android game development using cocos2d-x.

This tutorial asumes that you have a fully functional Android development environment using Eclipse IDE and Android SDK. If you do not, please go through  "Setting up Android Development Environment"  from Android Official Developers Site first, which provides a step by step procedure on setting up a dedicated Android Application Development environment and install various prerequisite softwares.

Setting up Cocos2d-x in Mac OSX for iOS Game Development

Cocos2d-x support multi-platform game development including iOS game developments. In this tutorial I will discuss how to install the Cocos2d-x game engine in your workstation for iOS game development.

Prerequisites:

  • Mac OSX version 10.6 or upper.
  • XCode 3.2.5+ 

Introduction to Cocos2d-x

Cocos2d is an easy to use and amazing 2d game engine to develop iOS based games. It is free and open source. But as it is written in Objective-c, you can only develop games for iOS and Mac using it. To overcome this issue and support multi-platform game development,  cocos2d-x is developed.

Top 5 Free Text Editors for Mac OSX

Friday, February 22, 2013

Many of the windows users use notepad++ as a text editor but unfortunately there is no mac version available for mac OSX. For mac user there are many alternative text editors.  These are much powerful and versatile.


TextWrangler

TextWrangler is a free version of BBEdit (see below). It offers a broad range of support for different programming languages, and fantastic find and replace functionality. A reliable and powerful tool, especially considering its freeware status.

Configure XDebug to Debug PHP Projects

There are few options to debug PHP projects. By default XDebug is not configured in PHP engine. So you need to follow some steps.

Steps:

  1. If you have used any of the AMP package like XAMPP/WAMP/LAMP, the XDebug extension may be already installed in your PHP engine.If not download the XDebug tool from its official website

Enable XDebug in Aptana Studio 3.x

Many of the web developers faced problem to use Aptana Studio as they cannot configure the XDebug in their workstation. Recently I configure my Aptana Studio for XDebug successfully. Here it is:

Requirements:

  1. Aptana Studio 3.2.0 or newer. I use 3.2.2 to demonstrate the tutorial
  2. XAMPP / WAMP/ LAMP or any other web server solutions.
  3. PHP 5.3 or newer.
  4. XDebug is already configured in the php.ini . If the XDebug is not configured in your web server, follow this link. I have discussed the topic in "Configure XDebug" post.

Speeding up Your Android Emulator

Thursday, February 21, 2013

The main problem to develop and testing an android application is their Emulator. Almost all of the android developers has complaints about the slowness of the Emulator. Although the current system image has built-in GPU support (Android 4.0.3 r2). With Android’s growing reliance on using the GPU to improve performance. But I, personally, dont like the slowness of Android Emulator and it really kill too many times of mine. So I got some research and found three solutions that are described below:
  1. Emulator Snapshot
  2. x86 hardware acceleration (Intel HAXM)
  3. Use BlueStack Emulator

Using Emulator Snapshot: 

The first solution to speed up the emulator is to use the snapshot option of the android emulator.

Resolve the Intel HAXM Issue in MAC OSX

Many Android Developers used the Intel Hardware Accelerator (HXAM) to accelerate the Android emulator in their workstations. Its works like a charm in the Windows environment but MAC OSX users may face reboot issue when they are tried to run a Intel x86 base AVD.

Yet another but the fastest android emulator

The main complaints about the Android emulator is their slowness. As the Android emulator uses the Atom based system image it operates slow in the PCs and traditional workstations. But finally their is a light in the tunnel and here it come BlueStack.

Change the blogger post URL using permalink

When you write a post, Blogger automatically generates a permalink (a URL that links to a blog post) for your post from its title.For example if your post title is something like "Change The URL" blogger automatically create an URL like "example.com/2013/02/change-the-url.html". If you prefer to use a custom permalink, you can do so via the “Permalink” option in the Post Settings box. To do so you should do the following steps.

WPF Tutorial: WPF Development Tools

Tuesday, February 19, 2013

There are a number of development tools available for developing Windows Presentation Foundation applications. Microsoft provides two development tools for WPF applications. One is Visual Studio, made for developers and the other is Expression Blend made for designers. While Visual Studio is good in code and XAML editing, Expression Blend covers the graphical part very well.

WPF Tutorial: Introduction to WPF

Windows Presentation Framework (WPF) is a next generation presentation framework for building stunning windows client application. WPF is developed by Microsoft and is a computer-software subsystem that is vastly used for rendering user interfaces in windows based applications. WPF was initially released as a part of .NET Framework 3.0. Rather than relaying on older USER32 and GDI32 subsystem, WPF utilizes DirectX for rendering user interfaces.

WPF Tutorial: Getting Started with WPF

Welcome to the world of WPF ( Windows Presentation Framework). In this tutorial I will share the basic knowledge and setup environment to start developing WPF applications.

Next Steps:
1. Introduction to WPF
2. Development tools
3. Setup Development Environment
4. Resources
 

Search This Blog