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

.NET

  1. D.C. and the Wrapper Factory — A while ago I wrote about using reflection for testing non-public members. Since then I've been increasingly annoyed by the repetitive nature of that approach. At some point it occurred to me that it should be possible to automate the mundane and boring task of writing the same kind of reflection code over and over again. However, there are two options for code generation each with some severe disadvantages. You can generate source code which means coupling the solution to a particular programming language and build system...
  2. Selecting Static Results with Dynamic LINQ — Dynamic LINQ (DLINQ) is a LINQ extension provided in the VS 2008 Samples. Scott Guthrie provides a good overview here: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library), but the executive summary is that it implements certain query operations on IQueryable (the non-generic variety)...
  3. Quick Tip: Parse String to Nullable Value — When you’re dealing with a system like SharePoint that returns most data as strings, it’s common to want to parse the data back into a useful numeric format. The .NET framework offers several options to achieve this, namely the static methods on System.Convert and the static Parse() methods on the various value types. However, these are limited in that they turn null...
  4. Community Links LVIII
  5. RTM’d today: CLR via C#, Third Edition

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

24.01.2010

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

.NET

  1. What’s the difference between a destructor and a finalizer? — Both are mechanisms for cleaning up a resource when it is no longer in use. When I was asked this, at first I didn’t think there was a difference. But some Wikipedia searches turned up a difference; the term “destructor” is typically used to mean a deterministically-invoked cleanup, whereas a “finalizer” runs when the garbage collector says to run it...
  2. Constructor over-injection anti-pattern — I’m interested in structure. We hear lots of talk about convention over configuration. I’m all for structure over convention (over configuration). This post is about laying out some code that is an anti-pattern. It uses 100% constructor injection. This code makes it easy for a container to bootstrap the construction of the objects...
  3. Constructor over-injection smell – follow up — Constructor over-injection, therefore, is a code smell, I believe. Without concrete do’s and don’ts, I believe it doesn’t deserve the explicit title of “anti-pattern”...
  4. Extension Method String.Reverse
  5. How to create a simple Extension method — ...How to create a simple Extension method. A simple example.Imagine for example the following scenario. You have an assembly created by someone else. This assembly contains a class called Products, this class has a field for the ProductName and for the ProductPrice

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

21.01.2010

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

.NET

  1. Replace Foreach with LINQ — One of the best ways to start Thinqing in LINQ is to find places where you can replace iterative loops with LINQ queries. This won’t necessarily make your applications any faster at the moment, but by taking advantage of the declarative syntax, it will allow you to change your underlying implementation (ie. parallelize it with PLINQ) easier in the future. Recently, I came across some code that mimicked creating a control array as we used to have in VB6 by iterating over a list of fields and adding controls to a form adding the index to the end of the field name. As the fields are being added,we hook up event listeners along the way...
  2. Making Your Own 8K Homegrown Inversion of Control Container — If you develop software, chances are you you've worked with Inversion of Control containers and the Dependency Injection pattern. Many frameworks exist to address how to marry concrete implementations to abstract classes and interfaces...

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

17.01.2010

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

.NET

  1. Quick Tip: Embedding and Accessing Schemas in .NET — I have a project I'm working on that requires the use of some extensive XML manipulation. While XML can be very powerful, XML without a schema is like JavaScript objects: no strong typing and the wild west as far as standards are concerned. A good, solid XML document will have a valid schema to validate against...
  2. Continuing to an outer loop — When you have a nested loop, sometimes you want to “continue” the outer loop, not the inner loop. For example, here we have a sequence of criteria and a sequence of items, and we wish to determine if there is any item which matches every criterion...
  3. 16 Ways To Create IObservables without implementing IObservable — The Reactive Extensions for .Net offers plenty of ways to create IObservables...
  4. Why Can't I Access A Protected Member From A Derived Class? Part Six — Reader Jesse McGrew asks an excellent follow-up question to my 2005 post about why you cannot access a protected member from a derived class. (You probably want to re-read that post in order to make sense of this one.)...
  5. Building custom LINQ expressions made easy with DynamicQueryable. — A colleague of mine recently called me out on the fact that I haven't blogged in … oh about a year and a half. Well it’s 2010 now and resolution season is in full swing so here’s my attempt at getting back on the ball (no promises though)...

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

