POCO Custom Multifile Assembly and ReSharper
I recently compiled all the libraries from my most recent post on LINQ To SQL, into a Multifile Assembly so people could play with the bits without having to load up the projects that make up the POCO Framework which contains the Repository / Specification and Fetching Strategy libraries in it’s VS.Net solution.
The trick in creating a custom multifile assembly is to take all the files from the libraries that you wish to blend into one assembly, compile them into netmodules and then combine them all with the Assembly Linker otherwise know as al.exe. In my case the modules were as below:
and the last command I had to execute on the command line was:
al <module name> <module name> … /main:<method name> /out:<file name> /target:<assembly file type>
where the module names were from my list above.
One thing to watch out for if your a ReSharper user: the multifile assembly (your DLL compiled from the netmodules) may not be recognised correctly by intellisense in VS.Net 2008 and may report that it cannot resolve symbols. I didn’t dig into the cause of this problem however turning ReSharper off will stop the warning and code window highlighting but the problem does not stop VS.Net successfully building and executing your code nonetheless.
As you can see, the ‘Repository’ type is not having intellisense resolve it correctly and it is showing up in RED! But let me re-iterate that this will not preclude your code from building and running in VS.Net 2008 and turning off ReSharper will remove the intellisense problem altogether.
The multifile assembly for my previous posts code can be found here and if you browse it in Reflector you can see that it incorporates all the namespaces and code from the multiple projects in the LINQ To SQL going POCO solution.
No commentsIE 7.0 can drive me nuts and how to default start your XBAP in FireFox.
Well I can scarcely believe it myself. If you had asked me a few years ago if I could imagine using FireFox as my preferred debugging environment in .NET then I would have laughed hard, but yes folks it’s true. IE 7.0 is driving me insane with how slow it is whilst debugging. Let me take you through a course of events that led me to writing this post.
It all began with me developing a company intranet application using WPF XBAP technology and several views (I am using MVC) into it I decided to update my source control to tortoise 1.5.0 and grab the newest version of Ankh as it was meant to work nicely in Vista. So, no problems with the installs and just as I open up VS.NET 2008 I discover that the Ankh install has caused VS to loose its project history and my profile settings as well and it begins to set up as though for the first time.
Now I am a patient guy, so I just quickly get things back to the way they were and fire up my XBAP ready to start work again. I create another view port for my application and decide that I would like to run the application to see this new view…..oh oh, default settings have gone back to IE 7.0 and it’s a tad slower than FireFox in loading the application and just as slow in releasing the IE process and stopping the debugger too. I wondered if the trick to getting the XBAP back to loading by default in FireFox was the same as it is for ASP.Net? A quick look for the context menu option on the XAML files does not show up with a ‘browse with’ so I decided to open an ASP.Net application and reset the default browser from there, then switch back to the XBAP and hey presto - the problem is solved. See below for the visuals:
Go to an ASPX page and right click to get the context menu and select ‘Browse With’, then select FireFox as the default browser….reopen my WPF application and my XBAP now loads in FireFox by default and I’m all done!
No commentsGOF Series: Episode #2 [The Abstract Factory]
The pattern a day keeps the doctor away series continues. In the last instalment of the series we looked at the Factory Method pattern, this time we look at the Abstract Factory Pattern. The abstract Factory Pattern is useful in creating groups of related object types without a requirement to create their concrete types explicitly and achieves this by using composition where a class delegates the role of object instantiation to another class. This pattern can be described in UML like this:
The tests included (as per below) are for the purpose of demonstrating the code and are not meant to be taken as complete unit tests.
1: [Test]
2: public void AbstractFactoryTest()
3: {
4: //set an earlier time to that
5: //when the document is created
6: DateTime earlier =
7: DateTime.Now.Subtract(new TimeSpan(0, 1, 0));
8: //create the mock of the AncillaryService
9: var mock =
10: new Mock<AncillaryService>(new
11: LitigationSupportFactory());
12: mock.Object.
13: SetupProject("My Test Lit Support Project");
14: //use the factory method that create a new document
15: //using the mock instance object.
16: Document litDoc =
17: mock.Object.
18: NewDocument("Lit Support Test Document");
19: mock.Object.
20: PersistDocument(litDoc);
21: //perform the tests for
22: //the Lit support factory
23: //and the client (AncillaryService)
24: //that has it in its composite.
25: Assert.IsTrue(litDoc is LitigationSupportDocument);
26: Assert.IsTrue(litDoc.Name == "Lit Support Test Document");
27: Assert.That(litDoc.DateCreated.Value > earlier);
28: Assert.IsTrue(File.Exists
29: (@"C:\DevFileDrop\Lit Support Test Document.litdoc"));
30:
31: mock =
32: new Mock<AncillaryService>(
33: new ImageWorkflowFactory());
34: mock.Object.SetupProject("My Test IW Project");
35: ImageWorkflowDocument iwDoc =
36: mock.Object.
37: NewDocument("IW Test Document")
38: as ImageWorkflowDocument;
39: mock.Object.PersistAll();
40: Assert.IsTrue(iwDoc != null);
41: Assert.IsTrue(iwDoc.Name == "IW Test Document");
42: Assert.That(iwDoc.DateCreated.Value > earlier);
43: Assert.IsTrue(File.Exists
44: (@"C:\DevFileDrop\IW Test Document.iwdoc"));
45: }
The code above assumes the AncillaryService, LitigationSupportFactory and ImageWorkflowFactory classes (which are indeed in the download code. The link to the FULL example code can be found here and comes with all previous modules in the series and the accompanying power point presentation to explain each pattern in detail, so I wont repeat that content here.
No comments







