Welcome to MSDN Blogs Sign in | Join | Help

Another SSDS sample: BlogEngine.NET on SSDS

As a by-product of a project I'm working on, I've got a working version of BlogEngine.NET on SSDS. You can download the provider and other related components from LitwareHR's web site releases section here.

In the package you will find:

  1. The SSDS based BlogProvider
  2. An SSDS based Membership & Role Providers for the web site
  3. Unit tests for all (with about 93% coverage for the provider)
  4. A simple tool for pre-loading the SSDS container with information that BlogEngine need to start

The underlying data access is inspired on LitwareHR's, although I've heavily refactored it. The key ideas remain the same: there's a Repository<T> type, it uses SOAP to access SSDS, etc. but the code is simpler, responsibilities are better balanced and distributed, and I eliminated superfluous code here and there.

The new SSDS BlogProvider also uses patterns & practices Unity application block to wire up dependencies, so you write things like this:

public override Post SelectPost(Guid id)
{
    Post be_post;
    Entities.Post post;

    using (IRepository<Entities.Post> r_post = RepositoryFactory.Build<Entities.Post>())
    {
       post = r_post.GetById(id);
       if( post == null )
          return null;
    }

    be_post = SSDSPostToBEPost(post);

    return post;
}

RepositoryFactory.Build<T>() will use Unity's Resolve() method to find the appropriate Repository implementation and all its dependencies configured. Build<T>() body looks approximately like this:

c.RegisterType(typeof(ITenantManager), typeof(DefaultTenantManager));
c.RegisterType<SitkaProxyFactory, SitkaProxyFactory>();
c.RegisterType( typeof(EntityMapper<T>), typeof( GenericMapper<T> ) );
c.RegisterType( typeof(IRepository<T>), typeof( Repository<T> ) );

IRepository<T> r = c.Resolve<IRepository<T>>();
r.TenantId = Constants.BlogEngineContainer;
return r;

I'm still learning about Unity so there might be better ways of implementing what I did, but it works.

 

Things I've liked about BlogEngine.NET:

  • The provider model. I think it was great design decision that allowed me to write this fairly quickly. I didn't want to look to much into other pieces of BlogEngine.NET, and this provided a clear separation. 
  • The code structure is quite neat. Navigating it was painless and I used the same structure implemented in the XmlBlogProvider.
  • It's a nice app with a lot of functionality and a fun project to work with!

Things that I missed or would have liked to be different:

  • The one thing I missed the most is pre-built unit tests for the provider. 
  • There are some assumptions on the engine and core components about where it runs (particularly ASP.NET) that introduced some issues.
  • I only changed 1 line of code (which was superfluous anyway), and that is this in the Category class in BlogEngine.Core:
internal static string _Folder = System.Web.HttpContext.Current.Server.MapPath(BlogSettings.Instance.StorageLocation);

This prevented me from unit testing my provider in complete isolation. It turns out that the variable wasn't needed anyway, so I commented it out.

  • There are other features in the app that are not abstracted in the provider (or in another replaceable component). For example, file attachments are handled in the Add_Entry.aspx web page. I didn't want to use the file system at all, but I also didn't want to change the code, so I left it as is. There are other parts of the app that have direct dependencies like this.
  • I wasn't sure about the app exception handling architecture, so I opted to do what the other providers seem to be doing: just throw and hope the upper layers handle it :-).

 

BlogEngine.NET expects some initial data: a user, an admin role and some initial settings. The unit tests will make sure these exist prior to running, and I also created a "Provisioning" console application that populates the container with the needed information. You need to configure all appropriate configuration files with your SSDS credentials.

Finally, because I'm using LitwareHR's data access, you can use the offline proxy to test the system independently from SSDS. So, until you get the SSDS beta account, you can start playing with it.

Feedback is welcome, as usual.

Published Wednesday, June 11, 2008 4:01 PM by eugeniop

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Another SSDS sample: BlogEngine.NET on SSDS

This is great... it will save some time to.

Yesterday got my beta account for SSDS and the first thing I started with, is porting my blog based on blogengine.net to use SSDS… thanks. For sure feedback will follow ;-)

Thursday, June 12, 2008 12:36 AM by Clemens

# نرم افزار آموزش مجازی

i think that the blogengineis finding its position on the blog engines and the good thing is that it is using new technologies and i think that with fans it will be developed rapidly.

Thursday, June 12, 2008 1:00 AM by نرم افزار آموزش مجازی

# BlogEngine.NET en mode S+S avec SSDS

Allez, avouez, vous n'avez rien pig&#233; au titre de ce billet, si ? Alors je vous le refais en clair

Tuesday, June 17, 2008 4:57 AM by Christophe Lauer, Blog Edition

# Le moteur de blogs en .Net, BlogEngine, devient S+S !

Ce moteur, disponible ici en open source sur le site Codeplex , peut être configuré pour tirer avantage

Wednesday, June 18, 2008 7:54 AM by Web Hosting, French Way - by Laurent Bonnet [MS France]

# re: Another SSDS sample: BlogEngine.NET on SSDS

I have been learning SSDS and trying to use your code blogengine ssds source code to build my application.

I spent last 2 days.. couldn't find a reason...

I am running into a problem, when i compile and run the application, the code fails here:

ISitkaSoapService proxy = factory.Build("SitkaProxy");

--> calls the function:

public TTypeToBuild Build(string settingsKey)

       {

           string typeName = System.Configuration.ConfigurationSettings.AppSettings[settingsKey];

           TTypeToBuild typeToBuild;

           if (string.IsNullOrEmpty(typeName))

           {

               return new TDefaultType();

           }

           else

           {

               typeToBuild = Activator.CreateInstance(Type.GetType(typeName)) as TTypeToBuild;

           }

           return typeToBuild;

       }

And I get TargetInvocationException at :

typeToBuild = Activator.CreateInstance(Type.GetType(typeName)) as TTypeToBuild;

the innerexception shows:

{"Could not find default endpoint element that references contract 'SitkaClient.ISitkaSoapService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element."}

i checked all the code/files.. am not sure what i am missing.. any help.. appreciate it..

Wednesday, August 13, 2008 11:18 PM by vontlin

# re: Another SSDS sample: BlogEngine.NET on SSDS

This looks like a misconfiguration. Check web.config.

Sunday, August 24, 2008 5:44 PM by Eugenio Pace

# Microsoft SQL Server Data Services (SSDS): First Contact

I have been reading about cloud computing quite a bit.&#160; I found that Microsoft is doing something

Sunday, October 05, 2008 3:31 PM by Colby Africa

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker