Using DataAnnotations to validate model in a S#harp Architecture Project
Published August 25, 2010 MVC , sharparchitecture Leave a CommentTags: DataAnnotations
S#harp Architecture – Testing multiple database mappings in MappingIntegrationTests
Published August 3, 2010 MVC , c# , nhibernate , sharparchitecture Leave a CommentTags: c#, mvc, sharparchitecture
//Add a list that holds the session keys
private List<string> sessionKeys;
[SetUp]
public virtual void SetUp()
{
string[] mappingAssemblies = RepositoryTestsHelper.GetMappingAssemblies();
configuration = NHibernateSession.Init(new SimpleSessionStorage(), mappingAssemblies,
new AutoPersistenceModelGenerator().Generate(),
"../../../../app/Humanities.IBusiness.Web/NHibernate.config");
/* ADD EXTRA DB'S TO SESSION CONFIG */
var configuration2 = NHibernateSession.AddConfiguration(DataGlobals.ROLES_DB_FACTORY_KEY,
mappingAssemblies,
new AutoPersistenceModelGenerator().Generate(),
"../../../../app/Humanities.IBusiness.Web/NHibernateForRolesDb.config",null,null, null);
/* ADD EACH SESSION KEY TO LIST */
sessionKeys = new List<string>();
sessionKeys.Add(DataGlobals.DEFAULT_DB_KEY);
sessionKeys.Add(DataGlobals.ROLES_DB_FACTORY_KEY);
}
[Test]
public void CanConfirmDatabaseMatchesMappings()
{
//GET ALL META DATA FROM SESSION (NOTE DOESN@T MATTER WHICH SESSION FACTORY IS USED!
var allClassMetadata = NHibernateSession.GetDefaultSessionFactory().GetAllClassMetadata();
if (NHibernateSession.IsConfiguredForMultipleDatabases())
{
//INTEROGATE EACH CLASS
foreach (var entry in allClassMetadata)
{
bool found = false;
//ENSURE EACH CLASS MAPS TO A DB
foreach (string key in sessionKeys)
{
ISession session = NHibernateSession.CurrentFor(key);
try
{
session.CreateCriteria(entry.Value.GetMappedClass(EntityMode.Poco))
.SetMaxResults(0).List();
found = true;
}
catch (Exception ex) { }
}
if (found == false)
throw new MappingException("Mapping not found for " + entry.Key.ToString());
}
}
else //Do what you'd normally do or do the above...
SharpArchitecture gitignore
Published July 20, 2010 MVC , Web Dev , git , sharparchitecture Leave a CommentI’ve been using Sharp as an MVC framework and git as my source control. Below is my gitignore file that allows me to track only the files I wish to track.
#SharpArch ignores #Folders lib/ logs/ build/ db/ tools/ #Files /CommonAssemblyInfo.cs CommonAssemblyInfo.cs *.obj *.pdb *.user *.aps *.pch *.vspscc *_i.c *_p.c *.ncb *.suo *.tlb *.bak *.cache *.ilk *.log *.dll *.DLL *.config *.sql *.txt *.tt #*/AssemblyInfo.cs #/*/AssemblyInfo.cs *AssemblyInfo.cs
(Trying) To implement RESTful web services in .net 3.5
Published May 19, 2010 Uncategorized Leave a CommentI’m sure this should be easier than it is….
So far I’ve used WCF REST Starter Kit and been following REST in WCF guidelines.
In particular A Guide to Designing and Building RESTful Web Services with WCF 3.5 is useful as is the video “Building resource singleton services with WCF starter kit“.
Also these screencasts are worth a watch.
A record of my asp.net MVC stack
Published April 22, 2010 Uncategorized Leave a CommentTags: mvc, asp.net, nhibernate
For my next project I’ll be using asp.mvc2. To this end I’ve been trying to make sense of the tools and libraries that I’ll need to accomplish this. I’m eager to avoid a complete stack like http://sharparchitecture.net/ until I’ve completely got my head around each component. I usually find it better for understanding to build from the ground up rather than to try and decompile the steps that others have taken in adopting a particular stack.
So far I’ve got the following:
Moq
Nunit
Castle Windsor
Inversion of Control and Dependency Injection with Castle Windsor Container – Part I
Inversion of Control and Dependency Injection with Castle Windsor Container – Part II
Inversion of Control and Dependency Injection with Castle Windsor Container – Part III
Inversion of Control and Dependency Injection with Castle Windsor Container – Part IV
Inversion of Control Containers and the Dependency Injection pattern – Martin Fowler
Fluent NHibernate
http://blogs.hibernatingrhinos.com/nhibernate/Default.aspx
http://dotnetslackers.com/articles/ado_net/Your-very-first-NHibernate-application-Part-1.aspx
ASP.MVC2
This list will likely increase and or change as I hone in the components that I really see advantage in.
Thanks to all those who attended the recent 21st Century Researcher Profiles Workshop. I always find it really interesting to talk with academics about their use of technology and the range of views about the role that social media can (or cannot) play in managing their professional reputation.
As promised here are the slides and handouts from the session. I would also really appreciate any feedback from the session and have included a link to a (very brief) online feedback form.
The slides
The handout
Forcing the NetTiers javascript calendar control to use UK dates
Published January 12, 2010 Programming Leave a CommentTags: date, javascript, nettiers
I’ve been using nettiers 2.3.0 with a new project that uses a lot of date fields.
I’ve had a problem with using the javascript calendar control that is produced with netTiers, in that it uses the American style date format mm/dd/yyyy. On DB set up for UK dates this causes a date conversion error.
At first I was hoping this could be ‘fixed’ by changing the culture info in the generated web.config file – to something like
However the nettiers js calendar control has no such built in globalisation logic.
It does however have a CalendarControl.js file where the string generated by the control is hard coded. So to make this generate UK style dates you simply need to change var dateString = month+”-”+day+”-”+year to var dateString = day+”-”+month+”-”+year
Using Technology to Enhance Your Teaching
Published November 25, 2009 21stCenturySkills , Ed Tech , Elearning , Workshops Leave a CommentThanks to all those who attended the recent “Using Technology to Enhance Your Teaching” workshop. I really enjoyed the session, especially hearing your stories about the technologies that you use in your teaching.
I’ve included all the materials used on the day and the mind map that we created from the activities that constitute your teaching.
The Slides
The Handout
The Mind Map
(Click on the image for the actual map)
George Veletsianos’s Slides
(see also George’s blog for more discussion in this area)
Some Reading
(See also http://delicious.com/tag/tech4training)
Handbook of Emerging Technologies”
Blogging with students… how and why
“Top 100 tools for learning 2009″
Tutorial on creating a blog and using RSS
Social Media Classroom – resources about teaching participatory media
How to create a blog with Blogger
7 things you should know about micro blogging
A write up of the “Twitter Experiment” – using twitter in a lecture setting
Using Technology to Enhance Your Research
Published November 11, 2009 21stCenturySkills , Workshops 2 CommentsHere are the resources for today’s 2 hour workshop for research staff. I’ll up date with items from the discussions after the event.
The Slides
The Handouts
Integrating technology into researcher training
Published September 15, 2009 21stCenturySkills , Elearning Leave a CommentI recently delivered a workshop at the Vitae Researcher Development conference in Warwick, called “Integrating technology into researcher training”.
The session looked at how researcher trainers can begin to incorporate technologies within their training.
The hands on session combined some practical activities with discussion about the best approaches, practicalities and potential pitfalls of using technology.
The slides and links to the artifacts used in the session are listed below.
1) The Slides
2) The Blog
3) The Mindmap
4) The Audience

