public override void Configure(Container container)
		{
			//Permit modern browsers (e.g. Firefox) to allow sending of any REST HTTP Method
			base.SetConfig(new EndpointHostConfig
			{
				GlobalResponseHeaders =
					{
						{ "Access-Control-Allow-Origin", "*" },
						{ "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" },
					},
				  DefaultContentType = ContentType.Json 
			});
			
			
			var config = new AppConfig(new ConfigurationResourceManager());
			container.Register(config);

			if (!Directory.Exists(config.PhotoDirectory))
			{
				Directory.CreateDirectory(config.PhotoDirectory);
			}
							
			
			OrmLiteConfig.DialectProvider= GetDialectProvider(config);
			
			IDbConnectionFactory dbFactory = new OrmLiteConnectionFactory(
				ConfigUtils.GetConnectionString("ApplicationDb"));
			
			container.Register<Factory>(
				new Factory(){
					DbFactory=dbFactory
				}
			);
			
			CreateAppTables(dbFactory);
			
			ConfigureAuth(container);
			
			ConfigureServiceRoutes();
			
			log.InfoFormat("AppHost Configured: " + DateTime.Now);
		}
		private  IOrmLiteDialectProvider GetDialectProvider(AppConfig config)
		{
			var ds = ConfigUtils.GetDictionaryFromAppSetting("DialectProvider");						
				
			var assembly = Assembly.LoadFrom(Path.Combine(config.LibDirectory, ds["AssemblyName"]));
			var type = assembly.GetType(ds["ClassName"]);
			if (type == null)
				throw new Exception(
					string.Format("Can not load type '{0}' from assembly '{1}'",
						ds["ClassName"], Path.Combine(config.LibDirectory , ds["AssemblyName"])));
			
			var fi = type.GetField(ds["InstanceFieldName"]);
			if (fi == null)
				throw new Exception(
					string.Format("Can not get Field '{0}' from class '{1}'",
						ds["InstanceFieldName"], ds["ClassName"]));

			var o = fi.GetValue(null);
			var dialect = o as IOrmLiteDialectProvider;

			if (dialect == null)
				throw new Exception(
					string.Format("Can not cast  from '{0}' to '{1}'",
						o, typeof(IOrmLiteDialectProvider))
				);

			return dialect;
		
		}