Jonathan Birkholz

Virtual Brown Bag 10/22/09

Today was a great virtual brown bag. Claudio will have a more exhaustive list of what was discussed, but I thought I would share some links to stuff I talked about.

Creating a Generic Type using Reflection

http://geekswithblogs.net/marcel/archive/2007/03/24/109722.aspx

1
2
3
4
5
public static object CreateGeneric(Type generic, Type innerType, params object[] args)
{
System.Type specificType = generic.MakeGenericType(new System.Type[] { innerType });
return Activator.CreateInstance(specificType, args);
}

StackOverflow Question from Marvin

http://stackoverflow.com/questions/1532991/help-with-a-windows-service-scheduled-task-that-must-use-a-web-browser-and-file-d

As Marvin and Claudio talked, I threw together an example on how I would solve the problem. Hopefully we can hear back from Marvin on whether it worked. :)

The code snippet is here : http://codesnippets.joyent.com/posts/show/2345

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var url = "http://www.codinghorror.com/blog/files/exported-font-and-colors-for-jeff-atwood-sept-19.zip";
var request = WebRequest.Create(url) as HttpWebRequest;
var response = request.GetResponse();
var readStream = response.GetResponseStream();
var fileStream = new FileStream(@"C:\temp\dlZip.zip", FileMode.Create);
int readByte = readStream.ReadByte();
while(readByte != -1)
{
fileStream.WriteByte((byte)readByte);
readByte = readStream.ReadByte();
}
fileStream.Flush();
fileStream.Close();

Using StructureMap with Castle Dynamic Proxy for INotifyPropertyChanged AOP

For creating the DynamicProxy interceptor I based my code off of : http://serialseb.blogspot.com/2008/05/implementing-inotifypropertychanged.html

The entire solution can be found here : http://github.com/RookieOne/StructureMapAopNotify

All in all, a darn good Virtual Brown Bag. :)

VBB