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

.NET

  1. Quick Tip: Cast DataItem in ListView to Business Object — So this is one of those things that has slipped past me for all these months and now that I’ve discovered it, I can’t believe I went without it. I recently found out that I can access a business object in the ItemDataBound event of a ListView which makes it way easier to do some last minute control changing (such as binding labels or hyperlinks, etc.)...
  2. Building Line of Business Applications with LINQ to SQL — The LINQ framework offers a basic pattern of sequence operators, allowing for primitive behavior such as filtering, grouping, and joining over collections and types. The support of the high level query comprehension syntax in C# 3.0 is paramount to developing an application quickly and allows for transparent development practices for developers where querying an in-memory collection or a remote database works the same...
  3. Iterator Blocks Part Seven: Why no anonymous iterators? — It would be totally awesome to be able to build yourself a little sequence generator in-place that closed over local variables. The reason why not is straightforward: the benefits don't outweigh the costs. The awesomeness of making sequence generators in-place is actually pretty small in the grand scheme of things and nominal methods do the job well enough in most scenarios. So the benefits are not that compelling...

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

27.08.2009

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

.NET

  1. Extend OpenFileDialog and SaveFileDialog the easy way — If you used WinForms, chances are that at some point you wanted to extend the OpenFileDialog or SaveFileDialog, but you gave up because there is no easy way to do it, especially if you wanted to add some new graphical elements. Even in the MFC days, such a task was not as daunting as it is for .NET because these classes are sealed, exposing only 16 properties, 5 methods and 3 events that can be used to customize the dialogs. Martin Parry's article on MSDN can give you an insight into how you can customize the OpenFileDialog using the OFNHookProc function and PInvoke...
  2. Introducing LazyLinq: Queryability — Before we try to query ILazyQueryable, it’s instructive to look at how System.Linq.Queryable works. There are essentially three types of operators on IQueryable...

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

23.08.2009

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

.NET

  1. How to Fill a ListBox/DropDownList from an Enum — There was a question about this on the Asp.Net forums and after a quick search I didn't find a good generic function so I thought I'd supply one...
  2. LINQ to Ducks – Bringing Back The Duck-Typed foreach Statement To LINQ — I promise, it will be a (relatively) short post this time. You all know the foreach statement in C#, don’t you? Think twice before you answer and tell me exactly how the following works...
  3. Why all .NET developers need a memory profiler ! — It is one of the dirty secrets of software development: the number of memory leaks that find their way into production code. Memory leaks are a special category of bug because they can easily go unnoticed. The user's perspective is that they start work using your application and everything is fine. If it is an application that is used lightly, maybe run once every morning to create a report, than everything is fine for ever. If it is a long-running application then eventually it will cause problems, though the user may not know which bit of software is to blame. Since Windows rarely runs out of memory, the user might just notice everything slowing down...
  4. A total n00b’s guide to migrating from a custom data layer to Nhibernate: so many choices — One of the great things about NHibernate is its vibrant community and ecosystem. So many people are using it or building other libraries on top of it that you can be pretty sure that there is always a reasonable solution to any problem you might face...

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

20.08.2009

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

.NET

  1. StringBuilderPlus Improves Upon StringBuilder — The above image shows that to concatenate about 40,000 strings in C# takes about 3 seconds. With the StringBuilderPlus, you can concatenate those same strings about a hundred times faster (or, 1/30th of a second). The experienced developer will note that StringBuilder can do this too, but there are a few weaknesses in StringBuilder that many people don't know about (skip to the "Problem" section to read more about that). StringBuilderPlus remedies those, as explained below, in the "Solution" section of the article...
  2. TestDriven.Net 2.23 Beta – Faster! — It turns out that the JIT compiler for x64 is considerably slower than for x86 (and uses more memory). You can easily improve the startup time for your EXE projects by changing them to compile for x86. In fact this is what Microsoft is doing in Visual Studio 2010 (the default for EXEs will be x86). It’s only worth compiling EXEs for AnyCPU if your application might use a lot of memory. See Rick Byers’ post on the subject: AnyCPU Exes are usually more trouble than they're worth...
  3. TestDriven.Net 2.23 Beta – Cleaner Stack Traces — You have probably noticed with previous versions of TestDriven.Net, stack traces could turn into an unruly mess of file path information...
  4. LINQ Tip of the week: LINQ and Anonymous types — Consider the case where we want to obtain a subset of data instead of an entire persistent instance. For example, if we want to obtain the contact details of all Customers based in London we would use the following query...
  5. Simplifying enumeration of Office object model collections with Linq and Extension methods — I found an interesting post on Deborah's Developer MindScape (via Greg’s blog )and wanted to share a modification of the technique that can simplify the use of Office object models in C# and VB. I use this heavily in my VisioAutomation library...

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

16.08.2009

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

.NET

  1. Raising Events, Event Handlers, and the Use of Delegates — When working with an IDE like Visual Studio, most events, particularly those involving Windows Forms applications, are nonlinear. That is, you might have to wait for a user to click a button or press a key to then respond to that event. In server applications, you might have to wait (and listen) for an incoming network request. These capabilities are provided by events in the .NET Framework. Any developer will notice the connection between events and delegates in technical documentation. This article will assume a working knowledge of the .NET Framework 2.0 and Visual Studio 2005 (2008), with the intention of defining both events and delegates...
  2. db4o Object Manager for .NET Improvements — Since the announcement that Object Manager Enterprise would be added to our open source offerings we take the time and a lot of improvements were made: bugs were fixed, code were rewritten and we started to add tests (incipient, but at least we started)...
  3. Statement Trees With Less Pain – Follow-Up on System.Linq.Expressions v4.0 — In my last post, Expression Trees, Take Two – Introducing System.Linq.Expressions v4.0, I showed how to the extensions to the LINQ expression trees API opens up for full-blown statement trees including support for assignment, control flow, etc. One popular question that came up in the comments section is on the lack of language-level support for statement trees...

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

