Wednesday, February 03, 2010

Reflection in .NET

In this article I tried to cover all the topics from .NET Reflection with examples. I have stated with definition of .NET Reflection and its road map, list of mostly used classes the System.Reflection namespace provides and importance of Type class in .net Reflection. You will also learn how to get the type information using different ways. Use of properties and methods of Type class in .NET Reflection with examples are interesting in this article. You will also see advance Reflection topic like dynamically loading an assembly and late binding end of this article.

Read more: C# Corner

Posted via email from jasper22's posterous

Building a Basic Web Server Using WCF

In my last post, I talked about how WCF actually can handle a lot more than basic web service communication. Today, I’m going to take that a little further, by showing you how you could build a very basic web server on top of WCF.

If you are familiar with ASP.NET, you have probably heard of a little class called IRequestHandler. In ASP.NET, if you wanted to create a handler that simply streamed a file from disk, you might write a little code like this:
view plaincopy to clipboardprint?

  1. public class FileRequestHandler : IHttpHandler  
  2. {  
  3.     #region IHttpHandler Members  
  4.  
  5.     public bool IsReusable  
  6.     {  
  7.         get { return false;  }  
  8.     }  
  9.  
 10.     public void ProcessRequest(HttpContext context)  
 11.     {  
 12.         context.Response.WriteFile(context.Request.PhysicalPath);  
 13.     }  
 14.  
 15.    

Posted via email from jasper22's posterous

Multithreaded UI: HostVisual

In general, objects in WPF can only be accessed from the thread that created them.  Sometimes this restriction is confused with the UI thread, but this is not true, and it is perfectly fine for objects to live on other threads.  But it is not generally possible to create an object on one thread, and access it from another.  In almost all cases this will result in an InvalidOperationException, stating that “The calling thread cannot access this object because a different thread owns it.”

Freezables

Of course, there are exceptions to this restriction.  A familiar one is the Freezable class.  Freezable objects can be frozen, at which point they become read-only and we lift the single-thread restriction.  Examples of frozen Freezables include the standard brushes, available from the Brushes class.  These brushes can be used on any thread at any time.

This is incredibly useful, and used for all of the graphics primitive resources (pens, brushes, transforms, etc).  You can even derive your own types from Freezable and play by the same rules.

Separate Windows

Unfortunately, that read-only restriction can be a real problem.  There are many scenarios where we want to run separate pieces of the UI on separate threads.  If these pieces of UI are independent from each other, you can host them in separate windows, and run the windows on separate threads.  This can be a reasonable solution for some scenarios, especially scenarios where the separate threads can be run in independent top-level windows.  The big restriction for this approach is that the graphics from one cannot be composited with the graphics of the other.  So while you could use a child window for the other thread’s UI, the system will just render one on top of the other.  You cannot have transparency, you cannot use one as a brush for 3D content, you can’t draw over it, etc.

Read more: Presentation Source

Posted via email from jasper22's posterous

Realtime Brainwave Data with WPF

A wonderful thing happened since my last post on this project. The friendly folks at Emotiv listened to their devoted users and opened up the raw electrode data from their amazing EPOC neuroheadset (just $299). That’s a 14-channel fire hose of brainwave data, streaming via Bluetooth at a sampling rate of 128Hz. I wanted to see if I could whip up a quick WPF control that that would display all that data in realtime.

epocheadset.gif

As it turned out, “quick” wasn’t in the cards -- delivering new Visual Studio 2010 content took priority -- but finally, I have a working prototype that shows it’s doable. The code’s not quite ready for public consumption, but here’s a teaser.

I wrote a managed wrapper in C#, named EmoEngineClient, that polls the neuroheadset for state and also collects the electrode data. That was the easy part. Much more challenging was designing the rendering pipeline. A couple of seconds of data generate several thousand points, and painting all of those within the 7.8ms frame rate is not straightforward. For highest performance, you’d probably write a pixel shader and do everything in the GPU, but I’m not a Shader Language jock, and I want to use native WPF features. The next best thing is to draw each channel’s data trace with a Polyline, and as long as I do very little clipping, it should render very quickly.

Even so, that’s too much data for the UI thread to render and still remain responsive to user input. The trick is to render each Polyline on its own thread, which is simpler than you might think, but still tricky.

Read more: Jim Galasyn's Learning Curve

Posted via email from jasper22's posterous

HipHop for PHP: Move Fast

One of the key values at Facebook is to move fast. For the past six years, we have been able to accomplish a lot thanks to rapid pace of development that PHP offers. As a programming language, PHP is simple. Simple to learn, simple to write, simple to read, and simple to debug. We are able to get new engineers ramped up at Facebook a lot faster with PHP than with other languages, which allows us to innovate faster.

...

HipHop for PHP isn't technically a compiler itself. Rather it is a source code transformer. HipHop programmatically transforms your PHP source code into highly optimized C++ and then uses g++ to compile it. HipHop executes the source code in a semantically equivalent manner and sacrifices some rarely used features — such as eval() — in exchange for improved performance. HipHop includes a code transformer, a reimplementation of PHP's runtime system, and a rewrite of many common PHP Extensions to take advantage of these performance optimizations.

Read more: Facebook Developers

Posted via email from jasper22's posterous

CouchDB: The Definitive Guide

This is the home of a free O’Reilly Media book about Apache CouchDB.

The book is designed to guide you gently through using CouchDB with clear but practical scenarios. We progressively showcase key features, starting with simple document CRUD, working through to advanced MapReduce, and culminate with deployment tuning for performance and reliability.

Sign up to the mailing list to stay updated and discuss changes. Each paragraph has a handy Comment link that allows you to quote text and post a comment to the mailing list. Feel free to make liberal use of this feature.

This book is a work in progress. The number of chapters linked below reflect our progress.

We’re mainly looking for high level commentary on the topics covered and on our clarity, tone, and pacing. Our editor will take care of spelling and other nitpicks.

Read more: CouchDB: The Definitive Guide

Posted via email from jasper22's posterous

How To: Create Or Convert Website Into Mobile Format

Now a days more and more people are using smart phones to access the internet, because of this growing demand web developers and designers must focus on mobile format websites too. Don’t worry, you don’t have to learn any programming language to do that. There are few online services available that will help you to create or convert websites into mobile format.

Here i have mentioned few tools and tutorials that will help you out.

Read more: PelFusion

Posted via email from jasper22's posterous

Creating a Quick Windbg Pseudo Debugger Extension - Part I

Problem

Quick way to script, format, group, parse and automate some debugging task[s].
If you ever wish that the debugger would had x,y or z command or debugger extension?
The learning curve and the time to create a simple debugger extension can be challenging for the most part.
Sometimes the debugger scripting may feel short in functionality every now and then.

Solution

Create a console application that is able to receive input and parameter data from windbg, inside the application be able to slide and dice the data using your preferred programming language that you are most familiar with and the ability to display back the data in the debuggers output window.

From windbg this can be done via the .shell command to call and pass parameter and inputs to your pseudo debugger console application, inside your app you can access the past arguments or parameter via the args[] parameter, just like any other command line arguments,  the input data from windbg can be accessed via the std io input stream.

Let’s say that you want to create a debugger extension that groups the top n frames on every thread and report back the results.

Read more: Tepache Debug

Posted via email from jasper22's posterous

The Return of the Class Wizard - Pavel's Blog - Sent using Google Toolbar

    Visual C++ 6 aficionados remember (fondly) the Class Wizard, most useful in MFC applications. The Class Wizard has gone away in later version of Visual Studio (2002, 2003, 2005, 2008), but is now making a smashing return in Visual Studio 2010 (Project menu –> Class Wizard or Ctrl+Shift+X).

image


Read more: Pavel's Blog

Posted via email from jasper22's posterous

Did you know about "Block Replace" in Visual Studio 2010 ?

Today is the second day of Diduary. You can see links to all of the published articles in the series here.

You may or may not have been aware that in Visual Studio, you have the ability to select blocks of text. I'm not talking about lines of text, or certain characters...you can do that in nearly any text editor.

Block select is that thing that you always wish for when you're working on an HTML or XML document (or really any formatted text), and perhaps you want to delete the same attribute from 10 different lines.


Read more: Jeff Blankenburg

Posted via email from jasper22's posterous

.NET Gem Fun

RubyGems is great for sharing Ruby code libraries.

Just for fun, I thought I’d play with the idea of using rubygems for packaging up .NET libraries. After a few hours of messing about, I finally have this.

$ gem search nhib -d

*** LOCAL GEMS ***

dotnet-nhibernate (2.1.2)
   Authors: ayenderahien, fabiomaulo, karlchu, sbohlen
   Homepage: http://nhforge.org
   Installed at: /Users/apple/.gem/ruby/1.8

   .NET port of the excellent Java Hibernate which provides
   Object/Relational mapping to persist objects in a relational
   database.

My dotnet-nhibernate gem is really simple; all it does is download the correct nhibernate zip from sourceforge and unpack it somewhere sensible.

Read more: tobin harris

Posted via email from jasper22's posterous

S#arp Architecture

Pronounced "Sharp Architecture," this is a solid architectural foundation for rapidly building maintainable web applications leveraging the ASP.NET MVC framework with NHibernate. The primary advantage to be sought in using any architectural framework is to decrease the code one has to write while increasing the quality of the end product. A framework should enable developers to spend little time on infrastructure details while allowing them to focus their attentions on the domain and user experience. Accordingly, S#arp Architecture adheres to the following key principles:

   * Focused on Domain Driven Design
   * Loosely coupled
   * Preconfigured Infrastructure
   * Open Ended Presentation

Read more: Sharp Architecture

Posted via email from jasper22's posterous

Packaging UI Components in MVC

Something I get asked by most customers starting out with ASP.NET MVC is how they should package, group, factor, and reuse their UI components. We're all used to thinking about User Controls, Custom Controls, and other Web Forms approaches. But rest assured, MVC provides a wealth of options.

The thoughts below describe how I see each of these options being put to best use. That doesn't mean the guidelines below are completely concrete (or indeed complete) – but they should get you thinking along the right lines initially.

If you've thoughts to add please do shout up!
Custom Rendering Extensions

Rendering extensions are Extension Methods applied to the HtmlHelper class so that they can be used in views to output clean HTML. They are best used for packaging reusable pieces of HTML found across a site. Often they're reusable across multiple web sites.


Read more: Simon Ince's Blog

Posted via email from jasper22's posterous

Common Compiler Infrastructure - Contrib

Project Description
The Common Compiler Infrastructure (CCI) is a set of libraries that provide some of the functionality that compilers and related programming tools tend to have in common.
This project will provide utility classes and things to provide features missing from the original project.

Read more: Codeplex

Posted via email from jasper22's posterous

MSBuild tasks for Subversion

MSBuild tasks for Subversion allows to manipulate with subversion's repositories and working copies.

Note: Project still in development.

Read more: Codeplex

Posted via email from jasper22's posterous