14.01.2010

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

.NET

  1. Getting Last Quarter end and Next Quarter End Extension methods — I wrote these utility extension methods to get the previous quarter end/month end and next quarter end/month end values for Financial calculations...
  2. How to get out of the GAC all the registered assemblies — You know how annoying the GAC shell extension makes it to access the actual assemblies...
  3. Simplified Many-To-Many Relationships with LINQ to SQL — Common questions when learning LINQ to SQL revolve around many-to-many relationships. This post will describe a scenario that needs queries across many-to-many relationships, show the data and the LINQ to SQL representation of that data, explain the query, and finally output the results...

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

10.01.2010

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

.NET

  1. More LINQ with System.Interactive – Functional fun and taming side-effects — Being rooted in query comprehensions as seen in various functional programming languages (including (the) pure one(s)), one would expect LINQ to have a very functional basis. Indeed it has, but being hosted in various not functionally pure languages like C# and Visual Basic, odds are off reasoning about side-effects in a meaningful and doable manner. As we’ve seen before, when talking about the Do and Run operators, it’s perfectly possible for a query to exhibit side-effects during iteration. You don’t even have to look that far, since every lambda passed to a query operator is an opportunity of introducing effects. The delayed execution nature of LINQ queries makes that those effects appear at the point of query execution. So far, nothing new...
  2. Serializing ArrayLists of Disparate Objects to XML Strings — Since then, while reading a book about XML, I learned of even more power in the .Net XML Serialization libraries*. In addition to serializing objects and collections of objects you can serialize ArrayLists which can contain disparate or non-homogeneous objects. Techno-babble translation: Disparate and non-homogenous mean 'different'...

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

07.01.2010

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

.NET

  1. Streaming OLAP with the Reactive Extensions (RX) for .Net — Streaming OLAP is something that comes up over and over again in the “CEP space” – using the Reactive Extensions for .Net this demo shows the basics; filtering, grouping, aggregates, and concurrent queries...
  2. More LINQ with System.Interactive – Sequences under construction — In order to perform operations over sequences using various combinators and operators, it’s obviously a prerequisite to have such sequences available. While collection types in the .NET Framework implement IEnumerable (or the non-generic counterpart, bridgeable to LINQ using the Cast Standard Query Operator), one often wants to construct sequences on the spot. Moreover, sequences often should have a lazy nature as their persistence in memory may be problematic or infeasible (infinite sequences). For all those reasons, constructor operators come in handy...
  3. More LINQ with System.Interactive – Exploiting the code = data relationship — Code and data are very similar animals, much more similar than you may expect them to be. We can approach this observation from two different angles, one being a machine-centric view. Today’s computers are realizations of von Neumann machines where instructions and data are treated on the same footage from a memory storage point of view. While this is very useful, it’s also the source of various security-related headaches such as script or SQL injection and data execution through e.g. stack overruns (Data Execution Prevention is one mitigation)...
  4. More LINQ with System.Interactive – More combinators for your Swiss Army Knife — Combinators are at the heart of LINQ’s expressive power, allowing sequences to be combined into new ones. In earlier posts, I’ve shown the essence of monadic computation through the following illustration...
  5. The Essence of LINQ – MinLINQ — Before reaching the catharsis in the “More LINQ with System.Interactive” series over here, I wanted to ensure a solid understanding of the essence of LINQ in my reader base. Often people forget the true essence of a technology due to the large number of auxiliary frameworks and extensions that are being provided. Or worse, sometimes a sense for the essence never materialized...
  6. LINQSQO v4.0 and MinLINQ v1.0 Now Available for Download — Introduced in my previous blog post on The Essence of LINQ – MinLINQ, the first release of this project is now available for reference at the LINQSQO CodePlex website at http://linqsqo.codeplex.com. Compared to the write-up over here in my previous post, there are a few small differences and caveats...
  7. The IDisposable Dispose Pattern — This is a full sample of a mostly safe way to implement IDisposable in C# (or .NET in general). The Finalizer method should make up for clients that forget to call Dispose(). Dispose() should always be re-entrant and should only do the work it is required...
  8. GridView using LINQ and Convert datetime to shortdate in LINQ. — In this article you will learn how to create a hyperlink in GridView using LINQ and Convert datetime to shortdate in LINQ...
  9. Covert color to Hex using C# — So you want convert a .NET color to hex or a hex color to .NET color. Well, its very easy to do this. We won’t have to write lots of code or a special class for it. Thanks to ColorTranslator class. We can convert between these with only 1 line of code. Here’s how its done...
  10. LINQ to XML with Hierarchical XML, Optional Elements, and Namespaces — Recently I had an interesting task to consume a particular XML document and populate a C# object from it. The structure of the XML document looked roughly like this...
  11. Fewer smaller .Net DLLs vs less large DLLs — Generally speaking it is better to have less large DLLs versus many smaller DLLs for the following reasons...

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