13.08.2009

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

.NET

  1. Creating vCard with image in .Net — vCard is popular format for exchanging contacts. Besides e-mail clients also modern mobile phones are able to read and send contacts as vCard. This posting introduces same ideas how to implement vCard support in your applications and how to add images to vCards...
  2. Interesting LINQ Exercise — A co-worker posed an interesting LINQ problem to me tonight so I figured I’d share. They had a collection of items and wanted an algorithm that would create a “collection of collections” where the first three items would be grouped together, second three items, on so on. For example, given a sequence like this: { “a”, “b”, “c”, “d”, “e”, “f”, “g”, “h” }, it would create a structure that contained 3 groups – the first element would be { “a”, “b”, “c” }, the second would be { “d”, “e”, “f” } and the third { “g”, “h” }. They already had an algorithm working fine but it was using a “brute force” approach and took about 15-20 lines of code. It “felt like” you could solve the same problem more elegantly with a LINQ solution and with less lines of code...
  3. Windows 7 Code Pack V. 1.0 Released — The Windows® API Code Pack for Microsoft® .NET Framework provides support for various features of Windows 7 and previous releases of that operating system. The Code Pack has reached version 1.0 and has been published on Code Gallery...
  4. A Whirlwind Tour through the Managed Extensibility Framework — From a hotel lobby in the sunny city of Durban, South-Africa, waiting for my plane transfer after a great TechEd Africa event. Why not write a blog post on one of my talks: the Managed Extensibility Framework, or MEF. As we steam ahead to release .NET 4.0, it’s great to see the amount of new APIs that will make it into this release. I had the opportunity to talk on three of those the past few days...
  5. Fun With the ?? Operator in C#: if { } or ?? – Which is Faster? — Yesterday evening at work a team member and I were pair programming. We had a disagreement about how to code a few lines. The question was around whether to use the ?? operator or to use an if statement using String.IsNullOrEmpty. We settled it like most developers do and that is with a benchmark...

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

09.08.2009

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

.NET

  1. StackOverflow answer – why learn multi-core programming? #2 — In my last post I talked about how multi-threading can be used to improve responsiveness while loading a file. I’ve put together a sample program (source included) that shows how to do this in C# 3.0, .NET 3.5, and WPF using Visual Studio 2008. You can find a zip file with a complete project attached...
  2. Introducing LazyLinq: Overview — This is the first in a series of posts on LazyLinq, a wrapper to support lazy initialization and deferred disposal of a LINQ query context, including LINQ to SQL’s DataContext...
  3. How to create 3 tire application using LINQ — As you know that in 3 tier architecture there are three layers...
  4. Simplistic Object Copying in .NET — In many applications it’s necessary to copy data between objects. Especially these days where we often have entities and Data Transfer Objects (DTO) where data needs to be shuttled back and forth between two objects I find it handy to have a simple routine that performs at least rudimentary, shallow data copying for me without manually having to write data mapping code at least if the properties identically or nearly identically. A few days ago I had a lengthy discussion about this topic on Twitter as well and some suggestions that some sort of data copying mechanism should be built into the .NET framework...
  5. Aspcts of Polymorphism in .NET Parts 1 & 2 – Inheritance — .NET Developers come in various shapes and sizes, not only physically, but also in terms of their expertise and experience. The polymorphic nature of the .NET Framework now allows their code to benefit from similar diversity. Sadly, though, it is entirely possible with .NET languages and tools, such as Visual Studio 2008, for developers to build programs and web sites without necessarily needing to know or understand the underlying complexity of what they are doing. I've come across so-called developers whose approach to solving problems has greatly improved their search engine skills as they scour the internet for code samples they can lift to fix the problem they're currently facing. Sadly, though, their attitude towards actually understanding and getting to grips with the problem domain is one of laziness. For this reason developers can work commercially...
  6. Aspects of Polymorphism in .NET Part 3 - Abstract Classes — Abstraction is at the top level of most things we're familiar with on a day to day basis. In our Ford Focus illustration we were dealing with a concrete instance of an abstract concept - vehicle. Although a person may be said to own a vehicle, it's meaningless without specifying the type of vehicle he or she possesses. For most of us this is a car, but for some it might be a plane, a boat, a bike, a helicopter etc. We then further solidify things by becoming more and more specific about things - what make, model, variation of car we have, for example...
  7. Aspects of Polymorphism in .NET Part 4 - Interfaces — I have often read that Interfaces can be likened to contracts. The thinking behind this analogy is that a class implementing an interface MUST implement ALL of the methods and properties declared by the interface, much the way that an employee MUST carry out all of the responsibilities contained in his contract of employment if he wants to keep his job...

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

06.08.2009

Действительно ли WPF независима от разрешения?

Один из главных заявленных преимуществ WPF это "независимость от разрешения". Зачастую это заявление описывается относительно расплывчато ведущими людьми, чтобы поверить что это значит тоже самое что WPF окно будет отображаться на любом мониторе в одинаковом размере независимо от разрешения которое установлено.

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

16.06.2007

Конвертация векторного формата SVG в разметку WPF XAML

Я хочу написать приложение на WPF, которое требует карту мира, и хотел использовать векторное изображение, чтобы при изменении размера все оставалось красиво. Я нашел эту SVG [1] карту мира, и использовал SVG Xamlon to Xaml конвертер для преобразования его в Xaml. После удаления одного паразитного пространства имен, я смог загрузить его в XamlPad. Полученные результаты представлены ниже (SVG версия отображается в программе для рисования векторной графики Inkscape).

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

21.11.2005