I am selfhosting an OData application. This currently involves a lot of hard-coding: In my DataService class itself:
public static void InitializeService(
DataServiceConfiguration config)
{
// Provide read-only access to all entries and feeds.
config.SetEntitySetAccessRule(
"*", EntitySetRights.AllRead);
config.SetServiceOperationAccessRule("*", ServiceOperationRights.AllRead);
config.UseVerboseErrors = true;
config.DataServiceBehavior.MaxProtocolVersion = System.Data.Services.Common.DataServiceProtocolVersion.V2;
}
and when initialising:
Type servicetype = typeof(MessageDataService);
Uri baseaddress = new Uri("http://localhost:8000/messageData");
Uri[] baseaddresses = new Uri[] { baseaddress };
using ( DataServiceHost dshost = new DataServiceHost(servicetype, baseaddresses))
{
dshost.Open();
//blah
}
I think this can be adequately summorised with "yuk". Now I can configure other WCF services neatly through App.config
. Is there anything out of the box for Data services too, or should I roll my own configuration classes?
WCF Data Services currently doesn't read any configuration from the config files. So rolling your own solution is the way to go.