Полезные ссылки (01.04.2010)

.NET

  1. Some Last-Minute New C# 4.0 Features — As I’m sure you know by now, we are done implementing C# 4. We’ve added support for interoperability with dynamic languages and legacy object models, named and optional parameters, the ability to “link” against interfaces from a Primary Interop Assembly, and my favourite feature, covariance and contravariance of interface and delegate types...
  2. Simplify Your Code with LINQ — I’m a big fan of LINQ and use it wherever I can to minimize code and make applications easier to maintain overall. I was going through a code file today refactoring it based on suggestions provided by Resharper and came across the following method...
  3. A C# implementation of the CallStream pattern — Dusan published this interesting post a couple of weeks ago about a novel JavaScript chaining pattern...
  4. LINQ: Single vs. First — I’ve witnessed and been involved in several discussions around the correctness or usefulness of the Single method in the LINQ API...

Читать полностью »

01.04.2010

Полезные ссылки (28.03.2010)

.NET

  1. Updated the CsvFileTester for Jet 4.0 — I was playing around building a tool to let me edit a database table in Excel, so I updated my CvsFileTester...
  2. Compare two XML Files using .Net — Many cases we need to validate staging and production data. Mostly the client have send only XML files(production) and we have to validate our end output(staging).In this tool, we Validate the schema and compare the datas...
  3. Adding the ForEach(Action) to IEnumerable — I return the original IEnumerable object to add 'chaining', something you can remove (i.e. void) if this capability is not required...

Читать полностью »

28.03.2010

Полезные ссылки (21.03.2010)

.NET

  1. Events get a little overhaul in C# 4, Part III: Breaking Changes — Now I’m here to tell you about some more in-your-face breaks that are a lot less subtle, and related to the binding change for += and -=. My hope is that anyone who actually sees these breaks will find this post and learn how to fix them. Let’s go...
  2. How to use String.Format in PowerShell? — Check out Formatting Types on the .NET Framework Developer's Guide or SteveX Compiled - String Formatting in C# (nice cheat sheet) for more examples...
  3. C# with keyword equivalent — There’s no with keyword in C#, like Visual Basic. So you end up writing code like this...
  4. Do not name a class the same as its namespace, Part Three — The reason we humans invented hierarchies in the first place is to organize a complicated body of stuff such that there’s a well-defined place for everything. Any time you see a hierarchy where there are two levels with the same name, something is messed up in the design of that hierarchy...
  5. Do not name a class the same as its namespace, Part Four — I said earlier that the fundamental reason for namespaces in the first place was organization of types into a hierarchy, not separation of two things with similar names. But suppose you are putting something into a namespace because you have two things that are of the same name and need to be kept separate...
  6. Convert Xml tree to a string quickly using .NET framework. — In web service enviroment, it is often necessary to convert the Xml tree to a string in order to calculate the hash or digital signature. NET framework provides several classes to parse XML document, each one has its own strength, here we investigate the difference of performance between them on my laptop. XmlUTF8TextReader is created using XmlDictionary.CreateTextReader() method with XmlReader interface. For XElement and XDocument...
  7. LINQ to Object Part #4: Querying Non- IEnumerable collections — In this article, I am going to show, how we could apply LINQ to query non-IEnumerable Collections...

Читать полностью »

21.03.2010

Полезные ссылки (14.03.2010)

