Highlight: LINQ to XML

Post Saturday, 29th March 2008 - Posted by Tom Bell

For my upcoming instant messaging project I will need to create a C# windows service for the Peer Mediator servers. To look into windows services using C# I decided to create a Cron-like service for scheduling. I decided the the crontab configuration file should be an XML file. I figured I could then use the new LINQ to XML technology in the .NET 3.5 framework. Below is an example of loading my crontab XML file using LINQ to XML in C#.

XDocument crontab = XDocument.Load("CronTab.xml"); var jobs = from job in crontab.Descendants("cronjob") select new { Schedule = job.Element("schedule").Value, Task = job.Element("task").Value }; foreach (var job in jobs) { Console.WriteLine("Schedule: " + job.Schedule); Console.WriteLine("Task: " + job.Task); }

LINQ is a great new technology in the 3.5 version of the .NET framework. You can also use LINQ to SQL which is similar except querying data from a SQL database, and LINQ to Objects which allows you to query collections of objects.

Tags tags: xml linq .net 

.NET Framework, LINQ, and Other News

Post Wednesday, 19th March 2008 - Posted by Tom Bell

Having looked at C# back when it was first released to the public I didn't make much of it, and continued using C and C++. Now the 3.5 .NET framework is out I have been convinced to take another look at C# and ASP.NET by my friend Martin. I have updated from just using Visual C++ 6.0 to Visual Studio 2008 which was provided by my University's MSDNAA.

I have begun working on a web service in C#, and ASP.NET that will provide an instant messenger like protocol. .NET 3.5 makes it very easy for a developer to create a web service. The web service is wrapped around SOAP protocol. My instant messaging protocol uses simple methods to currently login and out of the service, and get your friends list. This is constantly being worked on and will see a beta service being rolled out within the next few months. The web service is also making use of the new technology called LINQ. LINQ stands for Language Integrated Query which allows native data querying in code using a syntax similar to SQL. My web service uses LINQ to SQL quite heavily to interact with the SQL server. I will create a project page for my instant messaging web service soon with more specific details.

An interesting Microsoft research project I have been following is F#, which is a language that is similar to OCaml. F# is a .NET framework targetted language that uses a functional programming paradigm, as well as imperative object-oriented programming disciplines. It is still only a research project but it is coming along quite fast, if you're a fan of OCaml, or other functional programming languages, you may wish to take a look at F#.

Another interesting preview project I was told about is the Microsoft ASP.NET MVC preview. As many people know I have a MVC project for PHP called CarbonPHP. MVC is a design pattern (model-view-controller) whereby the business logic and presentation are split up. Microsoft has released a preview of the upcoming MVC framework for ASP.NET. More information about the ASP.NET MVC can be found here http://asp.net/mvc/.

Tags tags: mvc .net asp.net c# 

Testing New Blog Backend

Post Sunday, 2nd March 2008 - Posted by Tom Bell

If you're seeing this it means my new blog backend has successfully been converted to use CarbonPHP instead of the system I used before I wrote CarbonPHP

Edit: testing the edit feature in the admin panel.

Testing Google's Prettify JavaScript code for syntax highlighting.

C code

#include <stdio.h> int main(int argc, char** argv) { printf("Hello world!\n"); return 0; }

C# code

Using System; namespace Testing { public class HelloWorld { static public void Main(string[] args) { Console.WriteLine("Hello world!"); } } }

PHP code

include('some_file.php'); class someClass { public function __construct() { echo 'Constructor!'; } }