Tôi đang sử dụng Sterling trong dự án Silverlight bình thường của tôi và tất cả tôi đang làm là thêm này để App.xaml ..
<Application.ApplicationLifetimeObjects>
<common:SterlingService />
<appServices:WebContext>
<appServices:WebContext.Authentication>
<!--<appsvc:FormsAuthentication/>-->
<appsvc:WindowsAuthentication />
</appServices:WebContext.Authentication>
</appServices:WebContext>
</Application.ApplicationLifetimeObjects>
tài liệu tham khảo chung SterlingService.cs tốt i sao chép từ các ví dụ .. Bắt đầu như này
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; }
}
sau tôi vừa tạo một wrapper xung quanh dịch vụ này như soo .. và tôi chỉ cần gọi SterlingService nơi nào tôi cần phải tham khảo các dịch vụ như vậy ... 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));
}
}
}
Nguồn
2011-09-04 20:34:14
Đã hy vọng bạn sẽ trả lời ... ;-). Tôi đoán, rằng nó hoạt động theo cách đó nhưng không nhận được 'vòng trả lời nó WE này. – AxelEckenberger
Cảm ơn, Laurent. Điều đó làm cho rất nhiều ý nghĩa. Tôi đang tiến gần hơn đến việc có thể tự mình trả lời những câu hỏi này chỉ vì nhìn vào mã, nhưng tôi vẫn chưa hoàn toàn ở đó. Đánh giá cao sự trợ giúp, như mọi khi. –