mirror of
https://github.com/digital-jellyfish/Virtu.git
synced 2024-06-02 12:41:31 +00:00
7b713e6aaa
Set svn properties on files. --HG-- extra : convert_revision : svn%3Affd33b8c-2492-42e0-bdc5-587b920b7d6d/trunk%4044493
62 lines
1.7 KiB
C#
62 lines
1.7 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.IO.IsolatedStorage;
|
|
|
|
namespace Jellyfish.Virtu.Services
|
|
{
|
|
public sealed class SilverlightStorageService : StorageService
|
|
{
|
|
public SilverlightStorageService(Machine machine) :
|
|
base(machine)
|
|
{
|
|
}
|
|
|
|
public override void Load(string path, Action<Stream> reader)
|
|
{
|
|
if (reader == null)
|
|
{
|
|
throw new ArgumentNullException("reader");
|
|
}
|
|
|
|
try
|
|
{
|
|
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
|
|
{
|
|
using (var stream = new IsolatedStorageFileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, store))
|
|
{
|
|
reader(stream);
|
|
}
|
|
}
|
|
}
|
|
catch (FileNotFoundException)
|
|
{
|
|
}
|
|
catch (IsolatedStorageException)
|
|
{
|
|
}
|
|
}
|
|
|
|
public override void Save(string path, Action<Stream> writer)
|
|
{
|
|
if (writer == null)
|
|
{
|
|
throw new ArgumentNullException("writer");
|
|
}
|
|
|
|
try
|
|
{
|
|
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
|
|
{
|
|
using (var stream = new IsolatedStorageFileStream(path, FileMode.Create, FileAccess.Write, FileShare.None, store))
|
|
{
|
|
writer(stream);
|
|
}
|
|
}
|
|
}
|
|
catch (IsolatedStorageException)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|