I am using Sterling in my normal silverlight project and all i am doing is adding this to App.xaml..
<Application.ApplicationLifetimeObjects>
<common:SterlingService />
<appServices:WebContext>
<appServices:WebContext.Authentication>
<!--<appsvc:FormsAuthentication/>-->
<appsvc:WindowsAuthentication />
</appServices:WebContext.Authentication>
</appServices:WebContext>
</Application.ApplicationLifetimeObjects>
common references the SterlingService.cs fine i copied from the examples.. Starts like this
namespace Common
{
public sealed class SterlingService : IApplicationService, IApplicationLifetimeAware, IDisposable
{
public const long KILOBYTE = 1024;
public const long MEGABYTE = 1024 * KILOBYTE;
public const long QUOTA = 100 * MEGABYTE;
private SterlingEngine _engine;
private static readonly ISterlingDriver _driver = new IsolatedStorageDriver(); // could use this: new MemoryDriver();
public static SterlingService Current { get; private set; }
}
later i just created a wrapper around this service like soo.. and i just call SterlingService where ever i need to reference the service like so... Hope this helps.
[ExportService(ServiceType.Runtime, typeof(IOffLineDataService))]
public sealed class OfflineDataService : IOffLineDataService
{
User user = WebContext.Current.User;
public OfflineDataService()
{
}
public void PurgeAll(Action<Exception> callback)
{
try
{
SterlingService.Current.Database.Purge();
callback(null);
}
catch (Exception ex)
{
Error.LogError(ex, user);
callback(new Exception(ErrorMessages.OfflinePurgeAll));
}
}
}