Friday, January 29, 2010

Setting Up MVC

Having moved to the RC version of ASP.NET MVC 2.0, I've been looking around for resources (some repetition follows):

Google Data And Client Libraries

Quick link for those looking to get the Google .NET API:
Working with Google's APIs to extract I've discovered some very useful links:
I've now been attempting this fun for a little while and there seems to be a fair bit of mis-direction around the Google .NET APIs. My (and others, it seems) main concern is that the .NET APIs seem to cater very well for most Google Labs/Apps uses, except for Google Analytics. Issue #1 being how to even get access/login with .NET. I have since discovered the actual Analytics .NET libraries, so the links are here. However, currently, it's important to note that the links above don't directly link to the libraries you really need.
The code I used to get an authentication token from the Google Analytics Service is:

using Google.GData.Analytics;

AnalyticsService analyticsService = new AnalyticsService(ConfigurationManager.AppSettings["ApplicationName"]);
analyticsService.setUserCredentials(ConfigurationManager.AppSettings["Email"], ConfigurationManager.AppSettings["Password"]);
string analyticsAuthToken = analyticsService.QueryClientLoginToken();
return analyticsAuthToken;

Wednesday, January 27, 2010

Transforming XML Browser-Side

I like using XML and XSLT and find it a simple and powerful way to produce friendly, web-centric content. My utopia would be an easy to develop SQLXML output, which can be pumped as directly as possible to the browser, which then uses XSLT client side to render XHTML.

Currently, this is possible by using (for me) C# to pull the SQLXML content from the DB (I'm using T-SQL, ie: MSSQL http://msdn.microsoft.com/en-us/library/ms345117(SQL.90).aspx), processing it using the .NET XML transformation API (http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=63) and pushing the produced XHTML to the browser.

This approach is good because any extraneous processing or user values, validation, security and browser differences can be catered for, while removing strain on the browser. It's important to note that asking the client to do the XSL transformation isn't a great idea because browsers like Mobile Safari will ask a remote service to do the transform, which slows things down and will obfuscate a lot of data away from your app.

However, if you want to go ahead with having the browser do the heavy XSLT lifting, the best place to start is:

Posting Data From Server Side

Just a quick link, but might bolster this with more useful stuff later...

Sunday, January 24, 2010

Generics

Generics. They're generic. Sssss...

Good link:
Something I was wondering about recently was how to define constraints upon multiple generic types. Eg: If I have a class definition with more than one generic:
public class MyClass

How do I specify constraints (restrictions to the base types which the generic types can inherit from)? Answer (from the link above [5th code paragraph]):

public class MyClass
where T : String
where K : IComparable

Easy when you know how.

Wednesday, January 20, 2010

SQL Trees

Ok, so it's been bugging me for ages, I'm just going to start compiling all the SQL tree structure knowledge here. I might have started this in a previous post, and will try to find that, if I did, and aggregate the posts sometime...

Friday, January 08, 2010