Want to get rid of messy “PropertyChanged”-subscriptions and too many OnPropertyChanged(“…”) to manage value relations? Then DataBinder is what you’re looking for!
Read the rest of this entry »
Want to get rid of messy “PropertyChanged”-subscriptions and too many OnPropertyChanged(“…”) to manage value relations? Then DataBinder is what you’re looking for!
Read the rest of this entry »
Well – “as” is faster to type than a “real” cast using two brackets and has the same result. Really?
C# provides several ways to cast one type to another one. The two used in most cases are the “([Targettype]) [Variable]” and the “[Variable] as [Targettype]” notations. Many developers see them as equivalents, some even prefer “as” because it does not throw an exception when the cast fails.
Let’s say we have a variable called obj of type Object and we want to cast it to an IFoo so we can call IFoo.Bar:
object obj; //... (obj as IFoo).Bar();
Contracts? What are Contracts? And why are they reputed to be concerned with the type system? Aren’t they just injected into the executable? Is there maybe “more” behind them? And how should they really be used? Read this post for clarification.
There have been ? parts of the series “No interface Without Contract?” now. It’s not that I told you everything about Microsoft Code Contracts yet and there is nothing more to introduce. In fact this will not be the last part, but there will follow about three.
If you look at the previous parts, you will notice that they are quite distanced: All their content stands – less or more detailed – in the Code Contract’s manual. Thus, you may have noticed that I did not really go “deeper” by talking about my experience using them.
The reason for that is simple: I did not really think about one question: What are Code Contracts?
Invariants are a kind of postconditions which apply to all members. How to formulate them using Code Contracts?
In the previous part we got started using Microsoft Code Contracts and formulated first pre- and postconditions. We only looked at “simple” ones. In this posting you will learn what object invariants are and how they are connected with Code Contracts.
As anticipated in the introduction, invariants can be compared to postconditions valid for all members of a class. In fact, you are actually able to modulate them using Contract.Ensures(invariant) in each member.
However, they are more than simple postconditions – they are always valid, regardless of the object’s state. So invariants must never be broken during an object’s lifetime. Thus, other members can rely on them like on preconditions.
How can ViewModels become nearly independant from their concrete view but still keep the control over it?
IUserInteracter can be an answer.
Note: This posting is part of a series. See MVVM-Library for other parts and download.
As the last part of this series is more than one month ago, I really have to publish this now
So please excuse some undocumented parts, unfinished classes and not working code in the MVVM-Library. I will correct it later.
In the last part we were able to abstract the user interface using the IUserInterface interface. At the end, we could use this IUserInterface to show IShowables. However, we do not have any Showables yet – so we can not really use our IUserInterface.
Now we want to connect the IUserInterface and our ViewModels.
Let’s start!
Not very special but useful: A helper class for performance comparisons using a Stopwatch.
You may know the Stopwatch class which enables much more accurate performance tests than the DateTime struct.
This little helper class makes it use a little bit easier and more comfortable.
Let’s look at a sample test first which introduces the syntax:
static void Main(string[] args) { PerformanceTestRunner runner = new PerformanceTestRunner(1000, WhileLoop, ForLoop); runner.Run(); foreach (PerformanceTestResult result in runner.Results) Console.WriteLine("Result of {0}: Minimum: {1}; Average: {2}", result.Test.Name, result.MinimumTicks, result.AverageTicks); Console.ReadKey(); }
Distinguish between overloaded methods in XML-Comments
July 28, 2009 — winsharp93XML-Comments are quite handy when documenting public methods / classes. But what about method overloads in “see”-Tags?
Today when documenting some methods of a class using XML-Comments, I got a ReSharper message saying
However, ReSharper did not provide any automatic solution. So I had to find one myself
Read the rest of this entry »