03.01.2010

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

.NET

  1. Sort List and use Array.ForEach()
  2. LINQ Part 2 – LINQ for XML — Now that we’ve got some basics of LINQ for XML. I think we should also look into group by queries in LINQ for XML. My motivation here would be to find the total price of books for each of the genre. For this, I should write LINQ something similar to this below...
  3. LINQ Part 3 – LINQ for SQL — Now that we have some basics for LINQ for XML. Lets get deep into some using LINQ against Relational databases, aggregate functions, like group by and sort. The database we will be using is books, this can be obtained from this page. Once you download the database, mount it in SQL Server by attaching this mdf file. Once the mdf file is mounted, we can start with the following steps to do our first LINQ to SQL console program...
  4. Using LINQ and reflection to find matching properties of objects — As a side product of some experiments I wrote simple LINQ query that matches properties of two objects and returns these properties as list. The code I wrote is pretty simple and I packed it for you as method...
  5. More LINQ with System.Interactive – Getting Started — To get the Reactive Extensions, which include System.Interactive, visit the landing page on DevLabs over here. Downloads are available for .NET Framework 3.5 SP1, .NET Framework 4.0 Beta 2 and Silverlight 3. In this series, I’ll be using the “desktop CLR” distributions from Visual Studio 2008 and Visual Studio 2010...
  6. More LINQ with System.Interactive – The Ultimate Imperative — LINQ can be quite deceptive on a first encounter due to the lazy island it provides in an otherwise eagerly evaluated language like C# and Visual Basic. Simply writing down a query doesn’t cause it to be executed, assuming no eager operators like ToArray, ToList or ToDictionary are used. In fact, the composition of sequences lies at the heart of this since sequences can evaluate lazily, on demand when calling MoveNext on an enumerator. Iterators are a simple means to provide such a sequence, potentially capturing a sea of side-effects interleaved with the act of producing (or “yielding”) values...
  7. More LINQ with System.Interactive – Exceptional Exception Handling — Under regular circumstances, one expects sequences to produce data in response to iteration. However, it’s perfectly possibly for an iterator (or any enumerable object) to throw an exception in response to a MoveNext call. For example...
  8. Strip the last word from a string — A string extension method that strips the last word from the end of a string...
  9. My favorites .Net development toolkits — Rabbit MQ is a scalable message/queue AMQP server with WCF/C# client (free)...

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

27.12.2009

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