.NET

  1. SQL Style Extensions for C# — Now you can use your favourite SQL functions inside C#, with the amazing new "SQL Style Extensions" class...
  2. Using PowerShell to demo PowerShell via PowerShellPoint! (aka “PowerPoint for PowerShell’ers…” or “We don’t need no stink’n PowerPoint to present PowerShell!”) — As I worked out my demos, I still needed to have some PowerPoint slides to point out key concepts and things like URLs. As I was putting the slides together something was bothering me. Why was I using PowerPoint? I'm going to be a session on PowerShell. Shouldn't I be using PowerShell? The first rule of the PowerShell club is to use PowerShell! That's the second rule as well...
  3. Strengthening your domain: Encapsulated collections — One of the common themes throughout the DDD book is that much of the nuts and bolts of structural domain-driven design is just plain good use of object-oriented programming. This is certainly true, but DDD adds some direction to OOP, along with roles, stereotypes and patterns. Much of the direction for building entities at the class level can, and should, come from test-driven development. TDD is a great tool for building OO systems...
  4. .Net, Native, P/Invoke marshaling just like magic… “Marshaling with C# Pocket Reference” (Think “Marshalling Guide for the Busy Dev Guy”) — I hate to say it, but I kind of suck at writing P/Invoke code. I just don’t do it enough, so end up cutting-n-pasting a good deal. sigh… I’ve been on the look out for a good Marshalling Guide for the Busy Dev Guy Guide...
  5. Do not name a class the same as its namespace, Part One — The Framework Design Guidelines say in section 3.4 “do not use the same name for a namespace and a type in that namespace”...
  6. Do not name a class the same as its namespace, Part Two — You take this code and run a third-party “decorator” tool over it that makes your class into a more colourful class...
  7. WPF and Text Blurriness, now with complete Clarity — The #1 complaint I hear about WPF (Windows Presentation Foundation) is that many fonts end up looking "blurry." It's a darned shame because really great applications like Evernote get criticized because of this one issue...
  8. LINQ to Object Part #2: Filtering and Sorting — I have created two classes for explanation purposes, Student and Hostel. The Student class has details about a student and the Hostel class has details about a hostel. Both classes have the property HostelNumber in common. I will be using this property to perform join operations in later articles. Both classes are shown below...

Читать полностью »

14.03.2010

Полезные ссылки (28.02.2010)

.NET

  1. Insert xml string into XmlDocument
  2. Thou Shalt not Iterate! : Part 1 — LINQ as we all know provides intrinsic data querying capabilities to the framework languages supporting LINQ. Going forward its an obvious way to code clean, and with growing number of LINQ providers (LINQ to SQL, LINQ to Entities, LINQ to XML, LINQ for Maps, and not to forget DryadLinq and pLinq for us Cloudy folks’ Parallel Computing needs, and so on) it looks to be the de facto standard for querying within dotnet framework languages...
  3. How to implement paging with LINQ — With large amounts of data, it is not a good practice to pull all records from database when you are showing a fraction of them in one page. It is always recommended to use data on demand approach...
  4. LINQ to XML Part 1 - XAttribute Class — In this article, I will give explanation on XAttribute class. This class is used to construct Attributes in XML Elements. After completing this article, you will learn the purpose of XAttribute class and how to use it in LINQ to SQL...
  5. LINQ to XML Part 4: Different way of Parsing string to create XML tree — In this article, I will show different way of parsing string to create XML tree using LINQ to XML...
  6. LINQ to XML Part 5: Catching Parsing Exceptions — This is a very high level article which will explain; how to handle exception in parsing XML using LINQ to XML...

Читать полностью »

28.02.2010

Полезные ссылки (21.02.2010)

.NET

  1. Excel Open XML & LINQ Part I — In the next few posts I'll roll out a little project for Excel that uses Open XML and LINQ. The scenario for this little Office solution has to do with my massive collection of music. I've collected over 1000 albums of music both from ...
  2. 60+ .NET libraries every developer should know about. — Every good developer knows never to re-invent the wheel, especially if there is software out there that has been tested by others, and has an established track record. As a developer using the .NET framework I’ve found some of these libraries invaluable, so I’m sharing them for some of the other dev’s out there with a brief outline of how to use...
  3. Linq Distinct and Custom Object Sort — The main purpose of this post is to show what's required in the main 3 .net languages for filtering and sorting.
    I decided to put these two problems together because they presented themselves to me simultaneously...

Читать полностью »

21.02.2010

Полезные ссылки (16.02.2010)

.NET

  1. Rollup Extension Method: Create Running Totals using LINQ to Objects — Recently, I had need for a new extension method for IEnumerable, which I call "Rollup". This extension method is sort of a cross between the Select and Aggregate extension methods. Like Select, when using this extension method you write a lambda expression to project the new value in a new collection. Unlike Select, in the projection lambda expression, you are passed the projected value for the immediately preceding element...
  2. LINQ: ToLookup vs ToDictionary — Some people are not sure of the difference between ToLookup vs ToDictionary LINQ methods...
  3. Architect 3 : Building Data Access Layer Using Microsoft Enterprise Library 4.1 — You have a Customer table with three fields: ID, LastName and FirstName. You are building a data access layer to retrieve all the records from the Customer table and return the result as a collection of Customer objects...
  4. Extension methods as default interface method implementations — One of my comments in the 2nd edition of the .NET Framework design guidelines (on page 164) was that you can use extension methods as a way of getting default implementations for interface methods. We've actually begun using these techniques here on my team...
  5. Tip 10 : Returning the first part of a string with delimiter — You have a string delimited by underscore such as 1stPart_2ndPart_3rdPart and want to return the first part of the string only...
  6. Windows PowerShell Quick Reference Guide Updated — Quick reference guide to commonly-used Windows PowerShell commands. For best results, open the file in Microsoft Word, print the contents to legal-sized paper (8 inches by 14 inches), and fold the resulting printout in half, making a four-page booklet...
  7. Enumerate Enum flags — produces a list of the selected flags in an enum that was built using [Flags]...

