Dec 22 2011

Compare two objects’ hierarchy

Category: C# | Linq — Duke @ 17:47

I think that everyone sometime is in the situation to understand which are the difference between two objects.

Sometime it is easy but sometime is not. Imagine that you have to prepare for your user a log of all the difference and changes that has been applied on a complex document object model.

I’m in this situation: I have NHibenrate that maps a database. As usual the principal entity of the domain have dozens and dozens of sub entities.

This complex structure is subject to revision from the user. There is a workflow to generate and approve a newer version of the object graph, but as the graph is complex, the user want to have a report of what is changed. from the last approved version. ok: now I have an graph of objects that represent the current situation, and a graph of objects that represent the last approved version.

How to solve this issue? Next: once you have discovered where the objects differs, you maybe want to see which is the actual value and understand which was the old value and which is the new one. Finally, maybe you want to revert some of the difference…. how you can do it in an efficient and powerful way? the reply is EXPRESSIONS From linq on, .NET have gained one of the best thing I ever seen in a programming language, the ability to manipulate code as it is data.

This possibility is SIMPLY AMAZING. I’ve already used this in SyncWcf and now I’ve another clue that makes me love expression more and more. so what I’ve done? give a look at the code below: More...

Tags: , , , ,

Jan 6 2011

Running VirtualBox as 64 Bit windows service

Category: C# | Virtual Machines — Duke @ 13:19
It is some time that I’m interested in virtualization: I think it is a nice way to keep my machine healty and clean, and in the same time it allows me to experiment and do “distruptive” things.
I love the possibility to take snapshots and recover a previous state in a moment!
Probably some of you have noticed that “photoatomiclab.net” is not always online(there is a reason for this you’ll discover in a moment), right? I know it is boring and frustrating when a resource is not available when you need it, and for this I’m really sorry.
So… I’ve started thinking on how to improve the thing. First of all: my favorite virtualization environment is VirtualBox (too bad Oracle have bought it, I hope it will not ruine all this good work) I like it because is free, is fast (in my opinion far better than VMWare) and it is supported by an opensource community… and having the source code in your hands you can do great things.
Anyway… my site is not always available: that’s because it is hosted on a virtual machine on my real machine! ANd this because I always like to know the internals and from time to time I had some crazy ideas: like streaming the town fest in the square in front of my windows using my HD camera ( LOL, usually I did this on xmas night) or connect some netduino robots and drive it from a web interface… this requires me to have a host where I really can do everything. and these host services are not cheap, unfortunately Triste 
But hey! VirtualBox really saves the day! So I  have this virtualmachine “Bear” that runs my site… the one you are reading now. And it is hosted on my real machine… and my machine is housed in my bedroom… and at night I like to sleep A bocca aperta 
It is natural that I shut id down at night… and therefore the site becomes unavailable….
Again, my pc is setup to start up at about 14.00 CET every day (that’s because it have to record my favorite tv series…. but this is another story) and since I’m forgetful, I usually don’t remember to turn the VM on, so I’ve tough to improve the situation… I’ve started searching for a tool that allows me to automatically starts my VM up when the pc starts.
I’ve found VirtualBox headless mode… nice! but… I have not found a way to use it… expecially because for the shutd down part… I want my VM freezes its state when the pc is shutted down.. I don’t want to loose the last change on the site, nor to wait minutes for the virtualized machine shut down…
I’ve serched for days but nothing appears to be a strong solution…. there are some services that tries to emulate this but at the end they open a shell and invokes the command line version ov VBOX and “do things”
this have the bad behavior (in the major part of the occasions) to open console windows for some seconds, or to leave consoles opened…. and if you close the console .. the VM dies Triste
this is ugly and completely unprofessional.
But fortunately VirtualBox is opensource! and there are SDKs!!

Tags: ,