My Resume | Contact Me | RSS Feed | Follow Me on Twitter

Code Capers

The Ninja Coding Dojo
RSS Feed Twitter Email

First Encounters of the MEF Kind

clock March 14, 2010 by author Michael Ceranski
One of the newest additions to the .NET 4 framework is MEF. MEF stands for the Managed Extensibility Framework and is the answer to your prayers if you are building an app that allows developers to extend its functionality by building plugins. MEF makes the task of loading assemblies and utilizing their functionality very simple. Before we go any further there are a few basic terms that you must understand before you start using MEF: The Catalog is responsible for loading assemblies. There are several types of catalogs to chose from such as DirectoryCatalog and AssemblyCatalog which we will discuss in more detail later on.  The Container holds one or more catalogs. The Export attribute is used to decorate objects so they can be consumed by MEF. The Import attribute lets MEF know that an object is the target for one of more exported objects. A part is any object that is exported or imported. So in order to start using MEF, you need to create one or more ca... [More]


Client Side Validation with jQuery

clock February 24, 2010 by author Michael Ceranski
Validating user input on the client definitely has its advantages. It not only avoids unnecessary round trips to the server but it can also drastically improve the user experience. When I think about client side validation I think about jQuery. If you are familiar with jQuery, then you know that there are a ton a plug-ins available. Just like an Apple IPod has “an app for that”,  jQuery has a “plugin for that”. Anyway, after a quick search I discovered the jQuery Validation plugin. There are two different ways to use the Validation plugin. The first way, is to the pure JavaScript route. This means you establish all the validation rules, messages and callback events from code. The second way is to decorate your input fields with special CSS classes. The plugin will then inspect the class attribute of each field at runtime and apply validation rules accordingly. In the upcoming example, I used the CSS approach. However, if you decided that you want to go in the other direction ther... [More]


Getting Started with LINQ to XML

clock February 21, 2010 by author Michael Ceranski
I recently announced the WeBlog project. WeBlog is a blogging platform which will support multiple data providers. Out of the box I plan on offering SQL Server and XML support. Most people like the XML option because it drastically reduces web hosting costs. The only problem with XML is that it can be painful to work with. In general, XML makes me want to pull my hair out! When building a blog you have a few basic entities that you need to deal with. Most typical blogs have posts, categories, tags, users and roles. Therefore I made an XML file to represent each of these items. However, for this tutorial I will focus on parsing the XML for categories. For a point of reference here is the XML structure that I am using to store category information:   <?xml version="1.0" encoding="utf-8"?> <categories> <category id="19770e74-9ec9-4cde-b2ab-e5051aaaf348" description="Posts about my adventures with WeBlog" par... [More]


Announcing WeBlog – A Next Generation Blogging Platform

clock February 19, 2010 by author Michael Ceranski
One of the best ways to keep your skills sharp as a developer is to start your own open source project. For the last 6 months or so I have been trying to come up with ideas on what kind of application I want to build. Since I enjoy blogging so much I decided that I will build my own blogging platform. There are a lot of good blogging platforms already available such as Wordpress, dasBlog and BlogEngine.NET. In order to make something comparative to these products will take a fair amount of time and effort. However, having a pet project like this is fun and I am really looking forward to working on it. The WeBlog (pronounced We Blog) project is hosted on codeplex. I have already checked in some code and things are starting to take shape even though it is still early in the process. If you want to compile the code you will need need Visual Studio 2010. I figured there is no point starting a project on old technology so I went for the latest and greatest technology with MVC 2 and the .N... [More]


Dynamic Master Pages in MVC

clock February 17, 2010 by author Michael Ceranski
I have been working on a new project where I wanted to introduce the concepts of themes. This means that end users will be allowed to change the look and feel of the web application from a configuration menu. In order to deliver this functionality I needed to be able to dynamically change the master page on the fly. My initial response was to use the Page PreInit event. The Page PreInit event is called write before the master page is assigned and therefore makes it a good candidate for dynamically assign the the master page. Unfortunately this is a Page level event. In order to use this solution I would need to override this method on every page. This would be a maintenance nightmare so I immediately eliminated this as a viable solution. Another solution is to use the View method to assign the master page. public ActionResult Index() { return View("Index", MyApp.Properties.Settings.Default.Theme); } Unfortunately, this solution is also a maintenance nightmare bec... [More]


About the author

MikeMy name is Michael Ceranski. I am a software developer from Buffalo NY. I have been writing code for over 10 years starting with Borland Delphi and later migrating to the .NET stack. I enjoy blogging about .NET, MVC and jQuery and I hope to spread my enthusiasm for technology by sharing my thoughts and ideas with you.

View my resume

Cumulus

This will be shown to users with no Flash or Javascript.

Sign in