.NET

  1. Array.ForEach method — simple example for the Array.ForEach method...
  2. C# Delegates, Anonymous Methods, and Lambda Expressions – O My! — Delegates, anonymous methods, and lambda expressions can be very confusing in .NET. I think this is proven in code like the example below. Which one of the calls to First compiles? Which one returns the answer we are looking for; namely the Customer with the ID 5. The answer, incidentally, is that all six calls to First not only compile, but all find the correct customer and are functionally equivalent. If you are at all confused as to why this is true, this article is for you...
  3. My MonoTouch ebook is out - Build iPhone apps with C# and run on the iPhone — This Wrox Blox is for .NET developers who want to learn to develop for the iPhone with C# using MonoTouch and MonoDevelop on the Mac. The iPhone is the smartphone leader in mindshare and the amount of money spent on applications. This lead in money spent on applications is expected to grow over the next several years. Objective-C is the native language for iPhone development. .NET developers, who work in the largest general area of development frameworks, have looked at iPhone developers...
  4. Effectus: Building UI based on conventions — Each feature have a Presenter (business logic for the feature), a View Model, which is directly bound to the View and is the main way that Presenter has to communicate with the View. The main responsibility of the Model is to be bound to the UI, and allow the presenter to update it, but it is not quite enough...

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

20.12.2009

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

Web

  1. 20 Best jQuery Tips and Tricks Collection — jQuery adds amazing effects to your designs. With the beauty and attraction of animations and effects comes the overhead to speed and performance. A well optimised and efficiently crafted jQuery design can impress result in a lasting effect on the users. Create efficient and optimized jQiuery designs with this collection of jQuery tips and tricks colelction, which is a compendium of several easy ways to generate commonly used efefcts...
  2. soapUI 3.5 beta1 - The Protocol Release
  3. Using setTimeout to Delay Showing Event-Delegation Tooltips — In my last two tutorials, I explained how to use event delegation for showing and hiding tooltips. In a comment on the first one, Jan Aagaard asked how we might go about enhancing the script by adding a small delay before showing a tooltip. The answer lies with two JavaScript functions, setTimeout() and clearTimeout()...
  4. Binding Multiple Events to Reduce Redundancy with Event-Delegation Tooltips — Last time I showed how to use event delegation to create a simple tooltip for a huge number of elements without running into the problem of binding an event handler to all of those elements. In this tutorial, I'm going to refine that tooltip script...
  5. 50+ jQuery Plugins for Form Enhancements — Easy user interaction and data collection is really a key functionality on most websites and web applications. Providing users high quality and intuitive input forms may be just what is needed to make your users take the time to fill in and submit the information you’re trying to collect. In this article I have collected a number of really essential jQuery Form Enhancements. A few cheat sheets have been added as well...
  6. How to parse JSON from C# — WCF is cool because it is very very versatile. It is very well architected. One of the things WCF comes with is very good support for very thin clients, i.e. JavaScript, JSON...
  7. Feature List jQuery Plugin — Feature List requires very simple markup and can be easily styles using CSS. It also offers configuration options for customizing the behavior such as: specifying the default tab; enabling or disabling pause when the mouse hovers over the tabs; and setting transitions delays...
  8. 10 CSS Snippets to Save Precious Time — Today, I have compiled a set of 10 CSS snippets that can save you a lot of time and effort. These codes are needed frequently when developing CSS-based websites or themes. Just bookmark these codes (Ctrl + D) so that you don’t have to look for them on the Internet every time...
  9. A free standing ASP.NET Pager Web Control — Paging in ASP.NET has been relatively easy with stock controls supporting basic paging functionality. However, recently I built an MVC application and one of the things I ran into was that I HAD TO build manual paging support into a few of my pages. Dealing with list controls and rendering markup is easy enough, but doing paging is a little more involved. I ended up with a small but flexible component that can be dropped anywhere. As it turns out the task of creating a semi-generic Pager control for MVC was fairly easily...

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

17.12.2009