.NET

TwitterFacebook
Get flash to fully experience Pearltrees

Beginner's Guide to Reactive Extensions for .NET

http://msdn.microsoft.com/en-us/data/gg577611.aspx This page contains resources to help developers get up to speed with the Reactive Extensions. For additional resources see the Learning Resources page. The following is a series of workshop videos introducing you to the key concepts in Rx. Each video will showcase a concept and present you with a code challenge exercise at the end.
http://lostechies.com/jimmybogard/2008/08/12/enumeration-classes/ A question came up on the ALT.NET message board asking whether Value Objects should be used across service boundaries. Of course, the conversation took several detours, eventually coming to the question, “what do you do about enumerations crossing service boundaries.” I’m still ignoring that question, but I’ve found different ways to represent enums in my model. Now, enums are just fine in lots of scenarios, but quite poor in others. There are other options I like to use when enumerations break down, and many times in the domain model, I go straight to the other option.

Enumeration classes

A common complaint of the Entity Framework is slow insert times for larger datasets. Last night I was trying to insert a catalog of 15k products and it was taking a very long time (I gave up after 5 minutes). I recalled this post a while back from Mikael Eliasson demonstrating SqlBulkCopy using .NET. I had used BCP in SQL server, but not from .NET. I took Mikael’s example and roughed out a reusable generic version below, which produced 15k inserts in 2.4s or +- 6200 rows per second. I upped it to 4 catalogs, 224392 rows in 39s, for +- 5750 rps (changing between 4 files).

Elegant Code » SqlBulkCopy for Generic List<T> (useful for Entity Framework & NHibernate)

http://elegantcode.com/2012/01/26/sqlbulkcopy-for-generic-listt-useful-for-entity-framework-nhibernate/

VerifyArgs

VerifyArgs is a lightweight, fast and extensible library for method arguments value checks. It's written in C# 4.0 and can be used in .NET FW 4+ and Silverlight 4+ applications. VerifyArgs contains Verify class which can be used to validate arguments of your method: public string MyConcat( string first, string second, int secondCount) { Verify.Args( new { first, second }).NotNull().NotEmpty(); Verify.Args( new { secondCount }).Positive(); // your code } This code ensures that "first" and "second" arguments are not null/empty and "secondCount" is greater than zero. https://verifyargs.codeplex.com/
Introduced in the Effective Test Series , the Expected Object pattern is a technique involving the encapsulation of test-specific logic within a specialized type designed to compare its configured state against that of another object. Use of the Expected Object pattern eliminates the need to encumber system objects with test-specific equality behavior, helps to reduce test code duplication and can aid in expressing the logical intent of automated tests. While the Expected Object pattern is a great strategy for helping adhere to good testing practices, the process of actually implementing the required types can be less than motivating. To alleviate the burden of hand-rolling Expected Object types, I created the Expected Objects library. This library provides the ability to compare the state of one object against another without relying upon the provided type’s equality members.

Introducing the Expected Objects Library | Aspiring Craftsman

http://lostechies.com/derekgreer/2011/06/28/introducing-the-expected-objects-library/
The DebuggerDisplayAttribute is a powerful way to customize the way values are displayed at debug time. Instead of getting a simple type name display, interesting fields, properties or even custom strings can be surfaced to the user in useful combinations [ DebuggerDisplay ( "Student: {FirstName} {LastName}" )] public sealed class Student { public string FirstName { get ; set ; } public string LastName { get ; set ; } } The DebuggerDisplay attribute can customize the name, value and type columns in the debugger window. Each one can be customized using a string which can contain constant text or expressions to be be evaluated by the expression evaluator.

Normal Stuff - DebuggerDisplay attribute best practices - jaredpar's WebLog - Site Home - MSDN Blogs

https://blogs.msdn.com/themes/blogs/generic/post.aspx?WeblogApp=jaredpar&y=2011&m=03&d=18&WeblogPostName=debuggerdisplay-attribute-best-practices&GroupKeys=
http://philbolduc.blogspot.com/2010/03/retryable-actions-in-c.html

Retryable actions in C#

Download the Code In inevitably there will be times during the execution of your application where you will encounter an exception. Most common unavoidable types of exceptions are caused when accessing an external resource such as a database or web service. The resource may be known to have occasional expected.

How Duck Typing Benefits C# Developers

http://haacked.com/archive/2007/08/19/why-duck-typing-matters-to-c-developers.aspx David Meyer recently published a .NET class library that enables duck typing (also sometimes incorrectly described as Latent Typing as Ian Griffiths explains in his campaign to disabuse that notion ) for .NET languages. For most dynamic languages, this phrase is slightly inaccurate in describing duck typing. To understand why, let’s take a quick look at what duck typing is about.

Json.NET

https://json.codeplex.com/ LINQ to JSON is good for situations where you are only interested in getting values from JSON, you don't have a class to serialize or deserialize to, or the JSON is radically different from your class and you need to manually read and write from your objects. Json.NET is a free open source project that I have developed in my personal time. I really appreciate your feedback and support for Json.NET and its future development.

C# 4.0/3.0 in a Nutshell - PredicateBuilder

http://www.albahari.com/nutshell/predicatebuilder.aspx Dynamically Composing Expression Predicates Suppose you want to write a LINQ to SQL or Entity Framework query that implements a keyword-style search. In other words, a query that returns rows whose description contains some or all of a given set of keywords. We can proceed as follows:

JustDecompile - Free .NET Decompiling Tool

JustDecompile is a new, free developer productivity tool for easy .NET assembly browsing and decompiling. JustDecompile builds on Telerik's years of experience in code analysis and developer productivity tools. JustDecompile lets you effortlessly explore and analyze compiled .NET assemblies, decompiling code with the simple click of a button. You can also visit the JustDecompile feature suggestion forum to let us know what features you'd like to see added to JustDecompile, or vote for ones suggested by your peers.
Testing

Some time soon, I want to write about the various Java 7 closures proposals on my blog . However, when I started writing that post I found it was difficult to start off without an introduction to closures. As time went by, the introduction became so long that I feared I'd lose most of my readers before I got to the Java 7 bit. As chapter 5 in the book is largely about anonymous methods and how they provide closures to C#, it seemed appropriate to write this article here. Most articles about closures are written in terms of functional languages, as they tend to support them best. However, that's also precisely why it's useful to have an article written about how they appear more traditional OO languages.

C# in Depth: The Beauty of Closures

Asynchronous Programming

ORM Related

Documentation

The Repository Pattern with Linq to Fluent NHibernate and MySQL | Random Sparks

I have heard a lot of good things about NHibernate, but have never had the opportunity to use it. In this post I will describe how to get started using Fluent NHibernate with Linq to NHibernate using MySQL for a database. To add a bit of concreteness to the design / code, let’s imagine that we need to build out the back-end for a delivery truck management system. The business goal is to strap each truck with internet (3G) GPS radios. The radios will report geo-location tracking information for the truck every 5 minutes.
MVC

algorithm - C# rounding DateTime objects - Stack Overflow

I want to round dates/times to the nearest interval for a charting application. I'd like an extension method signature like follows so that the rounding can be acheived for any level of accuracy: static DateTime Round ( this DateTime date , TimeSpan span ); The idea is that if I pass in a timespan of ten minutes, it will round to the nearest ten minute interval.
WPF - Silverlight