Читать полностью »

16.02.2010

Полезные ссылки (07.02.2010)

.NET

  1. Json in .NET — I use Json all the time, but I feel like its super annoying in .NET. Typically Id call some web service that returns Json. In .NET it seems like the best thing to is to define a data contract and use the DataContractSerializer...
  2. Performance: Using LCG to copy property values of two objects — Today I gave last performance boost to my property values copying mechanism. I would like to thank my readers Ron and David to remind me Lightweight Code Generation (LCG) and pointing me out aussie bloke blog entry Generic copy object using Lightweight Code Generation. In this posting I will show you last performance boost and put down a summary about my experiment...

Читать полностью »

07.02.2010

Полезные ссылки (04.02.2010)

.NET

  1. Back to Basics - Keep it Simple and Develop Your Sense of Smell - From Linq To CSV — I spoke to my friend and they said it was cool to share their code for this post. This post isn't meant to be a WTF or OMG look at that code, as is it meant to talk about some of the underlying issues. There's few things going on here and it's not all their fault, but it smells...
  2. Hanselminutes Podcast 198 - Reactive Extensions for .NET (Rx) with Erik Meijer — My one-hundred-and-ninety-eighth podcast is up. I sit down with Erik Meijer from the Cloud Programmability Team to hear about the Reactive Extensions for .NET (Rx). Rx is a library for composing asynchronous and event-based programs using observable collections. Sound boring? Not even a little. Rx is a prescription for awesome...
  3. Some Better-Written Custom String Methods using C# — In my daily web-surfing, I often stumble upon snippets of C# code posted by people. Usually, I can tweak it a bit. Sometimes, I can tweak it a lot. I usually post a quick comment to the site offering it. Today, I came upon some code that was so bad --- which the author said was from his forthcoming book! --- more drastic measures must be taken...
  4. Difference is comparison when using equals method or Double Equal to operator — There are normally two ways to compare 2 objects. One by using == operator and by using the equals method. But these two are not same in the way they implements the comparison...
  5. Style follows semantics — To me, this comes down to the question “is Bar useful solely for obtaining its value, or also for its side effects?” The stylistic choices should typically be driven by a desire to clearly communicate the semantics of the program fragment...

Читать полностью »

04.02.2010

Полезные ссылки (31.01.2010)

.NET

  1. Sample Reflection.Emit code for using exception filters from C# — In this post, I mentioned that one way to use exception filters from C# code is to generate them with Reflection.Emit. Personally I usually prefer static compilation (even post-build assembly merging or rewriting) – there’s really nothing here that necessitates dynamic code generation, but I can understand the desire to avoid complicating the build process...
  2. Custom String Methods using C# — Below are some custom string methods for C# that are found in VB.NET and various scripting languages: PCase, Replace, ToSingleSpace, CharCount, Reverse, Left, Right, and IsPalindrome. These methods are useful in common string operations. Since the .NET Framewrk does not natively ...
  3. String List of enum Names — Code snippet showing how to populate a List of enum names using LINQ...
  4. Playing With LINQ: Getting Interface Property Implementations — Today, my friend Nuno was writing some code to get the PropertyInfos of a class implementation of an interface...
  5. The beauty of C# and Linq — Today I faced the following challenge to solve: return all possible combinations of three source collections...
  6. Don't Use Try/Catch — Exception handling has been talked about a lot over the last decade and a half. However, despite a general consensus on how to properly handle exceptions, a divide on usage continues to exist. Improper exception handling is easy to spot, easy to avoid, and is a simple code (and developer) quality metric. I know absolute rules come off as close minded or exaggerated, but as a general rule...
  7. Extension Methods on Types You Own? — It’s no secret that I’m a fan of using extension methods to make code more concise and expressive. This is particularly handy for enhancing APIs outside of your control, from the base class library to ASP.NET MVC and SharePoint...

Читать полностью »

31.01.2010