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 this far.

Read more

Writing cache based repositories for web application prototyping

When I started building in-house demo application I thought about how to solve temporary data layer so I don’t have to use real database and object mappings for it. Playing with new object model and new components I move way faster if I don’t have any additional ballast that I can avoid. So I wrote simple cache based repository mechanism I can use to imitate real repositories that I will write in the future.

Read more

.Net Framework 4.0: System.IO.File supports now IEnumerable

.Net Framework 4.0 adds also some new and cool features to file system objects. File class has now ReadLines() methods that returns IEnumerable. WriteAllLines() methods has two overload methods that accept IEnumerable instead of strings array that was also supported in previous versions of .Net Framework. This posting introduces ReadLines() and WriteAllLines() methods and gives you some ideas how to use these methods in your applications.

Read more

Optional arguments and named parameters in C#

C# 4.0 supports optional method arguments. Related to this is support for named parameters in function calls. For us it makes easier to use methods which have long argument list. It also introduces some new dangers which may lead us to messy and hard to understand code. In this code I will show how to use optional arguments and give some hints how to avoid messy code.

Read more

Using memory mapped files with C#

.Net Framework 4.0 introduces memory mapped files. Memory mapped files are useful when you need to do in-memory data manipulation and your data structures are large. For large in-memory data the performance of memory mapped file is the best. It is much faster thanMemoryStream. And like files on hard disc, memory mapped files can be shared between different programs. MemoryMappedFile and other classes for memory mapped files can be found from System.IO.MemoryMappedFiles namespace.

Read more