Posts Tagged C#
A Better INotifyPropertyChanged Implementation
Posted by gamlerhart in .NET on November 25, 2009
The INotifyPropertyChanged-interface and companions are a well know citizens of the .NET-framework. How do you implement this interfaces?. Does it look similar to this? public class Person : INotifyPropertyChanged { private string firstname = “”; /* Other fields for the properties */ public event PropertyChangedEventHandler PropertyChanged; public string Firstname { get { return firstname; } [...]
Read complete postLINQ: cast-catch
Posted by gamlerhart in .NET on November 4, 2009
In this post I’ll explain a little catch in LINQ, which may some beginners fall into: What’s the difference between those two queries? IEnumerable<Person> listOfEntities = LoadData(); // First version of the query var resultV1 = from p in listOfEntities where p.Name.Contains("a") select p; // Second version of the query var resultV2 = from Person [...]
Read complete postSoap & Skin, My Pal Satan, Erlang and nullptr
Posted by gamlerhart in Media Zap Oh Snap, channel 9 on November 1, 2009
My Pal Satan is a little comedy web-series about a Donna and her roommate, Satan. However there are only six episodes =( On infoq.com a talk from Joe Armstrong about fault-tolerant systems and Erlang is avaible. Maybe this doesn’t affect many developers today, but I think in the future more and more systems need some [...]
Read complete postBrian Beckman and Erik Meijer: Reactive Framework
Posted by gamlerhart in .NET, channel 9, people on July 15, 2009
This wonderful talk with Erik Meijer and Brian Beckman about reactive programming was published recently on channel 9. It starts of with simple and familiar things, the IEnumerable-Interface (or Iterable in Java). Then comes a little math, explained with a wild mix of Haskell, C# and fictional programming languages. And at the end the circle [...]
Read complete postMocks for internal interfaces
Posted by gamlerhart in .NET, software-development on May 7, 2009
Maybe you’ve already seen an exception like this: Castle.DynamicProxy.Generators.GeneratorException: Type is not public, so a proxy cannot be generated. Type: SpielWiese.IReportSender …stack-trace… at SpielWiese.TestSomething.ExpectReportsSend() in Program.cs: line 64 What I’ve tried is to create a mock-object with Rhino-Mock. Since this interface is only intended for usage within the assembly it’s declared as internal interface. So [...]
Read complete postArgument Validation Utility
Posted by gamlerhart in .NET, software-development on April 27, 2009
A while ago I’ve found a nice way to implement argument validation on the Paint.Net-blog. Its a fluent-interface like this: public void CallMe(object sender,int size, string name) { Validate.Begin() .IsType<Guid>(sender, “sender”) .BiggerThan(size, 0, “size”) .IsNotEmpty(name, “name”) .Check(); /*IMPL */ } If only condition fails, CallMe(Guid.NewGuid(), 2, “”); you get a normal exception: System.ArgumentException: The argument [...]
Read complete postWhy I can’t wait to get dynamic in C#
Posted by gamlerhart in .NET, software-development on April 21, 2009
Just wrote again really ugly reflection based code. In such moments I really wish that the ‘dynamic’-type is already here. I wanted to make this statement, but replace the MyServiceResolvedAtRuntime and ArgumentTypeResolvedAtRuntime with type I only know at runtime. private static void BuildArgumentProvider(ContainerBuilder builder) { builder.Register<Provider<MyServiceResolvedAtRuntime, ArgumentTypeResolvedAtRuntime>>( ctx => argument => ctx.Resolve<MyServiceResolvedAtRuntime>(new[] { new NamedPropertyParameter(“param”, [...]
Read complete postdb4o object database
Posted by gamlerhart in .NET, software-development on April 16, 2009
I’ve looked for a small embedded, easy to use data store for implementing my small software-engineering course project. Of course I’ve looked at MS SQL Server, which works great together with LINQ and the .NET world. However it isn’t small and lightweight. I’ve also tried Hibernate.NET, however the .NET version is way behind the Java-Version [...]
Read complete postFxCop
Posted by gamlerhart in .NET, software-development on February 18, 2009
I’m a fan of static analysis because whem I’m writing code in a statically typed language I want to get the most of it. So I’m a huge fan of IntelliJ IDEA’s code analysis and quick-fixes. Also FindBugs is useful and also open source. Of course there are even more sophisticated analyses, but it catches [...]
Read complete post